### RAW ASSEMBLY INSTRUCTIONS:

glabel update_encounters_post_battle
/* 1D310 80041F10 27BDFFC8 */  addiu     $sp, $sp, -0x38
/* 1D314 80041F14 AFB60028 */  sw        $s6, 0x28($sp)
/* 1D318 80041F18 3C16800B */  lui       $s6, %hi(gCurrentEncounter)
/* 1D31C 80041F1C 26D60F10 */  addiu     $s6, $s6, %lo(gCurrentEncounter)
/* 1D320 80041F20 AFB7002C */  sw        $s7, 0x2C($sp)
/* 1D324 80041F24 3C178011 */  lui       $s7, %hi(gPlayerStatus)
/* 1D328 80041F28 26F7EFC8 */  addiu     $s7, $s7, %lo(gPlayerStatus)
/* 1D32C 80041F2C AFB00010 */  sw        $s0, 0x10($sp)
/* 1D330 80041F30 3C108011 */  lui       $s0, %hi(gPlayerData)
/* 1D334 80041F34 2610F290 */  addiu     $s0, $s0, %lo(gPlayerData)
/* 1D338 80041F38 3C04800A */  lui       $a0, %hi(gEncounterSubState)
/* 1D33C 80041F3C 2484A5D0 */  addiu     $a0, $a0, %lo(gEncounterSubState)
/* 1D340 80041F40 AFBF0034 */  sw        $ra, 0x34($sp)
/* 1D344 80041F44 AFBE0030 */  sw        $fp, 0x30($sp)
/* 1D348 80041F48 AFB50024 */  sw        $s5, 0x24($sp)
/* 1D34C 80041F4C AFB40020 */  sw        $s4, 0x20($sp)
/* 1D350 80041F50 AFB3001C */  sw        $s3, 0x1C($sp)
/* 1D354 80041F54 AFB20018 */  sw        $s2, 0x18($sp)
/* 1D358 80041F58 AFB10014 */  sw        $s1, 0x14($sp)
/* 1D35C 80041F5C 8C830000 */  lw        $v1, 0x0($a0)
/* 1D360 80041F60 24050066 */  addiu     $a1, $zero, 0x66
/* 1D364 80041F64 106501FC */  beq       $v1, $a1, .L80042758
/* 1D368 80041F68 28620067 */   slti     $v0, $v1, 0x67
/* 1D36C 80041F6C 1040001D */  beqz      $v0, .L80041FE4
/* 1D370 80041F70 24020004 */   addiu    $v0, $zero, 0x4
/* 1D374 80041F74 10620183 */  beq       $v1, $v0, .L80042584
/* 1D378 80041F78 28620005 */   slti     $v0, $v1, 0x5
/* 1D37C 80041F7C 10400009 */  beqz      $v0, .L80041FA4
/* 1D380 80041F80 24020002 */   addiu    $v0, $zero, 0x2
/* 1D384 80041F84 1062011C */  beq       $v1, $v0, .L800423F8
/* 1D388 80041F88 28620003 */   slti     $v0, $v1, 0x3
/* 1D38C 80041F8C 1040011F */  beqz      $v0, .L8004240C
/* 1D390 80041F90 0000902D */   daddu    $s2, $zero, $zero
/* 1D394 80041F94 10600037 */  beqz      $v1, .L80042074
/* 1D398 80041F98 00000000 */   nop
/* 1D39C 80041F9C 08010BD3 */  j         .L80042F4C
/* 1D3A0 80041FA0 00000000 */   nop
.L80041FA4:
/* 1D3A4 80041FA4 2402000B */  addiu     $v0, $zero, 0xB
/* 1D3A8 80041FA8 106200B3 */  beq       $v1, $v0, .L80042278
/* 1D3AC 80041FAC 2862000C */   slti     $v0, $v1, 0xC
/* 1D3B0 80041FB0 10400005 */  beqz      $v0, .L80041FC8
/* 1D3B4 80041FB4 2402000A */   addiu    $v0, $zero, 0xA
/* 1D3B8 80041FB8 10620090 */  beq       $v1, $v0, .L800421FC
/* 1D3BC 80041FBC 00000000 */   nop
/* 1D3C0 80041FC0 08010BD3 */  j         .L80042F4C
/* 1D3C4 80041FC4 00000000 */   nop
.L80041FC8:
/* 1D3C8 80041FC8 24020064 */  addiu     $v0, $zero, 0x64
/* 1D3CC 80041FCC 106201B1 */  beq       $v1, $v0, .L80042694
/* 1D3D0 80041FD0 24020065 */   addiu    $v0, $zero, 0x65
/* 1D3D4 80041FD4 106201DB */  beq       $v1, $v0, .L80042744
/* 1D3D8 80041FD8 00000000 */   nop
/* 1D3DC 80041FDC 08010BD3 */  j         .L80042F4C
/* 1D3E0 80041FE0 00000000 */   nop
.L80041FE4:
/* 1D3E4 80041FE4 240200CB */  addiu     $v0, $zero, 0xCB
/* 1D3E8 80041FE8 106202F9 */  beq       $v1, $v0, .L80042BD0
/* 1D3EC 80041FEC 286200CC */   slti     $v0, $v1, 0xCC
/* 1D3F0 80041FF0 10400010 */  beqz      $v0, .L80042034
/* 1D3F4 80041FF4 240200C8 */   addiu    $v0, $zero, 0xC8
/* 1D3F8 80041FF8 10620278 */  beq       $v1, $v0, .L800429DC
/* 1D3FC 80041FFC 286200C9 */   slti     $v0, $v1, 0xC9
/* 1D400 80042000 10400005 */  beqz      $v0, .L80042018
/* 1D404 80042004 24020067 */   addiu    $v0, $zero, 0x67
/* 1D408 80042008 1062025A */  beq       $v1, $v0, .L80042974
/* 1D40C 8004200C 00000000 */   nop
/* 1D410 80042010 08010BD3 */  j         .L80042F4C
/* 1D414 80042014 00000000 */   nop
.L80042018:
/* 1D418 80042018 240200C9 */  addiu     $v0, $zero, 0xC9
/* 1D41C 8004201C 1062029B */  beq       $v1, $v0, .L80042A8C
/* 1D420 80042020 240200CA */   addiu    $v0, $zero, 0xCA
/* 1D424 80042024 1062029E */  beq       $v1, $v0, .L80042AA0
/* 1D428 80042028 0000902D */   daddu    $s2, $zero, $zero
/* 1D42C 8004202C 08010BD3 */  j         .L80042F4C
/* 1D430 80042030 00000000 */   nop
.L80042034:
/* 1D434 80042034 24020190 */  addiu     $v0, $zero, 0x190
/* 1D438 80042038 1062031E */  beq       $v1, $v0, .L80042CB4
/* 1D43C 8004203C 28620191 */   slti     $v0, $v1, 0x191
/* 1D440 80042040 10400005 */  beqz      $v0, .L80042058
/* 1D444 80042044 2402012C */   addiu    $v0, $zero, 0x12C
/* 1D448 80042048 106202F2 */  beq       $v1, $v0, .L80042C14
/* 1D44C 8004204C 00000000 */   nop
/* 1D450 80042050 08010BD3 */  j         .L80042F4C
/* 1D454 80042054 00000000 */   nop
.L80042058:
/* 1D458 80042058 24020191 */  addiu     $v0, $zero, 0x191
/* 1D45C 8004205C 1062033E */  beq       $v1, $v0, .L80042D58
/* 1D460 80042060 24020192 */   addiu    $v0, $zero, 0x192
/* 1D464 80042064 10620349 */  beq       $v1, $v0, .L80042D8C
/* 1D468 80042068 0000902D */   daddu    $s2, $zero, $zero
/* 1D46C 8004206C 08010BD3 */  j         .L80042F4C
/* 1D470 80042070 00000000 */   nop
.L80042074:
/* 1D474 80042074 82C20008 */  lb        $v0, 0x8($s6)
/* 1D478 80042078 104003E8 */  beqz      $v0, .L8004301C
/* 1D47C 8004207C 00000000 */   nop
/* 1D480 80042080 A2C00008 */  sb        $zero, 0x8($s6)
/* 1D484 80042084 A6E00010 */  sh        $zero, 0x10($s7)
/* 1D488 80042088 0C03A5F9 */  jal       func_800E97E4
/* 1D48C 8004208C A2C00012 */   sb       $zero, 0x12($s6)
/* 1D490 80042090 A2C000A0 */  sb        $zero, 0xA0($s6)
/* 1D494 80042094 A2C000A4 */  sb        $zero, 0xA4($s6)
/* 1D498 80042098 A2C000A8 */  sb        $zero, 0xA8($s6)
/* 1D49C 8004209C A2C000AC */  sb        $zero, 0xAC($s6)
/* 1D4A0 800420A0 3C02800A */  lui       $v0, %hi(D_8009A654)
/* 1D4A4 800420A4 8042A654 */  lb        $v0, %lo(D_8009A654)($v0)
/* 1D4A8 800420A8 24110001 */  addiu     $s1, $zero, 0x1
/* 1D4AC 800420AC A6C000A2 */  sh        $zero, 0xA2($s6)
/* 1D4B0 800420B0 A6C000A6 */  sh        $zero, 0xA6($s6)
/* 1D4B4 800420B4 A6C000AA */  sh        $zero, 0xAA($s6)
/* 1D4B8 800420B8 14510003 */  bne       $v0, $s1, .L800420C8
/* 1D4BC 800420BC A6C000AE */   sh       $zero, 0xAE($s6)
/* 1D4C0 800420C0 0C052B9B */  jal       bgm_pop_battle_song
/* 1D4C4 800420C4 00000000 */   nop
.L800420C8:
/* 1D4C8 800420C8 3C03FFFB */  lui       $v1, (0xFFFBFFFF >> 16)
/* 1D4CC 800420CC 3463FFFF */  ori       $v1, $v1, (0xFFFBFFFF & 0xFFFF)
/* 1D4D0 800420D0 AED10098 */  sw        $s1, 0x98($s6)
/* 1D4D4 800420D4 AEC0009C */  sw        $zero, 0x9C($s6)
/* 1D4D8 800420D8 8EE20000 */  lw        $v0, 0x0($s7)
/* 1D4DC 800420DC 3C10800A */  lui       $s0, %hi(D_8009A670)
/* 1D4E0 800420E0 2610A670 */  addiu     $s0, $s0, %lo(D_8009A670)
/* 1D4E4 800420E4 A2000000 */  sb        $zero, 0x0($s0)
/* 1D4E8 800420E8 00431024 */  and       $v0, $v0, $v1
/* 1D4EC 800420EC AEE20000 */  sw        $v0, 0x0($s7)
/* 1D4F0 800420F0 82C30005 */  lb        $v1, 0x5($s6)
/* 1D4F4 800420F4 24020003 */  addiu     $v0, $zero, 0x3
/* 1D4F8 800420F8 50620001 */  beql      $v1, $v0, .L80042100
/* 1D4FC 800420FC A2110000 */   sb       $s1, 0x0($s0)
.L80042100:
/* 1D500 80042100 3C028007 */  lui       $v0, %hi(D_80077C40)
/* 1D504 80042104 8C427C40 */  lw        $v0, %lo(D_80077C40)($v0)
/* 1D508 80042108 14400003 */  bnez      $v0, .L80042118
/* 1D50C 8004210C A2C00005 */   sb       $zero, 0x5($s6)
/* 1D510 80042110 0C03ADB1 */  jal       partner_handle_after_battle
/* 1D514 80042114 00000000 */   nop
.L80042118:
/* 1D518 80042118 3C028011 */  lui       $v0, %hi(gPartnerStatus)
/* 1D51C 8004211C 2442EBB0 */  addiu     $v0, $v0, %lo(gPartnerStatus)
/* 1D520 80042120 80420001 */  lb        $v0, 0x1($v0)
/* 1D524 80042124 3C03800A */  lui       $v1, %hi(D_8009A63C)
/* 1D528 80042128 2463A63C */  addiu     $v1, $v1, %lo(D_8009A63C)
/* 1D52C 8004212C 10400003 */  beqz      $v0, .L8004213C
/* 1D530 80042130 A0600000 */   sb       $zero, 0x0($v1)
/* 1D534 80042134 0801085D */  j         .L80042174
/* 1D538 80042138 A0710000 */   sb       $s1, 0x0($v1)
.L8004213C:
/* 1D53C 8004213C 82020000 */  lb        $v0, 0x0($s0)
/* 1D540 80042140 1440000C */  bnez      $v0, .L80042174
/* 1D544 80042144 00000000 */   nop
/* 1D548 80042148 8EE20000 */  lw        $v0, 0x0($s7)
/* 1D54C 8004214C 30420006 */  andi      $v0, $v0, 0x6
/* 1D550 80042150 14400008 */  bnez      $v0, .L80042174
/* 1D554 80042154 24020021 */   addiu    $v0, $zero, 0x21
/* 1D558 80042158 82E300B4 */  lb        $v1, 0xB4($s7)
/* 1D55C 8004215C 10620005 */  beq       $v1, $v0, .L80042174
/* 1D560 80042160 2402001D */   addiu    $v0, $zero, 0x1D
/* 1D564 80042164 10620003 */  beq       $v1, $v0, .L80042174
/* 1D568 80042168 00000000 */   nop
/* 1D56C 8004216C 0C039769 */  jal       set_action_state
/* 1D570 80042170 0000202D */   daddu    $a0, $zero, $zero
.L80042174:
/* 1D574 80042174 82C30009 */  lb        $v1, 0x9($s6)
/* 1D578 80042178 2C620005 */  sltiu     $v0, $v1, 0x5
/* 1D57C 8004217C 10400373 */  beqz      $v0, .L80042F4C
/* 1D580 80042180 00031080 */   sll      $v0, $v1, 2
/* 1D584 80042184 3C01800A */  lui       $at, %hi(jtbl_80098698)
/* 1D588 80042188 00220821 */  addu      $at, $at, $v0
/* 1D58C 8004218C 8C228698 */  lw        $v0, %lo(jtbl_80098698)($at)
/* 1D590 80042190 00400008 */  jr        $v0
/* 1D594 80042194 00000000 */   nop
glabel .L80042198
/* 1D598 80042198 2402000A */  addiu     $v0, $zero, 0xA
/* 1D59C 8004219C 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D5A0 800421A0 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D5A4 800421A4 08010BD3 */  j         .L80042F4C
/* 1D5A8 800421A8 00000000 */   nop
glabel .L800421AC
/* 1D5AC 800421AC 240200C8 */  addiu     $v0, $zero, 0xC8
/* 1D5B0 800421B0 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D5B4 800421B4 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D5B8 800421B8 08010BD3 */  j         .L80042F4C
/* 1D5BC 800421BC 00000000 */   nop
glabel .L800421C0
/* 1D5C0 800421C0 24020064 */  addiu     $v0, $zero, 0x64
/* 1D5C4 800421C4 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D5C8 800421C8 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D5CC 800421CC 08010BD3 */  j         .L80042F4C
/* 1D5D0 800421D0 00000000 */   nop
glabel .L800421D4
/* 1D5D4 800421D4 2402012C */  addiu     $v0, $zero, 0x12C
/* 1D5D8 800421D8 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D5DC 800421DC AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D5E0 800421E0 08010BD3 */  j         .L80042F4C
/* 1D5E4 800421E4 00000000 */   nop
glabel .L800421E8
/* 1D5E8 800421E8 24020190 */  addiu     $v0, $zero, 0x190
/* 1D5EC 800421EC 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D5F0 800421F0 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D5F4 800421F4 08010BD3 */  j         .L80042F4C
/* 1D5F8 800421F8 00000000 */   nop
.L800421FC:
/* 1D5FC 800421FC 82C2000B */  lb        $v0, 0xB($s6)
/* 1D600 80042200 10400019 */  beqz      $v0, .L80042268
/* 1D604 80042204 2402000B */   addiu    $v0, $zero, 0xB
/* 1D608 80042208 8EC4008C */  lw        $a0, 0x8C($s6)
/* 1D60C 8004220C 0C012354 */  jal       get_coin_drop_amount
/* 1D610 80042210 00000000 */   nop
/* 1D614 80042214 1040000F */  beqz      $v0, .L80042254
/* 1D618 80042218 2405000A */   addiu    $a1, $zero, 0xA
/* 1D61C 8004221C 3C048007 */  lui       $a0, %hi(D_80077C44)
/* 1D620 80042220 24847C44 */  addiu     $a0, $a0, %lo(D_80077C44)
/* 1D624 80042224 0C0B0CF8 */  jal       start_script
/* 1D628 80042228 0000302D */   daddu    $a2, $zero, $zero
/* 1D62C 8004222C 3C03800A */  lui       $v1, %hi(D_800A0BB0)
/* 1D630 80042230 24630BB0 */  addiu     $v1, $v1, %lo(D_800A0BB0)
/* 1D634 80042234 AC620000 */  sw        $v0, 0x0($v1)
/* 1D638 80042238 A0400004 */  sb        $zero, 0x4($v0)
/* 1D63C 8004223C 8C620000 */  lw        $v0, 0x0($v1)
/* 1D640 80042240 8C420144 */  lw        $v0, 0x144($v0)
/* 1D644 80042244 3C01800A */  lui       $at, %hi(D_800A0BB4)
/* 1D648 80042248 AC220BB4 */  sw        $v0, %lo(D_800A0BB4)($at)
/* 1D64C 8004224C 0801089A */  j         .L80042268
/* 1D650 80042250 2402000B */   addiu    $v0, $zero, 0xB
.L80042254:
/* 1D654 80042254 9202028A */  lbu       $v0, 0x28A($s0)
/* 1D658 80042258 A600028C */  sh        $zero, 0x28C($s0)
/* 1D65C 8004225C 24420001 */  addiu     $v0, $v0, 0x1
/* 1D660 80042260 A202028A */  sb        $v0, 0x28A($s0)
/* 1D664 80042264 2402000B */  addiu     $v0, $zero, 0xB
.L80042268:
/* 1D668 80042268 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D66C 8004226C AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D670 80042270 08010BD3 */  j         .L80042F4C
/* 1D674 80042274 00000000 */   nop
.L80042278:
/* 1D678 80042278 82C2000B */  lb        $v0, 0xB($s6)
/* 1D67C 8004227C 10400013 */  beqz      $v0, .L800422CC
/* 1D680 80042280 00000000 */   nop
/* 1D684 80042284 0C012354 */  jal       get_coin_drop_amount
/* 1D688 80042288 8EC4008C */   lw       $a0, 0x8C($s6)
/* 1D68C 8004228C 1040000F */  beqz      $v0, .L800422CC
/* 1D690 80042290 00000000 */   nop
/* 1D694 80042294 8EC20098 */  lw        $v0, 0x98($s6)
/* 1D698 80042298 8EC30090 */  lw        $v1, 0x90($s6)
/* 1D69C 8004229C 24420004 */  addiu     $v0, $v0, 0x4
/* 1D6A0 800422A0 00621823 */  subu      $v1, $v1, $v0
/* 1D6A4 800422A4 AEC20098 */  sw        $v0, 0x98($s6)
/* 1D6A8 800422A8 04610002 */  bgez      $v1, .L800422B4
/* 1D6AC 800422AC AEC30090 */   sw       $v1, 0x90($s6)
/* 1D6B0 800422B0 AEC00090 */  sw        $zero, 0x90($s6)
.L800422B4:
/* 1D6B4 800422B4 3C04800A */  lui       $a0, %hi(D_800A0BB4)
/* 1D6B8 800422B8 8C840BB4 */  lw        $a0, %lo(D_800A0BB4)($a0)
/* 1D6BC 800422BC 0C0B1059 */  jal       does_script_exist
/* 1D6C0 800422C0 00000000 */   nop
/* 1D6C4 800422C4 14400321 */  bnez      $v0, .L80042F4C
/* 1D6C8 800422C8 00000000 */   nop
.L800422CC:
/* 1D6CC 800422CC 8ED40088 */  lw        $s4, 0x88($s6)
/* 1D6D0 800422D0 8E820000 */  lw        $v0, 0x0($s4)
/* 1D6D4 800422D4 18400031 */  blez      $v0, .L8004239C
/* 1D6D8 800422D8 0000982D */   daddu    $s3, $zero, $zero
/* 1D6DC 800422DC 24120001 */  addiu     $s2, $zero, 0x1
/* 1D6E0 800422E0 0280882D */  daddu     $s1, $s4, $zero
.L800422E4:
/* 1D6E4 800422E4 8E300004 */  lw        $s0, 0x4($s1)
/* 1D6E8 800422E8 12000027 */  beqz      $s0, .L80042388
/* 1D6EC 800422EC 00000000 */   nop
/* 1D6F0 800422F0 8E030000 */  lw        $v1, 0x0($s0)
/* 1D6F4 800422F4 30620008 */  andi      $v0, $v1, 0x8
/* 1D6F8 800422F8 10400004 */  beqz      $v0, .L8004230C
/* 1D6FC 800422FC 30620020 */   andi     $v0, $v1, 0x20
/* 1D700 80042300 8EC2008C */  lw        $v0, 0x8C($s6)
/* 1D704 80042304 16020020 */  bne       $s0, $v0, .L80042388
/* 1D708 80042308 30620020 */   andi     $v0, $v1, 0x20
.L8004230C:
/* 1D70C 8004230C 1440001E */  bnez      $v0, .L80042388
/* 1D710 80042310 00000000 */   nop
/* 1D714 80042314 8E040030 */  lw        $a0, 0x30($s0)
/* 1D718 80042318 1080000E */  beqz      $a0, .L80042354
/* 1D71C 8004231C 2405000A */   addiu    $a1, $zero, 0xA
/* 1D720 80042320 0000302D */  daddu     $a2, $zero, $zero
/* 1D724 80042324 0C0B0D74 */  jal       start_script_in_group
/* 1D728 80042328 00C0382D */   daddu    $a3, $a2, $zero
/* 1D72C 8004232C 0040202D */  daddu     $a0, $v0, $zero
/* 1D730 80042330 AE040048 */  sw        $a0, 0x48($s0)
/* 1D734 80042334 8C820144 */  lw        $v0, 0x144($a0)
/* 1D738 80042338 AE020060 */  sw        $v0, 0x60($s0)
/* 1D73C 8004233C AC900148 */  sw        $s0, 0x148($a0)
/* 1D740 80042340 86020008 */  lh        $v0, 0x8($s0)
/* 1D744 80042344 A0800004 */  sb        $zero, 0x4($a0)
/* 1D748 80042348 AC82014C */  sw        $v0, 0x14C($a0)
/* 1D74C 8004234C 080108E2 */  j         .L80042388
/* 1D750 80042350 AED2009C */   sw       $s2, 0x9C($s6)
.L80042354:
/* 1D754 80042354 3C048007 */  lui       $a0, %hi(EVS_NpcDefeat)
/* 1D758 80042358 24847E38 */  addiu     $a0, $a0, %lo(EVS_NpcDefeat)
/* 1D75C 8004235C 0000302D */  daddu     $a2, $zero, $zero
/* 1D760 80042360 0C0B0D74 */  jal       start_script_in_group
/* 1D764 80042364 00C0382D */   daddu    $a3, $a2, $zero
/* 1D768 80042368 0040202D */  daddu     $a0, $v0, $zero
/* 1D76C 8004236C AE040048 */  sw        $a0, 0x48($s0)
/* 1D770 80042370 8C820144 */  lw        $v0, 0x144($a0)
/* 1D774 80042374 AE020060 */  sw        $v0, 0x60($s0)
/* 1D778 80042378 AC900148 */  sw        $s0, 0x148($a0)
/* 1D77C 8004237C 86020008 */  lh        $v0, 0x8($s0)
/* 1D780 80042380 A0800004 */  sb        $zero, 0x4($a0)
/* 1D784 80042384 AC82014C */  sw        $v0, 0x14C($a0)
.L80042388:
/* 1D788 80042388 8E820000 */  lw        $v0, 0x0($s4)
/* 1D78C 8004238C 26730001 */  addiu     $s3, $s3, 0x1
/* 1D790 80042390 0262102A */  slt       $v0, $s3, $v0
/* 1D794 80042394 1440FFD3 */  bnez      $v0, .L800422E4
/* 1D798 80042398 26310004 */   addiu    $s1, $s1, 0x4
.L8004239C:
/* 1D79C 8004239C 8EC20000 */  lw        $v0, 0x0($s6)
/* 1D7A0 800423A0 30420001 */  andi      $v0, $v0, 0x1
/* 1D7A4 800423A4 14400010 */  bnez      $v0, .L800423E8
/* 1D7A8 800423A8 24020002 */   addiu    $v0, $zero, 0x2
/* 1D7AC 800423AC 3C02800A */  lui       $v0, %hi(D_8009A63C)
/* 1D7B0 800423B0 8042A63C */  lb        $v0, %lo(D_8009A63C)($v0)
/* 1D7B4 800423B4 1440000C */  bnez      $v0, .L800423E8
/* 1D7B8 800423B8 24020002 */   addiu    $v0, $zero, 0x2
/* 1D7BC 800423BC 8EC2009C */  lw        $v0, 0x9C($s6)
/* 1D7C0 800423C0 14400009 */  bnez      $v0, .L800423E8
/* 1D7C4 800423C4 24020002 */   addiu    $v0, $zero, 0x2
/* 1D7C8 800423C8 3C02800A */  lui       $v0, %hi(D_8009A670)
/* 1D7CC 800423CC 8042A670 */  lb        $v0, %lo(D_8009A670)($v0)
/* 1D7D0 800423D0 14400005 */  bnez      $v0, .L800423E8
/* 1D7D4 800423D4 24020002 */   addiu    $v0, $zero, 0x2
/* 1D7D8 800423D8 3C040001 */  lui       $a0, (0x10032 >> 16)
/* 1D7DC 800423DC 0C037FBF */  jal       suggest_player_anim_allow_backward
/* 1D7E0 800423E0 34840032 */   ori      $a0, $a0, (0x10032 & 0xFFFF)
/* 1D7E4 800423E4 24020002 */  addiu     $v0, $zero, 0x2
.L800423E8:
/* 1D7E8 800423E8 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D7EC 800423EC AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D7F0 800423F0 08010BD3 */  j         .L80042F4C
/* 1D7F4 800423F4 00000000 */   nop
.L800423F8:
/* 1D7F8 800423F8 8EC30090 */  lw        $v1, 0x90($s6)
/* 1D7FC 800423FC 1460025B */  bnez      $v1, .L80042D6C
/* 1D800 80042400 24020003 */   addiu    $v0, $zero, 0x3
/* 1D804 80042404 08010BD3 */  j         .L80042F4C
/* 1D808 80042408 AC820000 */   sw       $v0, 0x0($a0)
.L8004240C:
/* 1D80C 8004240C 8ED40088 */  lw        $s4, 0x88($s6)
/* 1D810 80042410 8E820000 */  lw        $v0, 0x0($s4)
/* 1D814 80042414 18400018 */  blez      $v0, .L80042478
/* 1D818 80042418 0240982D */   daddu    $s3, $s2, $zero
/* 1D81C 8004241C 0280882D */  daddu     $s1, $s4, $zero
.L80042420:
/* 1D820 80042420 8E300004 */  lw        $s0, 0x4($s1)
/* 1D824 80042424 1200000F */  beqz      $s0, .L80042464
/* 1D828 80042428 00000000 */   nop
/* 1D82C 8004242C 8E030000 */  lw        $v1, 0x0($s0)
/* 1D830 80042430 30620008 */  andi      $v0, $v1, 0x8
/* 1D834 80042434 10400004 */  beqz      $v0, .L80042448
/* 1D838 80042438 30620020 */   andi     $v0, $v1, 0x20
/* 1D83C 8004243C 8EC2008C */  lw        $v0, 0x8C($s6)
/* 1D840 80042440 16020008 */  bne       $s0, $v0, .L80042464
/* 1D844 80042444 30620020 */   andi     $v0, $v1, 0x20
.L80042448:
/* 1D848 80042448 14400006 */  bnez      $v0, .L80042464
/* 1D84C 8004244C 00000000 */   nop
/* 1D850 80042450 0C0B1059 */  jal       does_script_exist
/* 1D854 80042454 8E040060 */   lw       $a0, 0x60($s0)
/* 1D858 80042458 50400002 */  beql      $v0, $zero, .L80042464
/* 1D85C 8004245C AE000048 */   sw       $zero, 0x48($s0)
/* 1D860 80042460 24120001 */  addiu     $s2, $zero, 0x1
.L80042464:
/* 1D864 80042464 8E820000 */  lw        $v0, 0x0($s4)
/* 1D868 80042468 26730001 */  addiu     $s3, $s3, 0x1
/* 1D86C 8004246C 0262102A */  slt       $v0, $s3, $v0
/* 1D870 80042470 1440FFEB */  bnez      $v0, .L80042420
/* 1D874 80042474 26310004 */   addiu    $s1, $s1, 0x4
.L80042478:
/* 1D878 80042478 164002B4 */  bnez      $s2, .L80042F4C
/* 1D87C 8004247C 00000000 */   nop
/* 1D880 80042480 8EC20000 */  lw        $v0, 0x0($s6)
/* 1D884 80042484 30420001 */  andi      $v0, $v0, 0x1
/* 1D888 80042488 1440000B */  bnez      $v0, .L800424B8
/* 1D88C 8004248C 00000000 */   nop
/* 1D890 80042490 3C02800A */  lui       $v0, %hi(D_8009A63C)
/* 1D894 80042494 8042A63C */  lb        $v0, %lo(D_8009A63C)($v0)
/* 1D898 80042498 14400007 */  bnez      $v0, .L800424B8
/* 1D89C 8004249C 24020001 */   addiu    $v0, $zero, 0x1
/* 1D8A0 800424A0 8EC3009C */  lw        $v1, 0x9C($s6)
/* 1D8A4 800424A4 14620004 */  bne       $v1, $v0, .L800424B8
/* 1D8A8 800424A8 00000000 */   nop
/* 1D8AC 800424AC 3C040001 */  lui       $a0, (0x10032 >> 16)
/* 1D8B0 800424B0 0C037FBF */  jal       suggest_player_anim_allow_backward
/* 1D8B4 800424B4 34840032 */   ori      $a0, $a0, (0x10032 & 0xFFFF)
.L800424B8:
/* 1D8B8 800424B8 8ED40088 */  lw        $s4, 0x88($s6)
/* 1D8BC 800424BC 8E820000 */  lw        $v0, 0x0($s4)
/* 1D8C0 800424C0 1840001D */  blez      $v0, .L80042538
/* 1D8C4 800424C4 0000982D */   daddu    $s3, $zero, $zero
/* 1D8C8 800424C8 0280882D */  daddu     $s1, $s4, $zero
.L800424CC:
/* 1D8CC 800424CC 8E300004 */  lw        $s0, 0x4($s1)
/* 1D8D0 800424D0 12000014 */  beqz      $s0, .L80042524
/* 1D8D4 800424D4 00000000 */   nop
/* 1D8D8 800424D8 8E030000 */  lw        $v1, 0x0($s0)
/* 1D8DC 800424DC 30620004 */  andi      $v0, $v1, 0x4
/* 1D8E0 800424E0 14400010 */  bnez      $v0, .L80042524
/* 1D8E4 800424E4 30620008 */   andi     $v0, $v1, 0x8
/* 1D8E8 800424E8 10400004 */  beqz      $v0, .L800424FC
/* 1D8EC 800424EC 30620001 */   andi     $v0, $v1, 0x1
/* 1D8F0 800424F0 8EC2008C */  lw        $v0, 0x8C($s6)
/* 1D8F4 800424F4 1602000B */  bne       $s0, $v0, .L80042524
/* 1D8F8 800424F8 30620001 */   andi     $v0, $v1, 0x1
.L800424FC:
/* 1D8FC 800424FC 14400007 */  bnez      $v0, .L8004251C
/* 1D900 80042500 30620010 */   andi     $v0, $v1, 0x10
/* 1D904 80042504 14400005 */  bnez      $v0, .L8004251C
/* 1D908 80042508 00000000 */   nop
/* 1D90C 8004250C 86850048 */  lh        $a1, 0x48($s4)
/* 1D910 80042510 82C40020 */  lb        $a0, 0x20($s6)
/* 1D914 80042514 0C00FB90 */  jal       set_defeated
/* 1D918 80042518 00B32821 */   addu     $a1, $a1, $s3
.L8004251C:
/* 1D91C 8004251C 0C00F9EB */  jal       kill_enemy
/* 1D920 80042520 0200202D */   daddu    $a0, $s0, $zero
.L80042524:
/* 1D924 80042524 8E820000 */  lw        $v0, 0x0($s4)
/* 1D928 80042528 26730001 */  addiu     $s3, $s3, 0x1
/* 1D92C 8004252C 0262102A */  slt       $v0, $s3, $v0
/* 1D930 80042530 1440FFE6 */  bnez      $v0, .L800424CC
/* 1D934 80042534 26310004 */   addiu    $s1, $s1, 0x4
.L80042538:
/* 1D938 80042538 8EC20000 */  lw        $v0, 0x0($s6)
/* 1D93C 8004253C 30420001 */  andi      $v0, $v0, 0x1
/* 1D940 80042540 1440000B */  bnez      $v0, .L80042570
/* 1D944 80042544 AEC00094 */   sw       $zero, 0x94($s6)
/* 1D948 80042548 3C02800A */  lui       $v0, %hi(D_8009A63C)
/* 1D94C 8004254C 8042A63C */  lb        $v0, %lo(D_8009A63C)($v0)
/* 1D950 80042550 14400008 */  bnez      $v0, .L80042574
/* 1D954 80042554 24020004 */   addiu    $v0, $zero, 0x4
/* 1D958 80042558 8EC3009C */  lw        $v1, 0x9C($s6)
/* 1D95C 8004255C 24020001 */  addiu     $v0, $zero, 0x1
/* 1D960 80042560 14620004 */  bne       $v1, $v0, .L80042574
/* 1D964 80042564 24020004 */   addiu    $v0, $zero, 0x4
/* 1D968 80042568 2402001E */  addiu     $v0, $zero, 0x1E
/* 1D96C 8004256C AEC20094 */  sw        $v0, 0x94($s6)
.L80042570:
/* 1D970 80042570 24020004 */  addiu     $v0, $zero, 0x4
.L80042574:
/* 1D974 80042574 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1D978 80042578 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1D97C 8004257C 08010BD3 */  j         .L80042F4C
/* 1D980 80042580 00000000 */   nop
.L80042584:
/* 1D984 80042584 8EC20000 */  lw        $v0, 0x0($s6)
/* 1D988 80042588 30420002 */  andi      $v0, $v0, 0x2
/* 1D98C 8004258C 14400009 */  bnez      $v0, .L800425B4
/* 1D990 80042590 00000000 */   nop
/* 1D994 80042594 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* 1D998 80042598 8C63419C */  lw        $v1, %lo(gGameStatusPtr)($v1)
/* 1D99C 8004259C 80620040 */  lb        $v0, 0x40($v1)
/* 1D9A0 800425A0 54400004 */  bnel      $v0, $zero, .L800425B4
/* 1D9A4 800425A4 AEC00094 */   sw       $zero, 0x94($s6)
/* 1D9A8 800425A8 80620044 */  lb        $v0, 0x44($v1)
/* 1D9AC 800425AC 54400001 */  bnel      $v0, $zero, .L800425B4
/* 1D9B0 800425B0 AEC00094 */   sw       $zero, 0x94($s6)
.L800425B4:
/* 1D9B4 800425B4 8EC20094 */  lw        $v0, 0x94($s6)
/* 1D9B8 800425B8 10400003 */  beqz      $v0, .L800425C8
/* 1D9BC 800425BC 2442FFFF */   addiu    $v0, $v0, -0x1
/* 1D9C0 800425C0 08010BD3 */  j         .L80042F4C
/* 1D9C4 800425C4 AEC20094 */   sw       $v0, 0x94($s6)
.L800425C8:
/* 1D9C8 800425C8 82C2001C */  lb        $v0, 0x1C($s6)
/* 1D9CC 800425CC 18400024 */  blez      $v0, .L80042660
/* 1D9D0 800425D0 0000982D */   daddu    $s3, $zero, $zero
/* 1D9D4 800425D4 02C0A82D */  daddu     $s5, $s6, $zero
.L800425D8:
/* 1D9D8 800425D8 8EB40028 */  lw        $s4, 0x28($s5)
/* 1D9DC 800425DC 1280001B */  beqz      $s4, .L8004264C
/* 1D9E0 800425E0 00000000 */   nop
/* 1D9E4 800425E4 8E820000 */  lw        $v0, 0x0($s4)
/* 1D9E8 800425E8 18400018 */  blez      $v0, .L8004264C
/* 1D9EC 800425EC 0000882D */   daddu    $s1, $zero, $zero
/* 1D9F0 800425F0 0280902D */  daddu     $s2, $s4, $zero
.L800425F4:
/* 1D9F4 800425F4 8E500004 */  lw        $s0, 0x4($s2)
/* 1D9F8 800425F8 1200000F */  beqz      $s0, .L80042638
/* 1D9FC 800425FC 00000000 */   nop
/* 1DA00 80042600 8E020000 */  lw        $v0, 0x0($s0)
/* 1DA04 80042604 30420020 */  andi      $v0, $v0, 0x20
/* 1DA08 80042608 1440000B */  bnez      $v0, .L80042638
/* 1DA0C 8004260C 00000000 */   nop
/* 1DA10 80042610 8E02003C */  lw        $v0, 0x3C($s0)
/* 1DA14 80042614 10400003 */  beqz      $v0, .L80042624
/* 1DA18 80042618 00000000 */   nop
/* 1DA1C 8004261C 0C0B1123 */  jal       resume_all_script
/* 1DA20 80042620 8E040054 */   lw       $a0, 0x54($s0)
.L80042624:
/* 1DA24 80042624 8E020044 */  lw        $v0, 0x44($s0)
/* 1DA28 80042628 10400003 */  beqz      $v0, .L80042638
/* 1DA2C 8004262C 00000000 */   nop
/* 1DA30 80042630 0C0B1123 */  jal       resume_all_script
/* 1DA34 80042634 8E04005C */   lw       $a0, 0x5C($s0)
.L80042638:
/* 1DA38 80042638 8E820000 */  lw        $v0, 0x0($s4)
/* 1DA3C 8004263C 26310001 */  addiu     $s1, $s1, 0x1
/* 1DA40 80042640 0222102A */  slt       $v0, $s1, $v0
/* 1DA44 80042644 1440FFEB */  bnez      $v0, .L800425F4
/* 1DA48 80042648 26520004 */   addiu    $s2, $s2, 0x4
.L8004264C:
/* 1DA4C 8004264C 82C2001C */  lb        $v0, 0x1C($s6)
/* 1DA50 80042650 26730001 */  addiu     $s3, $s3, 0x1
/* 1DA54 80042654 0262102A */  slt       $v0, $s3, $v0
/* 1DA58 80042658 1440FFDF */  bnez      $v0, .L800425D8
/* 1DA5C 8004265C 26B50004 */   addiu    $s5, $s5, 0x4
.L80042660:
/* 1DA60 80042660 2402000F */  addiu     $v0, $zero, 0xF
/* 1DA64 80042664 0C038069 */  jal       enable_player_input
/* 1DA68 80042668 A2C2000A */   sb       $v0, 0xA($s6)
/* 1DA6C 8004266C 0C03BD80 */  jal       partner_enable_input
/* 1DA70 80042670 00000000 */   nop
/* 1DA74 80042674 3C02800A */  lui       $v0, %hi(D_8009A63C)
/* 1DA78 80042678 8042A63C */  lb        $v0, %lo(D_8009A63C)($v0)
/* 1DA7C 8004267C 14400226 */  bnez      $v0, .L80042F18
/* 1DA80 80042680 3C040001 */   lui      $a0, (0x10002 >> 16)
/* 1DA84 80042684 0C037FBF */  jal       suggest_player_anim_allow_backward
/* 1DA88 80042688 34840002 */   ori      $a0, $a0, (0x10002 & 0xFFFF)
/* 1DA8C 8004268C 08010BC6 */  j         .L80042F18
/* 1DA90 80042690 00000000 */   nop
.L80042694:
/* 1DA94 80042694 8ED40088 */  lw        $s4, 0x88($s6)
/* 1DA98 80042698 8E820000 */  lw        $v0, 0x0($s4)
/* 1DA9C 8004269C 18400024 */  blez      $v0, .L80042730
/* 1DAA0 800426A0 0000982D */   daddu    $s3, $zero, $zero
/* 1DAA4 800426A4 0280882D */  daddu     $s1, $s4, $zero
.L800426A8:
/* 1DAA8 800426A8 8E300004 */  lw        $s0, 0x4($s1)
/* 1DAAC 800426AC 1200001B */  beqz      $s0, .L8004271C
/* 1DAB0 800426B0 00000000 */   nop
/* 1DAB4 800426B4 8E030000 */  lw        $v1, 0x0($s0)
/* 1DAB8 800426B8 30620008 */  andi      $v0, $v1, 0x8
/* 1DABC 800426BC 10400004 */  beqz      $v0, .L800426D0
/* 1DAC0 800426C0 30620020 */   andi     $v0, $v1, 0x20
/* 1DAC4 800426C4 8EC2008C */  lw        $v0, 0x8C($s6)
/* 1DAC8 800426C8 16020014 */  bne       $s0, $v0, .L8004271C
/* 1DACC 800426CC 30620020 */   andi     $v0, $v1, 0x20
.L800426D0:
/* 1DAD0 800426D0 14400012 */  bnez      $v0, .L8004271C
/* 1DAD4 800426D4 00000000 */   nop
/* 1DAD8 800426D8 8E040030 */  lw        $a0, 0x30($s0)
/* 1DADC 800426DC 1080000F */  beqz      $a0, .L8004271C
/* 1DAE0 800426E0 2405000A */   addiu    $a1, $zero, 0xA
/* 1DAE4 800426E4 0C0B0CF8 */  jal       start_script
/* 1DAE8 800426E8 0000302D */   daddu    $a2, $zero, $zero
/* 1DAEC 800426EC 0040202D */  daddu     $a0, $v0, $zero
/* 1DAF0 800426F0 8E0200B0 */  lw        $v0, 0xB0($s0)
/* 1DAF4 800426F4 AE040048 */  sw        $a0, 0x48($s0)
/* 1DAF8 800426F8 8C830144 */  lw        $v1, 0x144($a0)
/* 1DAFC 800426FC 34420001 */  ori       $v0, $v0, 0x1
/* 1DB00 80042700 AE030060 */  sw        $v1, 0x60($s0)
/* 1DB04 80042704 AE0200B0 */  sw        $v0, 0xB0($s0)
/* 1DB08 80042708 AC900148 */  sw        $s0, 0x148($a0)
/* 1DB0C 8004270C 86020008 */  lh        $v0, 0x8($s0)
/* 1DB10 80042710 AC82014C */  sw        $v0, 0x14C($a0)
/* 1DB14 80042714 92020006 */  lbu       $v0, 0x6($s0)
/* 1DB18 80042718 A0820004 */  sb        $v0, 0x4($a0)
.L8004271C:
/* 1DB1C 8004271C 8E820000 */  lw        $v0, 0x0($s4)
/* 1DB20 80042720 26730001 */  addiu     $s3, $s3, 0x1
/* 1DB24 80042724 0262102A */  slt       $v0, $s3, $v0
/* 1DB28 80042728 1440FFDF */  bnez      $v0, .L800426A8
/* 1DB2C 8004272C 26310004 */   addiu    $s1, $s1, 0x4
.L80042730:
/* 1DB30 80042730 24020065 */  addiu     $v0, $zero, 0x65
/* 1DB34 80042734 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1DB38 80042738 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1DB3C 8004273C 08010BD3 */  j         .L80042F4C
/* 1DB40 80042740 00000000 */   nop
.L80042744:
/* 1DB44 80042744 8EC30090 */  lw        $v1, 0x90($s6)
/* 1DB48 80042748 14600188 */  bnez      $v1, .L80042D6C
/* 1DB4C 8004274C 00000000 */   nop
/* 1DB50 80042750 08010BD3 */  j         .L80042F4C
/* 1DB54 80042754 AC850000 */   sw       $a1, 0x0($a0)
.L80042758:
/* 1DB58 80042758 8ED40088 */  lw        $s4, 0x88($s6)
/* 1DB5C 8004275C 0000902D */  daddu     $s2, $zero, $zero
/* 1DB60 80042760 8E820000 */  lw        $v0, 0x0($s4)
/* 1DB64 80042764 18400013 */  blez      $v0, .L800427B4
/* 1DB68 80042768 0240982D */   daddu    $s3, $s2, $zero
/* 1DB6C 8004276C 0280882D */  daddu     $s1, $s4, $zero
.L80042770:
/* 1DB70 80042770 8E300004 */  lw        $s0, 0x4($s1)
/* 1DB74 80042774 1200000A */  beqz      $s0, .L800427A0
/* 1DB78 80042778 00000000 */   nop
/* 1DB7C 8004277C 8E020000 */  lw        $v0, 0x0($s0)
/* 1DB80 80042780 30420020 */  andi      $v0, $v0, 0x20
/* 1DB84 80042784 14400006 */  bnez      $v0, .L800427A0
/* 1DB88 80042788 00000000 */   nop
/* 1DB8C 8004278C 0C0B1059 */  jal       does_script_exist
/* 1DB90 80042790 8E040060 */   lw       $a0, 0x60($s0)
/* 1DB94 80042794 50400002 */  beql      $v0, $zero, .L800427A0
/* 1DB98 80042798 AE000048 */   sw       $zero, 0x48($s0)
/* 1DB9C 8004279C 24120001 */  addiu     $s2, $zero, 0x1
.L800427A0:
/* 1DBA0 800427A0 8E820000 */  lw        $v0, 0x0($s4)
/* 1DBA4 800427A4 26730001 */  addiu     $s3, $s3, 0x1
/* 1DBA8 800427A8 0262102A */  slt       $v0, $s3, $v0
/* 1DBAC 800427AC 1440FFF0 */  bnez      $v0, .L80042770
/* 1DBB0 800427B0 26310004 */   addiu    $s1, $s1, 0x4
.L800427B4:
/* 1DBB4 800427B4 164001E5 */  bnez      $s2, .L80042F4C
/* 1DBB8 800427B8 00000000 */   nop
/* 1DBBC 800427BC 82C2001C */  lb        $v0, 0x1C($s6)
/* 1DBC0 800427C0 18400024 */  blez      $v0, .L80042854
/* 1DBC4 800427C4 0000982D */   daddu    $s3, $zero, $zero
/* 1DBC8 800427C8 02C0A82D */  daddu     $s5, $s6, $zero
.L800427CC:
/* 1DBCC 800427CC 8EB40028 */  lw        $s4, 0x28($s5)
/* 1DBD0 800427D0 1280001B */  beqz      $s4, .L80042840
/* 1DBD4 800427D4 00000000 */   nop
/* 1DBD8 800427D8 8E820000 */  lw        $v0, 0x0($s4)
/* 1DBDC 800427DC 18400018 */  blez      $v0, .L80042840
/* 1DBE0 800427E0 0000882D */   daddu    $s1, $zero, $zero
/* 1DBE4 800427E4 0280902D */  daddu     $s2, $s4, $zero
.L800427E8:
/* 1DBE8 800427E8 8E500004 */  lw        $s0, 0x4($s2)
/* 1DBEC 800427EC 1200000F */  beqz      $s0, .L8004282C
/* 1DBF0 800427F0 00000000 */   nop
/* 1DBF4 800427F4 8E020000 */  lw        $v0, 0x0($s0)
/* 1DBF8 800427F8 30420020 */  andi      $v0, $v0, 0x20
/* 1DBFC 800427FC 1440000B */  bnez      $v0, .L8004282C
/* 1DC00 80042800 00000000 */   nop
/* 1DC04 80042804 8E02003C */  lw        $v0, 0x3C($s0)
/* 1DC08 80042808 10400003 */  beqz      $v0, .L80042818
/* 1DC0C 8004280C 00000000 */   nop
/* 1DC10 80042810 0C0B1123 */  jal       resume_all_script
/* 1DC14 80042814 8E040054 */   lw       $a0, 0x54($s0)
.L80042818:
/* 1DC18 80042818 8E020044 */  lw        $v0, 0x44($s0)
/* 1DC1C 8004281C 10400003 */  beqz      $v0, .L8004282C
/* 1DC20 80042820 00000000 */   nop
/* 1DC24 80042824 0C0B1123 */  jal       resume_all_script
/* 1DC28 80042828 8E04005C */   lw       $a0, 0x5C($s0)
.L8004282C:
/* 1DC2C 8004282C 8E820000 */  lw        $v0, 0x0($s4)
/* 1DC30 80042830 26310001 */  addiu     $s1, $s1, 0x1
/* 1DC34 80042834 0222102A */  slt       $v0, $s1, $v0
/* 1DC38 80042838 1440FFEB */  bnez      $v0, .L800427E8
/* 1DC3C 8004283C 26520004 */   addiu    $s2, $s2, 0x4
.L80042840:
/* 1DC40 80042840 82C2001C */  lb        $v0, 0x1C($s6)
/* 1DC44 80042844 26730001 */  addiu     $s3, $s3, 0x1
/* 1DC48 80042848 0262102A */  slt       $v0, $s3, $v0
/* 1DC4C 8004284C 1440FFDF */  bnez      $v0, .L800427CC
/* 1DC50 80042850 26B50004 */   addiu    $s5, $s5, 0x4
.L80042854:
/* 1DC54 80042854 8ED0008C */  lw        $s0, 0x8C($s6)
/* 1DC58 80042858 3C030004 */  lui       $v1, (0x40000 >> 16)
/* 1DC5C 8004285C 8E020000 */  lw        $v0, 0x0($s0)
/* 1DC60 80042860 8ED40088 */  lw        $s4, 0x88($s6)
/* 1DC64 80042864 00431024 */  and       $v0, $v0, $v1
/* 1DC68 80042868 1440001A */  bnez      $v0, .L800428D4
/* 1DC6C 8004286C 2402002D */   addiu    $v0, $zero, 0x2D
/* 1DC70 80042870 A20200B4 */  sb        $v0, 0xB4($s0)
/* 1DC74 80042874 2402002D */  addiu     $v0, $zero, 0x2D
/* 1DC78 80042878 A6E20010 */  sh        $v0, 0x10($s7)
/* 1DC7C 8004287C 8E820000 */  lw        $v0, 0x0($s4)
/* 1DC80 80042880 18400014 */  blez      $v0, .L800428D4
/* 1DC84 80042884 0000882D */   daddu    $s1, $zero, $zero
/* 1DC88 80042888 2406002D */  addiu     $a2, $zero, 0x2D
/* 1DC8C 8004288C 2405002D */  addiu     $a1, $zero, 0x2D
/* 1DC90 80042890 0280202D */  daddu     $a0, $s4, $zero
.L80042894:
/* 1DC94 80042894 8C900004 */  lw        $s0, 0x4($a0)
/* 1DC98 80042898 12000009 */  beqz      $s0, .L800428C0
/* 1DC9C 8004289C 00000000 */   nop
/* 1DCA0 800428A0 8E030000 */  lw        $v1, 0x0($s0)
/* 1DCA4 800428A4 30620020 */  andi      $v0, $v1, 0x20
/* 1DCA8 800428A8 14400005 */  bnez      $v0, .L800428C0
/* 1DCAC 800428AC 30620008 */   andi     $v0, $v1, 0x8
/* 1DCB0 800428B0 14400003 */  bnez      $v0, .L800428C0
/* 1DCB4 800428B4 00000000 */   nop
/* 1DCB8 800428B8 A20600B4 */  sb        $a2, 0xB4($s0)
/* 1DCBC 800428BC A6E50010 */  sh        $a1, 0x10($s7)
.L800428C0:
/* 1DCC0 800428C0 8E820000 */  lw        $v0, 0x0($s4)
/* 1DCC4 800428C4 26310001 */  addiu     $s1, $s1, 0x1
/* 1DCC8 800428C8 0222102A */  slt       $v0, $s1, $v0
/* 1DCCC 800428CC 1440FFF1 */  bnez      $v0, .L80042894
/* 1DCD0 800428D0 24840004 */   addiu    $a0, $a0, 0x4
.L800428D4:
/* 1DCD4 800428D4 8EC20000 */  lw        $v0, 0x0($s6)
/* 1DCD8 800428D8 8ED0008C */  lw        $s0, 0x8C($s6)
/* 1DCDC 800428DC 30420004 */  andi      $v0, $v0, 0x4
/* 1DCE0 800428E0 14400010 */  bnez      $v0, .L80042924
/* 1DCE4 800428E4 2402002D */   addiu    $v0, $zero, 0x2D
/* 1DCE8 800428E8 3C048007 */  lui       $a0, %hi(D_80077E9C)
/* 1DCEC 800428EC 24847E9C */  addiu     $a0, $a0, %lo(D_80077E9C)
/* 1DCF0 800428F0 2405000A */  addiu     $a1, $zero, 0xA
/* 1DCF4 800428F4 0C0B0CF8 */  jal       start_script
/* 1DCF8 800428F8 0000302D */   daddu    $a2, $zero, $zero
/* 1DCFC 800428FC 0040202D */  daddu     $a0, $v0, $zero
/* 1DD00 80042900 AE040048 */  sw        $a0, 0x48($s0)
/* 1DD04 80042904 8C820144 */  lw        $v0, 0x144($a0)
/* 1DD08 80042908 AE020060 */  sw        $v0, 0x60($s0)
/* 1DD0C 8004290C AC900148 */  sw        $s0, 0x148($a0)
/* 1DD10 80042910 86020008 */  lh        $v0, 0x8($s0)
/* 1DD14 80042914 AC82014C */  sw        $v0, 0x14C($a0)
/* 1DD18 80042918 92020006 */  lbu       $v0, 0x6($s0)
/* 1DD1C 8004291C A0820004 */  sb        $v0, 0x4($a0)
/* 1DD20 80042920 2402002D */  addiu     $v0, $zero, 0x2D
.L80042924:
/* 1DD24 80042924 A2C2000A */  sb        $v0, 0xA($s6)
/* 1DD28 80042928 2402002D */  addiu     $v0, $zero, 0x2D
/* 1DD2C 8004292C 0C038069 */  jal       enable_player_input
/* 1DD30 80042930 A6E20010 */   sh       $v0, 0x10($s7)
/* 1DD34 80042934 0C03BD80 */  jal       partner_enable_input
/* 1DD38 80042938 00000000 */   nop
/* 1DD3C 8004293C 3C05BF80 */  lui       $a1, (0xBF800000 >> 16)
/* 1DD40 80042940 0C04DF62 */  jal       set_screen_overlay_params_front
/* 1DD44 80042944 240400FF */   addiu    $a0, $zero, 0xFF
/* 1DD48 80042948 3C02800A */  lui       $v0, %hi(D_8009A63C)
/* 1DD4C 8004294C 8042A63C */  lb        $v0, %lo(D_8009A63C)($v0)
/* 1DD50 80042950 54400003 */  bnel      $v0, $zero, .L80042960
/* 1DD54 80042954 AEC00094 */   sw       $zero, 0x94($s6)
/* 1DD58 80042958 2402000F */  addiu     $v0, $zero, 0xF
/* 1DD5C 8004295C AEC20094 */  sw        $v0, 0x94($s6)
.L80042960:
/* 1DD60 80042960 24020067 */  addiu     $v0, $zero, 0x67
/* 1DD64 80042964 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1DD68 80042968 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1DD6C 8004296C 08010BD3 */  j         .L80042F4C
/* 1DD70 80042970 00000000 */   nop
.L80042974:
/* 1DD74 80042974 8EC20094 */  lw        $v0, 0x94($s6)
/* 1DD78 80042978 1040000D */  beqz      $v0, .L800429B0
/* 1DD7C 8004297C 2442FFFF */   addiu    $v0, $v0, -0x1
/* 1DD80 80042980 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* 1DD84 80042984 8C63419C */  lw        $v1, %lo(gGameStatusPtr)($v1)
/* 1DD88 80042988 AEC20094 */  sw        $v0, 0x94($s6)
/* 1DD8C 8004298C 8C620000 */  lw        $v0, 0x0($v1)
/* 1DD90 80042990 14400007 */  bnez      $v0, .L800429B0
/* 1DD94 80042994 00000000 */   nop
/* 1DD98 80042998 80620040 */  lb        $v0, 0x40($v1)
/* 1DD9C 8004299C 14400004 */  bnez      $v0, .L800429B0
/* 1DDA0 800429A0 00000000 */   nop
/* 1DDA4 800429A4 80620044 */  lb        $v0, 0x44($v1)
/* 1DDA8 800429A8 10400168 */  beqz      $v0, .L80042F4C
/* 1DDAC 800429AC 00000000 */   nop
.L800429B0:
/* 1DDB0 800429B0 3C02800A */  lui       $v0, %hi(D_8009A63C)
/* 1DDB4 800429B4 8042A63C */  lb        $v0, %lo(D_8009A63C)($v0)
/* 1DDB8 800429B8 1440015A */  bnez      $v0, .L80042F24
/* 1DDBC 800429BC 3C020005 */   lui      $v0, (0x50000 >> 16)
/* 1DDC0 800429C0 8EE300B8 */  lw        $v1, 0xB8($s7)
/* 1DDC4 800429C4 14620157 */  bne       $v1, $v0, .L80042F24
/* 1DDC8 800429C8 3C040001 */   lui      $a0, (0x10002 >> 16)
/* 1DDCC 800429CC 0C037FBF */  jal       suggest_player_anim_allow_backward
/* 1DDD0 800429D0 34840002 */   ori      $a0, $a0, (0x10002 & 0xFFFF)
/* 1DDD4 800429D4 08010BC9 */  j         .L80042F24
/* 1DDD8 800429D8 00000000 */   nop
.L800429DC:
/* 1DDDC 800429DC 3C040008 */  lui       $a0, (0x80009 >> 16)
/* 1DDE0 800429E0 0C037FBF */  jal       suggest_player_anim_allow_backward
/* 1DDE4 800429E4 34840009 */   ori      $a0, $a0, (0x80009 & 0xFFFF)
/* 1DDE8 800429E8 8ED40088 */  lw        $s4, 0x88($s6)
/* 1DDEC 800429EC 8E820000 */  lw        $v0, 0x0($s4)
/* 1DDF0 800429F0 18400021 */  blez      $v0, .L80042A78
/* 1DDF4 800429F4 0000982D */   daddu    $s3, $zero, $zero
/* 1DDF8 800429F8 0280882D */  daddu     $s1, $s4, $zero
.L800429FC:
/* 1DDFC 800429FC 8E300004 */  lw        $s0, 0x4($s1)
/* 1DE00 80042A00 12000018 */  beqz      $s0, .L80042A64
/* 1DE04 80042A04 00000000 */   nop
/* 1DE08 80042A08 8E030000 */  lw        $v1, 0x0($s0)
/* 1DE0C 80042A0C 30620008 */  andi      $v0, $v1, 0x8
/* 1DE10 80042A10 10400004 */  beqz      $v0, .L80042A24
/* 1DE14 80042A14 30620020 */   andi     $v0, $v1, 0x20
/* 1DE18 80042A18 8EC2008C */  lw        $v0, 0x8C($s6)
/* 1DE1C 80042A1C 16020011 */  bne       $s0, $v0, .L80042A64
/* 1DE20 80042A20 30620020 */   andi     $v0, $v1, 0x20
.L80042A24:
/* 1DE24 80042A24 1440000F */  bnez      $v0, .L80042A64
/* 1DE28 80042A28 00000000 */   nop
/* 1DE2C 80042A2C 8E040030 */  lw        $a0, 0x30($s0)
/* 1DE30 80042A30 1080000C */  beqz      $a0, .L80042A64
/* 1DE34 80042A34 2405000A */   addiu    $a1, $zero, 0xA
/* 1DE38 80042A38 0C0B0CF8 */  jal       start_script
/* 1DE3C 80042A3C 0000302D */   daddu    $a2, $zero, $zero
/* 1DE40 80042A40 0040202D */  daddu     $a0, $v0, $zero
/* 1DE44 80042A44 AE040048 */  sw        $a0, 0x48($s0)
/* 1DE48 80042A48 8C820144 */  lw        $v0, 0x144($a0)
/* 1DE4C 80042A4C AE020060 */  sw        $v0, 0x60($s0)
/* 1DE50 80042A50 AC900148 */  sw        $s0, 0x148($a0)
/* 1DE54 80042A54 86020008 */  lh        $v0, 0x8($s0)
/* 1DE58 80042A58 AC82014C */  sw        $v0, 0x14C($a0)
/* 1DE5C 80042A5C 92020006 */  lbu       $v0, 0x6($s0)
/* 1DE60 80042A60 A0820004 */  sb        $v0, 0x4($a0)
.L80042A64:
/* 1DE64 80042A64 8E820000 */  lw        $v0, 0x0($s4)
/* 1DE68 80042A68 26730001 */  addiu     $s3, $s3, 0x1
/* 1DE6C 80042A6C 0262102A */  slt       $v0, $s3, $v0
/* 1DE70 80042A70 1440FFE2 */  bnez      $v0, .L800429FC
/* 1DE74 80042A74 26310004 */   addiu    $s1, $s1, 0x4
.L80042A78:
/* 1DE78 80042A78 240200C9 */  addiu     $v0, $zero, 0xC9
/* 1DE7C 80042A7C 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1DE80 80042A80 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1DE84 80042A84 08010BD3 */  j         .L80042F4C
/* 1DE88 80042A88 00000000 */   nop
.L80042A8C:
/* 1DE8C 80042A8C 8EC30090 */  lw        $v1, 0x90($s6)
/* 1DE90 80042A90 146000B6 */  bnez      $v1, .L80042D6C
/* 1DE94 80042A94 00000000 */   nop
/* 1DE98 80042A98 08010BD3 */  j         .L80042F4C
/* 1DE9C 80042A9C AC820000 */   sw       $v0, 0x0($a0)
.L80042AA0:
/* 1DEA0 80042AA0 8ED40088 */  lw        $s4, 0x88($s6)
/* 1DEA4 80042AA4 8E820000 */  lw        $v0, 0x0($s4)
/* 1DEA8 80042AA8 18400013 */  blez      $v0, .L80042AF8
/* 1DEAC 80042AAC 0240982D */   daddu    $s3, $s2, $zero
/* 1DEB0 80042AB0 0280882D */  daddu     $s1, $s4, $zero
.L80042AB4:
/* 1DEB4 80042AB4 8E300004 */  lw        $s0, 0x4($s1)
/* 1DEB8 80042AB8 1200000A */  beqz      $s0, .L80042AE4
/* 1DEBC 80042ABC 00000000 */   nop
/* 1DEC0 80042AC0 8E020000 */  lw        $v0, 0x0($s0)
/* 1DEC4 80042AC4 30420020 */  andi      $v0, $v0, 0x20
/* 1DEC8 80042AC8 14400006 */  bnez      $v0, .L80042AE4
/* 1DECC 80042ACC 00000000 */   nop
/* 1DED0 80042AD0 0C0B1059 */  jal       does_script_exist
/* 1DED4 80042AD4 8E040060 */   lw       $a0, 0x60($s0)
/* 1DED8 80042AD8 50400002 */  beql      $v0, $zero, .L80042AE4
/* 1DEDC 80042ADC AE000048 */   sw       $zero, 0x48($s0)
/* 1DEE0 80042AE0 24120001 */  addiu     $s2, $zero, 0x1
.L80042AE4:
/* 1DEE4 80042AE4 8E820000 */  lw        $v0, 0x0($s4)
/* 1DEE8 80042AE8 26730001 */  addiu     $s3, $s3, 0x1
/* 1DEEC 80042AEC 0262102A */  slt       $v0, $s3, $v0
/* 1DEF0 80042AF0 1440FFF0 */  bnez      $v0, .L80042AB4
glabel func_80042AF4
/* 1DEF4 80042AF4 26310004 */   addiu    $s1, $s1, 0x4
.L80042AF8:
/* 1DEF8 80042AF8 16400114 */  bnez      $s2, .L80042F4C
/* 1DEFC 80042AFC 00000000 */   nop
/* 1DF00 80042B00 82C2001C */  lb        $v0, 0x1C($s6)
/* 1DF04 80042B04 18400024 */  blez      $v0, .L80042B98
/* 1DF08 80042B08 0000982D */   daddu    $s3, $zero, $zero
/* 1DF0C 80042B0C 02C0A82D */  daddu     $s5, $s6, $zero
.L80042B10:
/* 1DF10 80042B10 8EB40028 */  lw        $s4, 0x28($s5)
/* 1DF14 80042B14 1280001B */  beqz      $s4, .L80042B84
/* 1DF18 80042B18 00000000 */   nop
/* 1DF1C 80042B1C 8E820000 */  lw        $v0, 0x0($s4)
/* 1DF20 80042B20 18400018 */  blez      $v0, .L80042B84
/* 1DF24 80042B24 0000882D */   daddu    $s1, $zero, $zero
/* 1DF28 80042B28 0280902D */  daddu     $s2, $s4, $zero
.L80042B2C:
/* 1DF2C 80042B2C 8E500004 */  lw        $s0, 0x4($s2)
/* 1DF30 80042B30 1200000F */  beqz      $s0, .L80042B70
/* 1DF34 80042B34 00000000 */   nop
/* 1DF38 80042B38 8E020000 */  lw        $v0, 0x0($s0)
/* 1DF3C 80042B3C 30420020 */  andi      $v0, $v0, 0x20
/* 1DF40 80042B40 1440000B */  bnez      $v0, .L80042B70
/* 1DF44 80042B44 00000000 */   nop
/* 1DF48 80042B48 8E02003C */  lw        $v0, 0x3C($s0)
/* 1DF4C 80042B4C 10400003 */  beqz      $v0, .L80042B5C
/* 1DF50 80042B50 00000000 */   nop
/* 1DF54 80042B54 0C0B1123 */  jal       resume_all_script
/* 1DF58 80042B58 8E040054 */   lw       $a0, 0x54($s0)
.L80042B5C:
/* 1DF5C 80042B5C 8E020044 */  lw        $v0, 0x44($s0)
/* 1DF60 80042B60 10400003 */  beqz      $v0, .L80042B70
/* 1DF64 80042B64 00000000 */   nop
/* 1DF68 80042B68 0C0B1123 */  jal       resume_all_script
/* 1DF6C 80042B6C 8E04005C */   lw       $a0, 0x5C($s0)
.L80042B70:
/* 1DF70 80042B70 8E820000 */  lw        $v0, 0x0($s4)
/* 1DF74 80042B74 26310001 */  addiu     $s1, $s1, 0x1
/* 1DF78 80042B78 0222102A */  slt       $v0, $s1, $v0
/* 1DF7C 80042B7C 1440FFEB */  bnez      $v0, .L80042B2C
/* 1DF80 80042B80 26520004 */   addiu    $s2, $s2, 0x4
.L80042B84:
/* 1DF84 80042B84 82C2001C */  lb        $v0, 0x1C($s6)
/* 1DF88 80042B88 26730001 */  addiu     $s3, $s3, 0x1
/* 1DF8C 80042B8C 0262102A */  slt       $v0, $s3, $v0
/* 1DF90 80042B90 1440FFDF */  bnez      $v0, .L80042B10
/* 1DF94 80042B94 26B50004 */   addiu    $s5, $s5, 0x4
.L80042B98:
/* 1DF98 80042B98 0C038069 */  jal       enable_player_input
/* 1DF9C 80042B9C 00000000 */   nop
/* 1DFA0 80042BA0 0C03BD80 */  jal       partner_enable_input
/* 1DFA4 80042BA4 00000000 */   nop
/* 1DFA8 80042BA8 3C05BF80 */  lui       $a1, (0xBF800000 >> 16)
/* 1DFAC 80042BAC 0C04DF62 */  jal       set_screen_overlay_params_front
/* 1DFB0 80042BB0 240400FF */   addiu    $a0, $zero, 0xFF
/* 1DFB4 80042BB4 2402000F */  addiu     $v0, $zero, 0xF
/* 1DFB8 80042BB8 AEC20094 */  sw        $v0, 0x94($s6)
/* 1DFBC 80042BBC 240200CB */  addiu     $v0, $zero, 0xCB
/* 1DFC0 80042BC0 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1DFC4 80042BC4 AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1DFC8 80042BC8 08010BD3 */  j         .L80042F4C
/* 1DFCC 80042BCC 00000000 */   nop
.L80042BD0:
/* 1DFD0 80042BD0 8EC20094 */  lw        $v0, 0x94($s6)
/* 1DFD4 80042BD4 104000D3 */  beqz      $v0, .L80042F24
/* 1DFD8 80042BD8 2442FFFF */   addiu    $v0, $v0, -0x1
/* 1DFDC 80042BDC 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* 1DFE0 80042BE0 8C63419C */  lw        $v1, %lo(gGameStatusPtr)($v1)
/* 1DFE4 80042BE4 AEC20094 */  sw        $v0, 0x94($s6)
/* 1DFE8 80042BE8 8C620000 */  lw        $v0, 0x0($v1)
/* 1DFEC 80042BEC 144000CD */  bnez      $v0, .L80042F24
/* 1DFF0 80042BF0 00000000 */   nop
/* 1DFF4 80042BF4 80620040 */  lb        $v0, 0x40($v1)
/* 1DFF8 80042BF8 144000CA */  bnez      $v0, .L80042F24
/* 1DFFC 80042BFC 00000000 */   nop
/* 1E000 80042C00 80620044 */  lb        $v0, 0x44($v1)
/* 1E004 80042C04 104000D1 */  beqz      $v0, .L80042F4C
/* 1E008 80042C08 00000000 */   nop
/* 1E00C 80042C0C 08010BC9 */  j         .L80042F24
/* 1E010 80042C10 00000000 */   nop
.L80042C14:
/* 1E014 80042C14 82C2001C */  lb        $v0, 0x1C($s6)
/* 1E018 80042C18 184000BB */  blez      $v0, .L80042F08
/* 1E01C 80042C1C 0000982D */   daddu    $s3, $zero, $zero
/* 1E020 80042C20 02C0A82D */  daddu     $s5, $s6, $zero
.L80042C24:
/* 1E024 80042C24 8EB40028 */  lw        $s4, 0x28($s5)
/* 1E028 80042C28 1280001B */  beqz      $s4, .L80042C98
/* 1E02C 80042C2C 00000000 */   nop
/* 1E030 80042C30 8E820000 */  lw        $v0, 0x0($s4)
/* 1E034 80042C34 18400018 */  blez      $v0, .L80042C98
/* 1E038 80042C38 0000882D */   daddu    $s1, $zero, $zero
/* 1E03C 80042C3C 0280902D */  daddu     $s2, $s4, $zero
.L80042C40:
/* 1E040 80042C40 8E500004 */  lw        $s0, 0x4($s2)
/* 1E044 80042C44 1200000F */  beqz      $s0, .L80042C84
/* 1E048 80042C48 00000000 */   nop
/* 1E04C 80042C4C 8E020000 */  lw        $v0, 0x0($s0)
/* 1E050 80042C50 30420020 */  andi      $v0, $v0, 0x20
/* 1E054 80042C54 1440000B */  bnez      $v0, .L80042C84
/* 1E058 80042C58 00000000 */   nop
/* 1E05C 80042C5C 8E02003C */  lw        $v0, 0x3C($s0)
/* 1E060 80042C60 10400003 */  beqz      $v0, .L80042C70
/* 1E064 80042C64 00000000 */   nop
/* 1E068 80042C68 0C0B1123 */  jal       resume_all_script
/* 1E06C 80042C6C 8E040054 */   lw       $a0, 0x54($s0)
.L80042C70:
/* 1E070 80042C70 8E020044 */  lw        $v0, 0x44($s0)
/* 1E074 80042C74 10400003 */  beqz      $v0, .L80042C84
/* 1E078 80042C78 00000000 */   nop
/* 1E07C 80042C7C 0C0B1123 */  jal       resume_all_script
/* 1E080 80042C80 8E04005C */   lw       $a0, 0x5C($s0)
.L80042C84:
/* 1E084 80042C84 8E820000 */  lw        $v0, 0x0($s4)
/* 1E088 80042C88 26310001 */  addiu     $s1, $s1, 0x1
/* 1E08C 80042C8C 0222102A */  slt       $v0, $s1, $v0
/* 1E090 80042C90 1440FFEB */  bnez      $v0, .L80042C40
/* 1E094 80042C94 26520004 */   addiu    $s2, $s2, 0x4
.L80042C98:
/* 1E098 80042C98 82C2001C */  lb        $v0, 0x1C($s6)
/* 1E09C 80042C9C 26730001 */  addiu     $s3, $s3, 0x1
/* 1E0A0 80042CA0 0262102A */  slt       $v0, $s3, $v0
/* 1E0A4 80042CA4 1440FFDF */  bnez      $v0, .L80042C24
/* 1E0A8 80042CA8 26B50004 */   addiu    $s5, $s5, 0x4
/* 1E0AC 80042CAC 08010BC2 */  j         .L80042F08
/* 1E0B0 80042CB0 00000000 */   nop
.L80042CB4:
/* 1E0B4 80042CB4 8ED40088 */  lw        $s4, 0x88($s6)
/* 1E0B8 80042CB8 8E820000 */  lw        $v0, 0x0($s4)
/* 1E0BC 80042CBC 18400021 */  blez      $v0, .L80042D44
/* 1E0C0 80042CC0 0000982D */   daddu    $s3, $zero, $zero
/* 1E0C4 80042CC4 0280882D */  daddu     $s1, $s4, $zero
.L80042CC8:
/* 1E0C8 80042CC8 8E300004 */  lw        $s0, 0x4($s1)
/* 1E0CC 80042CCC 12000018 */  beqz      $s0, .L80042D30
/* 1E0D0 80042CD0 00000000 */   nop
/* 1E0D4 80042CD4 8E030000 */  lw        $v1, 0x0($s0)
/* 1E0D8 80042CD8 30620008 */  andi      $v0, $v1, 0x8
/* 1E0DC 80042CDC 10400004 */  beqz      $v0, .L80042CF0
/* 1E0E0 80042CE0 30620020 */   andi     $v0, $v1, 0x20
/* 1E0E4 80042CE4 8EC2008C */  lw        $v0, 0x8C($s6)
/* 1E0E8 80042CE8 16020011 */  bne       $s0, $v0, .L80042D30
/* 1E0EC 80042CEC 30620020 */   andi     $v0, $v1, 0x20
.L80042CF0:
/* 1E0F0 80042CF0 1440000F */  bnez      $v0, .L80042D30
/* 1E0F4 80042CF4 00000000 */   nop
/* 1E0F8 80042CF8 8E040030 */  lw        $a0, 0x30($s0)
/* 1E0FC 80042CFC 1080000C */  beqz      $a0, .L80042D30
/* 1E100 80042D00 2405000A */   addiu    $a1, $zero, 0xA
/* 1E104 80042D04 0C0B0CF8 */  jal       start_script
/* 1E108 80042D08 0000302D */   daddu    $a2, $zero, $zero
/* 1E10C 80042D0C 0040202D */  daddu     $a0, $v0, $zero
/* 1E110 80042D10 AE040048 */  sw        $a0, 0x48($s0)
/* 1E114 80042D14 8C820144 */  lw        $v0, 0x144($a0)
/* 1E118 80042D18 AE020060 */  sw        $v0, 0x60($s0)
/* 1E11C 80042D1C AC900148 */  sw        $s0, 0x148($a0)
/* 1E120 80042D20 86020008 */  lh        $v0, 0x8($s0)
/* 1E124 80042D24 AC82014C */  sw        $v0, 0x14C($a0)
/* 1E128 80042D28 92020006 */  lbu       $v0, 0x6($s0)
/* 1E12C 80042D2C A0820004 */  sb        $v0, 0x4($a0)
.L80042D30:
/* 1E130 80042D30 8E820000 */  lw        $v0, 0x0($s4)
/* 1E134 80042D34 26730001 */  addiu     $s3, $s3, 0x1
/* 1E138 80042D38 0262102A */  slt       $v0, $s3, $v0
/* 1E13C 80042D3C 1440FFE2 */  bnez      $v0, .L80042CC8
/* 1E140 80042D40 26310004 */   addiu    $s1, $s1, 0x4
.L80042D44:
/* 1E144 80042D44 24020191 */  addiu     $v0, $zero, 0x191
/* 1E148 80042D48 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1E14C 80042D4C AC22A5D0 */  sw        $v0, %lo(gEncounterSubState)($at)
/* 1E150 80042D50 08010BD3 */  j         .L80042F4C
/* 1E154 80042D54 00000000 */   nop
.L80042D58:
/* 1E158 80042D58 8EC30090 */  lw        $v1, 0x90($s6)
/* 1E15C 80042D5C 14600003 */  bnez      $v1, .L80042D6C
/* 1E160 80042D60 00000000 */   nop
/* 1E164 80042D64 08010BD3 */  j         .L80042F4C
/* 1E168 80042D68 AC820000 */   sw       $v0, 0x0($a0)
.L80042D6C:
/* 1E16C 80042D6C 8EC20098 */  lw        $v0, 0x98($s6)
/* 1E170 80042D70 24420004 */  addiu     $v0, $v0, 0x4
/* 1E174 80042D74 AEC20098 */  sw        $v0, 0x98($s6)
/* 1E178 80042D78 00621023 */  subu      $v0, $v1, $v0
/* 1E17C 80042D7C 04410073 */  bgez      $v0, .L80042F4C
/* 1E180 80042D80 AEC20090 */   sw       $v0, 0x90($s6)
/* 1E184 80042D84 08010BD3 */  j         .L80042F4C
/* 1E188 80042D88 AEC00090 */   sw       $zero, 0x90($s6)
.L80042D8C:
/* 1E18C 80042D8C 8ED40088 */  lw        $s4, 0x88($s6)
/* 1E190 80042D90 8E820000 */  lw        $v0, 0x0($s4)
/* 1E194 80042D94 18400013 */  blez      $v0, .L80042DE4
/* 1E198 80042D98 0240982D */   daddu    $s3, $s2, $zero
/* 1E19C 80042D9C 0280882D */  daddu     $s1, $s4, $zero
.L80042DA0:
/* 1E1A0 80042DA0 8E300004 */  lw        $s0, 0x4($s1)
/* 1E1A4 80042DA4 1200000A */  beqz      $s0, .L80042DD0
/* 1E1A8 80042DA8 00000000 */   nop
/* 1E1AC 80042DAC 8E020000 */  lw        $v0, 0x0($s0)
/* 1E1B0 80042DB0 30420020 */  andi      $v0, $v0, 0x20
/* 1E1B4 80042DB4 14400006 */  bnez      $v0, .L80042DD0
/* 1E1B8 80042DB8 00000000 */   nop
/* 1E1BC 80042DBC 0C0B1059 */  jal       does_script_exist
/* 1E1C0 80042DC0 8E040060 */   lw       $a0, 0x60($s0)
/* 1E1C4 80042DC4 50400002 */  beql      $v0, $zero, .L80042DD0
/* 1E1C8 80042DC8 AE000048 */   sw       $zero, 0x48($s0)
/* 1E1CC 80042DCC 24120001 */  addiu     $s2, $zero, 0x1
.L80042DD0:
/* 1E1D0 80042DD0 8E820000 */  lw        $v0, 0x0($s4)
/* 1E1D4 80042DD4 26730001 */  addiu     $s3, $s3, 0x1
/* 1E1D8 80042DD8 0262102A */  slt       $v0, $s3, $v0
/* 1E1DC 80042DDC 1440FFF0 */  bnez      $v0, .L80042DA0
/* 1E1E0 80042DE0 26310004 */   addiu    $s1, $s1, 0x4
.L80042DE4:
/* 1E1E4 80042DE4 16400059 */  bnez      $s2, .L80042F4C
/* 1E1E8 80042DE8 00000000 */   nop
/* 1E1EC 80042DEC 82C2001C */  lb        $v0, 0x1C($s6)
/* 1E1F0 80042DF0 18400024 */  blez      $v0, .L80042E84
/* 1E1F4 80042DF4 0000982D */   daddu    $s3, $zero, $zero
/* 1E1F8 80042DF8 02C0A82D */  daddu     $s5, $s6, $zero
.L80042DFC:
/* 1E1FC 80042DFC 8EB40028 */  lw        $s4, 0x28($s5)
/* 1E200 80042E00 1280001B */  beqz      $s4, .L80042E70
/* 1E204 80042E04 00000000 */   nop
/* 1E208 80042E08 8E820000 */  lw        $v0, 0x0($s4)
/* 1E20C 80042E0C 18400018 */  blez      $v0, .L80042E70
/* 1E210 80042E10 0000882D */   daddu    $s1, $zero, $zero
/* 1E214 80042E14 0280902D */  daddu     $s2, $s4, $zero
.L80042E18:
/* 1E218 80042E18 8E500004 */  lw        $s0, 0x4($s2)
/* 1E21C 80042E1C 1200000F */  beqz      $s0, .L80042E5C
/* 1E220 80042E20 00000000 */   nop
/* 1E224 80042E24 8E020000 */  lw        $v0, 0x0($s0)
/* 1E228 80042E28 30420020 */  andi      $v0, $v0, 0x20
/* 1E22C 80042E2C 1440000B */  bnez      $v0, .L80042E5C
/* 1E230 80042E30 00000000 */   nop
/* 1E234 80042E34 8E02003C */  lw        $v0, 0x3C($s0)
/* 1E238 80042E38 10400003 */  beqz      $v0, .L80042E48
/* 1E23C 80042E3C 00000000 */   nop
/* 1E240 80042E40 0C0B1123 */  jal       resume_all_script
/* 1E244 80042E44 8E040054 */   lw       $a0, 0x54($s0)
.L80042E48:
/* 1E248 80042E48 8E020044 */  lw        $v0, 0x44($s0)
/* 1E24C 80042E4C 10400003 */  beqz      $v0, .L80042E5C
/* 1E250 80042E50 00000000 */   nop
/* 1E254 80042E54 0C0B1123 */  jal       resume_all_script
/* 1E258 80042E58 8E04005C */   lw       $a0, 0x5C($s0)
.L80042E5C:
/* 1E25C 80042E5C 8E820000 */  lw        $v0, 0x0($s4)
/* 1E260 80042E60 26310001 */  addiu     $s1, $s1, 0x1
/* 1E264 80042E64 0222102A */  slt       $v0, $s1, $v0
/* 1E268 80042E68 1440FFEB */  bnez      $v0, .L80042E18
/* 1E26C 80042E6C 26520004 */   addiu    $s2, $s2, 0x4
.L80042E70:
/* 1E270 80042E70 82C2001C */  lb        $v0, 0x1C($s6)
/* 1E274 80042E74 26730001 */  addiu     $s3, $s3, 0x1
/* 1E278 80042E78 0262102A */  slt       $v0, $s3, $v0
/* 1E27C 80042E7C 1440FFDF */  bnez      $v0, .L80042DFC
/* 1E280 80042E80 26B50004 */   addiu    $s5, $s5, 0x4
.L80042E84:
/* 1E284 80042E84 8ED0008C */  lw        $s0, 0x8C($s6)
/* 1E288 80042E88 8E020000 */  lw        $v0, 0x0($s0)
/* 1E28C 80042E8C 30420004 */  andi      $v0, $v0, 0x4
/* 1E290 80042E90 1440001C */  bnez      $v0, .L80042F04
/* 1E294 80042E94 2402002D */   addiu    $v0, $zero, 0x2D
/* 1E298 80042E98 8ED40088 */  lw        $s4, 0x88($s6)
/* 1E29C 80042E9C A20200B4 */  sb        $v0, 0xB4($s0)
/* 1E2A0 80042EA0 2402002D */  addiu     $v0, $zero, 0x2D
/* 1E2A4 80042EA4 A6E20010 */  sh        $v0, 0x10($s7)
/* 1E2A8 80042EA8 8E820000 */  lw        $v0, 0x0($s4)
/* 1E2AC 80042EAC 18400014 */  blez      $v0, .L80042F00
/* 1E2B0 80042EB0 0000882D */   daddu    $s1, $zero, $zero
/* 1E2B4 80042EB4 2406002D */  addiu     $a2, $zero, 0x2D
/* 1E2B8 80042EB8 2405002D */  addiu     $a1, $zero, 0x2D
/* 1E2BC 80042EBC 0280202D */  daddu     $a0, $s4, $zero
.L80042EC0:
/* 1E2C0 80042EC0 8C900004 */  lw        $s0, 0x4($a0)
/* 1E2C4 80042EC4 12000009 */  beqz      $s0, .L80042EEC
/* 1E2C8 80042EC8 00000000 */   nop
/* 1E2CC 80042ECC 8E030000 */  lw        $v1, 0x0($s0)
/* 1E2D0 80042ED0 30620020 */  andi      $v0, $v1, 0x20
/* 1E2D4 80042ED4 14400005 */  bnez      $v0, .L80042EEC
/* 1E2D8 80042ED8 30620008 */   andi     $v0, $v1, 0x8
/* 1E2DC 80042EDC 14400003 */  bnez      $v0, .L80042EEC
/* 1E2E0 80042EE0 00000000 */   nop
/* 1E2E4 80042EE4 A20600B4 */  sb        $a2, 0xB4($s0)
/* 1E2E8 80042EE8 A6E50010 */  sh        $a1, 0x10($s7)
.L80042EEC:
/* 1E2EC 80042EEC 8E820000 */  lw        $v0, 0x0($s4)
/* 1E2F0 80042EF0 26310001 */  addiu     $s1, $s1, 0x1
/* 1E2F4 80042EF4 0222102A */  slt       $v0, $s1, $v0
/* 1E2F8 80042EF8 1440FFF1 */  bnez      $v0, .L80042EC0
/* 1E2FC 80042EFC 24840004 */   addiu    $a0, $a0, 0x4
.L80042F00:
/* 1E300 80042F00 2402002D */  addiu     $v0, $zero, 0x2D
.L80042F04:
/* 1E304 80042F04 A2C2000A */  sb        $v0, 0xA($s6)
.L80042F08:
/* 1E308 80042F08 0C038069 */  jal       enable_player_input
/* 1E30C 80042F0C 00000000 */   nop
/* 1E310 80042F10 0C03BD80 */  jal       partner_enable_input
/* 1E314 80042F14 00000000 */   nop
.L80042F18:
/* 1E318 80042F18 3C05BF80 */  lui       $a1, (0xBF800000 >> 16)
/* 1E31C 80042F1C 0C04DF62 */  jal       set_screen_overlay_params_front
/* 1E320 80042F20 240400FF */   addiu    $a0, $zero, 0xFF
.L80042F24:
/* 1E324 80042F24 0C0B1192 */  jal       resume_all_group
/* 1E328 80042F28 24040010 */   addiu    $a0, $zero, 0x10
/* 1E32C 80042F2C 24020002 */  addiu     $v0, $zero, 0x2
/* 1E330 80042F30 3C01800A */  lui       $at, %hi(gEncounterState)
/* 1E334 80042F34 AC22A600 */  sw        $v0, %lo(gEncounterState)($at)
/* 1E338 80042F38 24020001 */  addiu     $v0, $zero, 0x1
/* 1E33C 80042F3C 3C01800A */  lui       $at, %hi(D_8009A678)
/* 1E340 80042F40 AC22A678 */  sw        $v0, %lo(D_8009A678)($at)
/* 1E344 80042F44 3C01800A */  lui       $at, %hi(gEncounterSubState)
/* 1E348 80042F48 AC20A5D0 */  sw        $zero, %lo(gEncounterSubState)($at)
.L80042F4C:
/* 1E34C 80042F4C 82C2001C */  lb        $v0, 0x1C($s6)
/* 1E350 80042F50 18400032 */  blez      $v0, .L8004301C
/* 1E354 80042F54 0000982D */   daddu    $s3, $zero, $zero
/* 1E358 80042F58 3C1E8000 */  lui       $fp, (0x80000000 >> 16)
/* 1E35C 80042F5C 3C177FFF */  lui       $s7, (0x7FFFFFFF >> 16)
/* 1E360 80042F60 36F7FFFF */  ori       $s7, $s7, (0x7FFFFFFF & 0xFFFF)
/* 1E364 80042F64 02C0A82D */  daddu     $s5, $s6, $zero
.L80042F68:
/* 1E368 80042F68 8EB40028 */  lw        $s4, 0x28($s5)
/* 1E36C 80042F6C 12800026 */  beqz      $s4, .L80043008
/* 1E370 80042F70 00000000 */   nop
/* 1E374 80042F74 8E820000 */  lw        $v0, 0x0($s4)
/* 1E378 80042F78 18400023 */  blez      $v0, .L80043008
/* 1E37C 80042F7C 0000882D */   daddu    $s1, $zero, $zero
/* 1E380 80042F80 0280902D */  daddu     $s2, $s4, $zero
.L80042F84:
/* 1E384 80042F84 8E500004 */  lw        $s0, 0x4($s2)
/* 1E388 80042F88 1200001A */  beqz      $s0, .L80042FF4
/* 1E38C 80042F8C 00000000 */   nop
/* 1E390 80042F90 8E020000 */  lw        $v0, 0x0($s0)
/* 1E394 80042F94 30420020 */  andi      $v0, $v0, 0x20
/* 1E398 80042F98 14400016 */  bnez      $v0, .L80042FF4
/* 1E39C 80042F9C 00000000 */   nop
/* 1E3A0 80042FA0 0C00EABB */  jal       get_npc_unsafe
/* 1E3A4 80042FA4 86040008 */   lh       $a0, 0x8($s0)
/* 1E3A8 80042FA8 0040202D */  daddu     $a0, $v0, $zero
/* 1E3AC 80042FAC 820200B4 */  lb        $v0, 0xB4($s0)
/* 1E3B0 80042FB0 920300B4 */  lbu       $v1, 0xB4($s0)
/* 1E3B4 80042FB4 1040000F */  beqz      $v0, .L80042FF4
/* 1E3B8 80042FB8 30620001 */   andi     $v0, $v1, 0x1
/* 1E3BC 80042FBC 10400007 */  beqz      $v0, .L80042FDC
/* 1E3C0 80042FC0 00000000 */   nop
/* 1E3C4 80042FC4 8C820000 */  lw        $v0, 0x0($a0)
/* 1E3C8 80042FC8 005E1025 */  or        $v0, $v0, $fp
/* 1E3CC 80042FCC AC820000 */  sw        $v0, 0x0($a0)
/* 1E3D0 80042FD0 8E020000 */  lw        $v0, 0x0($s0)
/* 1E3D4 80042FD4 08010BFC */  j         .L80042FF0
/* 1E3D8 80042FD8 005E1025 */   or       $v0, $v0, $fp
.L80042FDC:
/* 1E3DC 80042FDC 8C820000 */  lw        $v0, 0x0($a0)
/* 1E3E0 80042FE0 00571024 */  and       $v0, $v0, $s7
/* 1E3E4 80042FE4 AC820000 */  sw        $v0, 0x0($a0)
/* 1E3E8 80042FE8 8E020000 */  lw        $v0, 0x0($s0)
/* 1E3EC 80042FEC 00571024 */  and       $v0, $v0, $s7
.L80042FF0:
/* 1E3F0 80042FF0 AE020000 */  sw        $v0, 0x0($s0)
.L80042FF4:
/* 1E3F4 80042FF4 8E820000 */  lw        $v0, 0x0($s4)
/* 1E3F8 80042FF8 26310001 */  addiu     $s1, $s1, 0x1
/* 1E3FC 80042FFC 0222102A */  slt       $v0, $s1, $v0
/* 1E400 80043000 1440FFE0 */  bnez      $v0, .L80042F84
/* 1E404 80043004 26520004 */   addiu    $s2, $s2, 0x4
.L80043008:
/* 1E408 80043008 82C2001C */  lb        $v0, 0x1C($s6)
/* 1E40C 8004300C 26730001 */  addiu     $s3, $s3, 0x1
/* 1E410 80043010 0262102A */  slt       $v0, $s3, $v0
/* 1E414 80043014 1440FFD4 */  bnez      $v0, .L80042F68
/* 1E418 80043018 26B50004 */   addiu    $s5, $s5, 0x4
.L8004301C:
/* 1E41C 8004301C 8FBF0034 */  lw        $ra, 0x34($sp)
/* 1E420 80043020 8FBE0030 */  lw        $fp, 0x30($sp)
/* 1E424 80043024 8FB7002C */  lw        $s7, 0x2C($sp)
/* 1E428 80043028 8FB60028 */  lw        $s6, 0x28($sp)
/* 1E42C 8004302C 8FB50024 */  lw        $s5, 0x24($sp)
/* 1E430 80043030 8FB40020 */  lw        $s4, 0x20($sp)
/* 1E434 80043034 8FB3001C */  lw        $s3, 0x1C($sp)
/* 1E438 80043038 8FB20018 */  lw        $s2, 0x18($sp)
/* 1E43C 8004303C 8FB10014 */  lw        $s1, 0x14($sp)
/* 1E440 80043040 8FB00010 */  lw        $s0, 0x10($sp)
/* 1E444 80043044 03E00008 */  jr        $ra
/* 1E448 80043048 27BD0038 */   addiu    $sp, $sp, 0x38

### DECOMPILED C INSTRUCTIONS:

void update_encounters_post_battle(void) {
    EncounterStatus* currentEncounter = &gCurrentEncounter;
    PlayerStatus* playerStatus = &gPlayerStatus;
    PlayerData* playerData = &gPlayerData;
    PartnerStatus* partnerStatus = &gPartnerStatus;
    Encounter* encounter;
    Evt* script;
    Enemy* enemy;
    s32 i, j;
    s32 hasDefeatScript;
    Npc* npc;

    switch (gEncounterSubState) {
        case ENCOUNTER_SUBSTATE_POST_BATTLE_INIT:
            if (currentEncounter->unk_08 == 0) {
                return;
            }

            currentEncounter->unk_08 = 0;
            gPlayerStatus.blinkTimer = 0;
            currentEncounter->scriptedBattle = FALSE;
            func_800E97E4();
            currentEncounter->dizzyAttackStatus = 0;
            currentEncounter->unk_A4 = 0;
            currentEncounter->unk_A8 = 0;
            currentEncounter->unk_AC = 0;
            currentEncounter->dizzyAttackDuration = 0;
            currentEncounter->unk_A6 = 0;
            currentEncounter->unk_AA = 0;
            currentEncounter->unk_AE = 0;
            if (D_8009A654 == TRUE) {
                bgm_pop_battle_song();
            }
            currentEncounter->fadeOutAccel = 1;
            currentEncounter->battleStartCountdown = 0;
            D_8009A670 = FALSE;
            gPlayerStatus.flags &= ~PS_FLAG_ENTERING_BATTLE;
            if (currentEncounter->hitType == ENCOUNTER_TRIGGER_SPIN) {
                D_8009A670 = TRUE;
            }
            currentEncounter->hitType = 0;
            if (D_80077C40 == 0) {
                partner_handle_after_battle();
            }
            D_8009A63C = FALSE;
            if (partnerStatus->shouldResumeAbility) {
                D_8009A63C = TRUE;
            } else if (D_8009A670 == 0 &&
                       !(gPlayerStatus.flags & (PS_FLAG_JUMPING | PS_FLAG_FALLING)) &&
                       gPlayerStatus.actionState != ACTION_STATE_RIDE &&
                       gPlayerStatus.actionState != ACTION_STATE_USE_SPINNING_FLOWER) {
                set_action_state(ACTION_STATE_IDLE);
            }
            switch (currentEncounter->battleOutcome) {
                case OUTCOME_PLAYER_WON:
                    gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_WON_CHECK_MERLEE_BONUS;
                    break;
                case OUTCOME_PLAYER_LOST:
                    gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_INIT;
                    break;
                case OUTCOME_PLAYER_FLED:
                    gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_INIT;
                    break;
                case OUTCOME_4:
                    gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_300;
                    break;
                case OUTCOME_ENEMY_FLED:
                    gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_INIT;
                    break;
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_WON_CHECK_MERLEE_BONUS:
            if (currentEncounter->hasMerleeCoinBonus) {
                if (get_coin_drop_amount(currentEncounter->currentEnemy) != 0) {
                    D_800A0BB0 = start_script(&EVS_MerleeDropCoins, EVT_PRIORITY_A, 0);
                    D_800A0BB0->groupFlags = 0;
                    D_800A0BB4 = D_800A0BB0->id;
                } else {
                    playerData->merleeTurnCount = 0;
                    playerData->merleeCastsLeft++;
                }
            }
            gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_PLAY_NPC_DEFEAT;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_PLAY_NPC_DEFEAT:
            if (currentEncounter->hasMerleeCoinBonus && (get_coin_drop_amount(currentEncounter->currentEnemy) != 0)) {
                currentEncounter->fadeOutAccel += 4;
                currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
                if (currentEncounter->fadeOutAmount < 0) {
                    currentEncounter->fadeOutAmount = 0;
                }
                if (does_script_exist(D_800A0BB4)) {
                    break;
                }
            }
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->currentEnemy) {
                    continue;
                }
                if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                    continue;
                }
                if (enemy->defeatBytecode != NULL) {
                    script = start_script_in_group(enemy->defeatBytecode, EVT_PRIORITY_A, 0, 0);
                    enemy->defeatScript = script;
                    enemy->defeatScriptID = script->id;
                    script->owner1.enemy = enemy;
                    script->owner2.npcID = enemy->npcID;
                    script->groupFlags = 0;
                    currentEncounter->battleStartCountdown = 1;
                } else {
                    script = start_script_in_group(&EVS_NpcDefeat, EVT_PRIORITY_A, 0, 0);
                    enemy->defeatScript = script;
                    enemy->defeatScriptID = script->id;
                    script->owner1.enemy = enemy;
                    script->owner2.npcID = enemy->npcID;
                    script->groupFlags = 0;
                }
            }
            if (!(currentEncounter->flags & ENCOUNTER_STATUS_FLAG_1) && !D_8009A63C && currentEncounter->battleStartCountdown == 0 && D_8009A670 == 0) {
                suggest_player_anim_allow_backward(0x10032);
            }
            gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_WON_WAIT;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_WON_WAIT:
            if (currentEncounter->fadeOutAmount == 0) {
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_WON_KILL;
            } else {
                currentEncounter->fadeOutAccel += 4;
                currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
                if (currentEncounter->fadeOutAmount < 0) {
                    currentEncounter->fadeOutAmount = 0;
                }
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_WON_KILL:
            hasDefeatScript = FALSE;
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->currentEnemy) {
                    continue;
                }
                if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                    continue;
                }
                if (does_script_exist(enemy->defeatScriptID)) {
                    hasDefeatScript = TRUE;
                } else {
                    enemy->defeatScript = NULL;
                }
            }
            if (!hasDefeatScript) {
                if (!(currentEncounter->flags & ENCOUNTER_STATUS_FLAG_1) && !D_8009A63C && currentEncounter->battleStartCountdown == 1) {
                    suggest_player_anim_allow_backward(ANIM_Mario1_ThumbsUp);
                }
                encounter = currentEncounter->currentEncounter;
                for (i = 0; i < encounter->count; i++) {
                    enemy = encounter->enemy[i];
                    enemy = encounter->enemy[i];
                    if (enemy == NULL) {
                        continue;
                    }
                    if (enemy->flags & ENEMY_FLAG_4) {
                        continue;
                    }
                    if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->currentEnemy) {
                        continue;
                    }
                    if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
                        if (!(enemy->flags & ENEMY_FLAG_FLED)) {
                            set_defeated(currentEncounter->mapID, encounter->encounterID + i);
                        }
                    }
                    kill_enemy(enemy);
                }

                currentEncounter->unk_94 = 0;
                if (!(currentEncounter->flags & ENCOUNTER_STATUS_FLAG_1) && !D_8009A63C && currentEncounter->battleStartCountdown == 1) {
                    currentEncounter->unk_94 = 30;
                }
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_WON_TO_NEUTRAL;
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_WON_TO_NEUTRAL:
            if (!(currentEncounter->flags & ENCOUNTER_STATUS_FLAG_2) && (gGameStatusPtr->stickX[0] != 0 || gGameStatusPtr->stickY[0] != 0)) {
                currentEncounter->unk_94 = 0;
            }
            if (currentEncounter->unk_94 != 0) {
                currentEncounter->unk_94--;
                break;
            }

            for (i = 0; i < currentEncounter->numEncounters; i++) {
                encounter = currentEncounter->encounterList[i];
                if (encounter == NULL) {
                    continue;
                }
                for (j = 0; j < encounter->count; j++) {
                    enemy = encounter->enemy[j];
                    if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                        continue;
                    }
                    if (enemy->aiScript != NULL) {
                        resume_all_script(enemy->aiScriptID);
                    }
                    if (enemy->auxScript != NULL) {
                        resume_all_script(enemy->auxScriptID);
                    }
                }
            }

            currentEncounter->battleTriggerCooldown = 15;
            enable_player_input();
            partner_enable_input();
            if (!D_8009A63C) {
                suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
            }
            set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
            resume_all_group(EVT_GROUP_10);
            gEncounterState = ENCOUNTER_STATE_NEUTRAL;
            D_8009A678 = 1;
            gEncounterSubState = ENCOUNTER_SUBSTATE_NEUTRAL;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_INIT:
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->currentEnemy) {
                    continue;
                }

                if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                    continue;
                }

                if (enemy->defeatBytecode != NULL) {
                    script = start_script(enemy->defeatBytecode, EVT_PRIORITY_A, 0);
                    enemy->defeatScript = script;
                    enemy->defeatScriptID = script->id;
                    enemy->aiFlags |= 1;
                    script->owner1.enemy = enemy;
                    script->owner2.npcID = enemy->npcID;
                    script->groupFlags = enemy->scriptGroup;
                }
            }
            gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_WAIT;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_WAIT:
            if (currentEncounter->fadeOutAmount == 0) {
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_102;
            } else {
                currentEncounter->fadeOutAccel += 4;
                currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
                if (currentEncounter->fadeOutAmount < 0) {
                    currentEncounter->fadeOutAmount = 0;
                }
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_102:
            encounter = currentEncounter->currentEncounter;
            hasDefeatScript = FALSE;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                    if (does_script_exist(enemy->defeatScriptID)) {
                        hasDefeatScript = TRUE;
                    } else {
                        enemy->defeatScript = NULL;
                    }
                }
            }
            if (!hasDefeatScript) {
                for (i = 0; i < currentEncounter->numEncounters; i++) {
                    encounter = currentEncounter->encounterList[i];
                    if (encounter == NULL) {
                        continue;
                    }
                    for (j = 0; j < encounter->count; j++) {
                        enemy = encounter->enemy[j];
                        if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                            continue;
                        }
                        if (enemy->aiScript != NULL) {
                            resume_all_script(enemy->aiScriptID);
                        }
                        if (enemy->auxScript != NULL) {
                            resume_all_script(enemy->auxScriptID);
                        }
                    }
                }

                enemy = currentEncounter->currentEnemy;
                encounter = currentEncounter->currentEncounter;
                if (!(enemy->flags & ENEMY_FLAG_40000)) {
                    enemy->aiSuspendTime = 45;
                    playerStatus->blinkTimer = 45;
                    for (j = 0; j < encounter->count; j++) {
                        enemy = encounter->enemy[j];
                        if (enemy == NULL) {
                            continue;
                        }
                        if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                            continue;
                        }
                        if (enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) {
                            continue;
                        }
                        enemy->aiSuspendTime = 45;
                        playerStatus->blinkTimer = 45;
                    }
                }

                enemy = currentEncounter->currentEnemy;
                if (!(currentEncounter->flags & ENCOUNTER_STATUS_FLAG_4)) {
                    script = start_script(&EVS_FleeBattleDrops, EVT_PRIORITY_A, 0);
                    enemy->defeatScript = script;
                    enemy->defeatScriptID = script->id;
                    script->owner1.enemy = enemy;
                    script->owner2.npcID = enemy->npcID;
                    script->groupFlags = enemy->scriptGroup;
                }

                currentEncounter->battleTriggerCooldown = 45;
                playerStatus->blinkTimer = 45;
                enable_player_input();
                partner_enable_input();
                set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
                if (!D_8009A63C) {
                    currentEncounter->unk_94 = 15;
                } else {
                    currentEncounter->unk_94 = 0;
                }
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_103;
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_103:
            if (currentEncounter->unk_94 != 0) {
                currentEncounter->unk_94--;
                if (gGameStatusPtr->currentButtons[0] == 0 && gGameStatusPtr->stickX[0] == 0 && gGameStatusPtr->stickY[0] == 0) {
                    break;
                }
            }
            if (!D_8009A63C && playerStatus->anim == ANIM_MarioB3_Hustled) {
                suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
            }
            resume_all_group(EVT_GROUP_10);
            gEncounterState = ENCOUNTER_STATE_NEUTRAL;
            D_8009A678 = 1;
            gEncounterSubState = ENCOUNTER_SUBSTATE_NEUTRAL;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_INIT:
            suggest_player_anim_allow_backward(ANIM_MarioW2_LayingDown);
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->currentEnemy) {
                    continue;
                }

                if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                    continue;
                }

                if (enemy->defeatBytecode != NULL) {
                    script = start_script(enemy->defeatBytecode, EVT_PRIORITY_A, 0);
                    enemy->defeatScript = script;
                    enemy->defeatScriptID = script->id;
                    script->owner1.enemy = enemy;
                    script->owner2.npcID = enemy->npcID;
                    script->groupFlags = enemy->scriptGroup;
                }
            }
            gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_WAIT;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_WAIT:
            if (currentEncounter->fadeOutAmount == 0) {
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_202;
            } else {
                currentEncounter->fadeOutAccel += 4;
                currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
                if (currentEncounter->fadeOutAmount < 0) {
                    currentEncounter->fadeOutAmount = 0;
                }
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_202:
            hasDefeatScript = FALSE;
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                    if (does_script_exist(enemy->defeatScriptID)) {
                        hasDefeatScript = TRUE;
                    } else {
                        enemy->defeatScript = NULL;
                    }
                }
            }
            if (!hasDefeatScript) {
                for (i = 0; i < currentEncounter->numEncounters; i++) {
                    encounter = currentEncounter->encounterList[i];
                    if (encounter == NULL) {
                        continue;
                    }
                    for (j = 0; j < encounter->count; j++) {
                        enemy = encounter->enemy[j];
                        if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                            continue;
                        }
                        if (enemy->aiScript != NULL) {
                            resume_all_script(enemy->aiScriptID);
                        }
                        if (enemy->auxScript != NULL) {
                            resume_all_script(enemy->auxScriptID);
                        }
                    }
                }
                enable_player_input();
                partner_enable_input();
                set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
                currentEncounter->unk_94 = 15;
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_TO_NEUTRAL;
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_TO_NEUTRAL:
            if (currentEncounter->unk_94 != 0) {
                currentEncounter->unk_94--;
                if (gGameStatusPtr->currentButtons[0] == 0 && gGameStatusPtr->stickX[0] == 0 && gGameStatusPtr->stickY[0] == 0) {
                    break;
                }
            }
            resume_all_group(EVT_GROUP_10);
            gEncounterState = ENCOUNTER_STATE_NEUTRAL;
            D_8009A678 = 1;
            gEncounterSubState = ENCOUNTER_SUBSTATE_NEUTRAL;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_300:
            for (i = 0; i < currentEncounter->numEncounters; i++) {
                encounter = currentEncounter->encounterList[i];
                if (encounter == NULL) {
                    continue;
                }
                for (j = 0; j < encounter->count; j++) {
                    enemy = encounter->enemy[j];
                    if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                        continue;
                    }
                    if (enemy->aiScript != NULL) {
                        resume_all_script(enemy->aiScriptID);
                    }
                    if (enemy->auxScript != NULL) {
                        resume_all_script(enemy->auxScriptID);
                    }
                }
            }
            enable_player_input();
            partner_enable_input();
            set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
            resume_all_group(EVT_GROUP_10);
            gEncounterState = ENCOUNTER_STATE_NEUTRAL;
            D_8009A678 = 1;
            gEncounterSubState = ENCOUNTER_SUBSTATE_NEUTRAL;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_INIT:
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->currentEnemy) {
                    continue;
                }

                if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                    continue;
                }

                if (enemy->defeatBytecode != NULL) {
                    script = start_script(enemy->defeatBytecode, EVT_PRIORITY_A, 0);
                    enemy->defeatScript = script;
                    enemy->defeatScriptID = script->id;
                    script->owner1.enemy = enemy;
                    script->owner2.npcID = enemy->npcID;
                    script->groupFlags = enemy->scriptGroup;
                }
            }
            gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_WAIT;
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_WAIT:
            if (currentEncounter->fadeOutAmount == 0) {
                gEncounterSubState = ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_TO_NEUTRAL;
            } else {
                currentEncounter->fadeOutAccel += 4;
                currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
                if (currentEncounter->fadeOutAmount < 0) {
                    currentEncounter->fadeOutAmount = 0;
                }
            }
            break;
        case ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_TO_NEUTRAL:
            hasDefeatScript = FALSE;
            encounter = currentEncounter->currentEncounter;
            for (i = 0; i < encounter->count; i++) {
                enemy = encounter->enemy[i];
                if (enemy == NULL) {
                    continue;
                }
                if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                    if (does_script_exist(enemy->defeatScriptID)) {
                        hasDefeatScript = TRUE;
                    } else {
                        enemy->defeatScript = NULL;
                    }
                }
            }
            if (!hasDefeatScript) {
                for (i = 0; i < currentEncounter->numEncounters; i++) {
                    encounter = currentEncounter->encounterList[i];
                    if (encounter == NULL) {
                        continue;
                    }
                    for (j = 0; j < encounter->count; j++) {
                        enemy = encounter->enemy[j];
                        if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                            continue;
                        }
                        if (enemy->aiScript != NULL) {
                            resume_all_script(enemy->aiScriptID);
                        }
                        if (enemy->auxScript != NULL) {
                            resume_all_script(enemy->auxScriptID);
                        }
                    }
                }

                enemy = currentEncounter->currentEnemy;
                if (!(enemy->flags & ENEMY_FLAG_4)) {
                    encounter = currentEncounter->currentEncounter;
                    enemy->aiSuspendTime = 45;
                    playerStatus->blinkTimer = 45;
                    for (j = 0; j < encounter->count; j++) {
                        enemy = encounter->enemy[j];
                        if (enemy == NULL) {
                            continue;
                        }
                        if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
                            continue;
                        }
                        if (enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) {
                            continue;
                        }
                        enemy->aiSuspendTime = 45;
                        playerStatus->blinkTimer = 45;
                    }
                }

                currentEncounter->battleTriggerCooldown = 45;
                enable_player_input();
                partner_enable_input();
                set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
                resume_all_group(EVT_GROUP_10);
                gEncounterState = ENCOUNTER_STATE_NEUTRAL;
                D_8009A678 = 1;
                gEncounterSubState = ENCOUNTER_SUBSTATE_NEUTRAL;
            }
            break;
    }

    for (i = 0; i < currentEncounter->numEncounters; i++) {
        encounter = currentEncounter->encounterList[i];
        if (encounter == NULL) {
            continue;
        }
        for (j = 0; j < encounter->count; j++) {
            enemy = encounter->enemy[j];
            if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
                continue;
            }

            npc = get_npc_unsafe(enemy->npcID);
            if (enemy->aiSuspendTime != 0) {
                if (enemy->aiSuspendTime & 1) {
                    npc->flags |= NPC_FLAG_SUSPENDED;
                    enemy->flags |= ENEMY_FLAG_SUSPENDED;
                } else {
                    npc->flags &= ~NPC_FLAG_SUSPENDED;
                    enemy->flags &= ~ENEMY_FLAG_SUSPENDED;
                }
            }
        }
    }
}