### RAW ASSEMBLY INSTRUCTIONS:

glabel PartnerPowerBounceEnemy
/* 1AEB50 80280270 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* 1AEB54 80280274 AFB20018 */  sw        $s2, 0x18($sp)
/* 1AEB58 80280278 0080902D */  daddu     $s2, $a0, $zero
/* 1AEB5C 8028027C AFBF0024 */  sw        $ra, 0x24($sp)
/* 1AEB60 80280280 AFB40020 */  sw        $s4, 0x20($sp)
/* 1AEB64 80280284 AFB3001C */  sw        $s3, 0x1C($sp)
/* 1AEB68 80280288 AFB10014 */  sw        $s1, 0x14($sp)
/* 1AEB6C 8028028C AFB00010 */  sw        $s0, 0x10($sp)
/* 1AEB70 80280290 8E440148 */  lw        $a0, 0x148($s2)
/* 1AEB74 80280294 0C09A75B */  jal       get_actor
/* 1AEB78 80280298 8E50000C */   lw       $s0, 0xC($s2)
/* 1AEB7C 8028029C 8E140000 */  lw        $s4, 0x0($s0)
/* 1AEB80 802802A0 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEB84 802802A4 8E030000 */  lw        $v1, 0x0($s0)
/* 1AEB88 802802A8 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEB8C 802802AC 0240202D */  daddu     $a0, $s2, $zero
/* 1AEB90 802802B0 3C11800E */  lui       $s1, %hi(gBattleStatus)
/* 1AEB94 802802B4 2631C070 */  addiu     $s1, $s1, %lo(gBattleStatus)
/* 1AEB98 802802B8 0040982D */  daddu     $s3, $v0, $zero
/* 1AEB9C 802802BC AE230188 */  sw        $v1, 0x188($s1)
/* 1AEBA0 802802C0 8E030000 */  lw        $v1, 0x0($s0)
/* 1AEBA4 802802C4 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEBA8 802802C8 AE23018C */  sw        $v1, 0x18C($s1)
/* 1AEBAC 802802CC 8E030000 */  lw        $v1, 0x0($s0)
glabel shop_owner_reset_speech
/* 1AEBB0 802802D0 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEBB4 802802D4 AE230190 */  sw        $v1, 0x190($s1)
/* 1AEBB8 802802D8 8E050000 */  lw        $a1, 0x0($s0)
/* 1AEBBC 802802DC 0C0B1EAF */  jal       evt_get_variable
/* 1AEBC0 802802E0 26100004 */   addiu    $s0, $s0, 0x4
/* 1AEBC4 802802E4 A622017E */  sh        $v0, 0x17E($s1)
/* 1AEBC8 802802E8 8E050000 */  lw        $a1, 0x0($s0)
/* 1AEBCC 802802EC 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEBD0 802802F0 0C0B1EAF */  jal       evt_get_variable
/* 1AEBD4 802802F4 0240202D */   daddu    $a0, $s2, $zero
/* 1AEBD8 802802F8 A2220198 */  sb        $v0, 0x198($s1)
/* 1AEBDC 802802FC 8E100000 */  lw        $s0, 0x0($s0)
/* 1AEBE0 80280300 24020030 */  addiu     $v0, $zero, 0x30
/* 1AEBE4 80280304 32030030 */  andi      $v1, $s0, 0x30
/* 1AEBE8 80280308 54620004 */  bnel      $v1, $v0, .L8028031C
/* 1AEBEC 8028030C 32020010 */   andi     $v0, $s0, 0x10
/* 1AEBF0 80280310 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEBF4 80280314 080A00D7 */  j         shop_owner_end_speech
/* 1AEBF8 80280318 34420030 */   ori      $v0, $v0, 0x30
.L8028031C:
/* 1AEBFC 8028031C 10400004 */  beqz      $v0, .L80280330
/* 1AEC00 80280320 2403FFDF */   addiu    $v1, $zero, -0x21
/* 1AEC04 80280324 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEC08 80280328 080A00D6 */  j         .L80280358
/* 1AEC0C 8028032C 34420010 */   ori      $v0, $v0, 0x10
.L80280330:
/* 1AEC10 80280330 32020020 */  andi      $v0, $s0, 0x20
/* 1AEC14 80280334 10400005 */  beqz      $v0, .L8028034C
/* 1AEC18 80280338 2403FFEF */   addiu    $v1, $zero, -0x11
/* 1AEC1C 8028033C 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEC20 80280340 00431024 */  and       $v0, $v0, $v1
/* 1AEC24 80280344 080A00D7 */  j         shop_owner_end_speech
/* 1AEC28 80280348 34420020 */   ori      $v0, $v0, 0x20
.L8028034C:
/* 1AEC2C 8028034C 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEC30 80280350 00431024 */  and       $v0, $v0, $v1
/* 1AEC34 80280354 2403FFDF */  addiu     $v1, $zero, -0x21
.L80280358:
/* 1AEC38 80280358 00431024 */  and       $v0, $v0, $v1
glabel shop_owner_end_speech
/* 1AEC3C 8028035C AE220000 */  sw        $v0, 0x0($s1)
/* 1AEC40 80280360 32020040 */  andi      $v0, $s0, 0x40
/* 1AEC44 80280364 10400007 */  beqz      $v0, .L80280384
/* 1AEC48 80280368 2404FFBF */   addiu    $a0, $zero, -0x41
/* 1AEC4C 8028036C 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AEC50 80280370 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AEC54 80280374 8C620000 */  lw        $v0, 0x0($v1)
/* 1AEC58 80280378 34420040 */  ori       $v0, $v0, 0x40
/* 1AEC5C 8028037C 080A00E6 */  j         .L80280398
/* 1AEC60 80280380 AC620000 */   sw       $v0, 0x0($v1)
.L80280384:
/* 1AEC64 80280384 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AEC68 80280388 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AEC6C 8028038C 8C430000 */  lw        $v1, 0x0($v0)
/* 1AEC70 80280390 00641824 */  and       $v1, $v1, $a0
/* 1AEC74 80280394 AC430000 */  sw        $v1, 0x0($v0)
.L80280398:
/* 1AEC78 80280398 32020200 */  andi      $v0, $s0, 0x200
/* 1AEC7C 8028039C 10400007 */  beqz      $v0, .L802803BC
/* 1AEC80 802803A0 2404FDFF */   addiu    $a0, $zero, -0x201
/* 1AEC84 802803A4 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AEC88 802803A8 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AEC8C 802803AC 8C620000 */  lw        $v0, 0x0($v1)
/* 1AEC90 802803B0 34420200 */  ori       $v0, $v0, 0x200
/* 1AEC94 802803B4 080A00F4 */  j         .L802803D0
/* 1AEC98 802803B8 AC620000 */   sw       $v0, 0x0($v1)
.L802803BC:
/* 1AEC9C 802803BC 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AECA0 802803C0 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AECA4 802803C4 8C430000 */  lw        $v1, 0x0($v0)
glabel func_802803C8
/* 1AECA8 802803C8 00641824 */  and       $v1, $v1, $a0
/* 1AECAC 802803CC AC430000 */  sw        $v1, 0x0($v0)
.L802803D0:
/* 1AECB0 802803D0 32020080 */  andi      $v0, $s0, 0x80
/* 1AECB4 802803D4 10400007 */  beqz      $v0, .L802803F4
/* 1AECB8 802803D8 2404FF7F */   addiu    $a0, $zero, -0x81
/* 1AECBC 802803DC 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AECC0 802803E0 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AECC4 802803E4 8C620000 */  lw        $v0, 0x0($v1)
/* 1AECC8 802803E8 34420080 */  ori       $v0, $v0, 0x80
/* 1AECCC 802803EC 080A0102 */  j         .L80280408
/* 1AECD0 802803F0 AC620000 */   sw       $v0, 0x0($v1)
.L802803F4:
/* 1AECD4 802803F4 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AECD8 802803F8 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AECDC 802803FC 8C430000 */  lw        $v1, 0x0($v0)
.L80280400:
/* 1AECE0 80280400 00641824 */  and       $v1, $v1, $a0
/* 1AECE4 80280404 AC430000 */  sw        $v1, 0x0($v0)
.L80280408:
/* 1AECE8 80280408 32020800 */  andi      $v0, $s0, 0x800
/* 1AECEC 8028040C 10400007 */  beqz      $v0, .L8028042C
glabel func_80280410
/* 1AECF0 80280410 2404F7FF */   addiu    $a0, $zero, -0x801
/* 1AECF4 80280414 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AECF8 80280418 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AECFC 8028041C 8C620000 */  lw        $v0, 0x0($v1)
/* 1AED00 80280420 34420800 */  ori       $v0, $v0, 0x800
/* 1AED04 80280424 080A0110 */  j         .L80280440
/* 1AED08 80280428 AC620000 */   sw       $v0, 0x0($v1)
.L8028042C:
/* 1AED0C 8028042C 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AED10 80280430 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AED14 80280434 8C430000 */  lw        $v1, 0x0($v0)
/* 1AED18 80280438 00641824 */  and       $v1, $v1, $a0
/* 1AED1C 8028043C AC430000 */  sw        $v1, 0x0($v0)
.L80280440:
/* 1AED20 80280440 96620428 */  lhu       $v0, 0x428($s3)
/* 1AED24 80280444 92230193 */  lbu       $v1, 0x193($s1)
/* 1AED28 80280448 A62201A0 */  sh        $v0, 0x1A0($s1)
/* 1AED2C 8028044C 92620426 */  lbu       $v0, 0x426($s3)
/* 1AED30 80280450 A2230194 */  sb        $v1, 0x194($s1)
/* 1AED34 80280454 306300FF */  andi      $v1, $v1, 0xFF
/* 1AED38 80280458 A22201A2 */  sb        $v0, 0x1A2($s1)
/* 1AED3C 8028045C 240200FF */  addiu     $v0, $zero, 0xFF
/* 1AED40 80280460 50620001 */  beql      $v1, $v0, .L80280468
/* 1AED44 80280464 A2200194 */   sb       $zero, 0x194($s1)
.L80280468:
/* 1AED48 80280468 8E220190 */  lw        $v0, 0x190($s1)
/* 1AED4C 8028046C 30420F00 */  andi      $v0, $v0, 0xF00
/* 1AED50 80280470 00021203 */  sra       $v0, $v0, 8
/* 1AED54 80280474 0C09F8CA */  jal       calc_partner_damage_enemy
/* 1AED58 80280478 A2220195 */   sb       $v0, 0x195($s1)
/* 1AED5C 8028047C 0440000B */  bltz      $v0, .L802804AC
/* 1AED60 80280480 0240202D */   daddu    $a0, $s2, $zero
/* 1AED64 80280484 0280282D */  daddu     $a1, $s4, $zero
/* 1AED68 80280488 0C0B2026 */  jal       evt_set_variable
/* 1AED6C 8028048C 0040302D */   daddu    $a2, $v0, $zero
/* 1AED70 80280490 0C0B1069 */  jal       does_script_exist_by_ref
/* 1AED74 80280494 0240202D */   daddu    $a0, $s2, $zero
/* 1AED78 80280498 0040182D */  daddu     $v1, $v0, $zero
/* 1AED7C 8028049C 10600004 */  beqz      $v1, .L802804B0
/* 1AED80 802804A0 240200FF */   addiu    $v0, $zero, 0xFF
/* 1AED84 802804A4 080A012C */  j         .L802804B0
/* 1AED88 802804A8 24020002 */   addiu    $v0, $zero, 0x2
.L802804AC:
/* 1AED8C 802804AC 240200FF */  addiu     $v0, $zero, 0xFF
.L802804B0:
/* 1AED90 802804B0 8FBF0024 */  lw        $ra, 0x24($sp)
/* 1AED94 802804B4 8FB40020 */  lw        $s4, 0x20($sp)
/* 1AED98 802804B8 8FB3001C */  lw        $s3, 0x1C($sp)
/* 1AED9C 802804BC 8FB20018 */  lw        $s2, 0x18($sp)
/* 1AEDA0 802804C0 8FB10014 */  lw        $s1, 0x14($sp)
/* 1AEDA4 802804C4 8FB00010 */  lw        $s0, 0x10($sp)
/* 1AEDA8 802804C8 03E00008 */  jr        $ra
/* 1AEDAC 802804CC 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

ApiStatus PartnerPowerBounceEnemy(Evt* script, s32 isInitialCall) {
    BattleStatus* battleStatus = &gBattleStatus;
    Bytecode* args = script->ptrReadPos;
    Actor* actor = get_actor(script->owner1.enemyID);
    s32 returnValue = *args++;
    s32 flags;
    u8 statusChance;
    s32 damageResult;

    battleStatus->currentAttackElement = *args++;
    battleStatus->currentAttackEventSuppression = *args++;
    battleStatus->currentAttackStatus = *args++;
    battleStatus->currentAttackDamage = evt_get_variable(script, *args++);
    battleStatus->powerBounceCounter = evt_get_variable(script, *args++);
    flags = *args++;

    if ((flags & (BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE)) == (BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE)) {
        battleStatus->flags1 |= BS_FLAGS1_10;
        battleStatus->flags1 |= BS_FLAGS1_SP_EVT_ACTIVE;
    } else if (flags & BS_FLAGS1_10) {
        battleStatus->flags1 |= BS_FLAGS1_10;
        battleStatus->flags1 &= ~BS_FLAGS1_SP_EVT_ACTIVE;
    } else if (flags & BS_FLAGS1_SP_EVT_ACTIVE) {
        battleStatus->flags1 &= ~BS_FLAGS1_10;
        battleStatus->flags1 |= BS_FLAGS1_SP_EVT_ACTIVE;
    } else {
        battleStatus->flags1 &= ~BS_FLAGS1_10;
        battleStatus->flags1 &= ~BS_FLAGS1_SP_EVT_ACTIVE;
    }

    if (flags & BS_FLAGS1_40) {
        gBattleStatus.flags1 |= BS_FLAGS1_40;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_40;
    }
    if (flags & BS_FLAGS1_200) {
        gBattleStatus.flags1 |= BS_FLAGS1_200;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_200;
    }
    if (flags & BS_FLAGS1_80) {
        gBattleStatus.flags1 |= BS_FLAGS1_80;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_80;
    }
    if (flags & BS_FLAGS1_FORCE_HIT_IMMUNE) {
        gBattleStatus.flags1 |= BS_FLAGS1_FORCE_HIT_IMMUNE;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_FORCE_HIT_IMMUNE;
    }

    statusChance = battleStatus->currentAttackStatus;
    battleStatus->currentTargetID = actor->targetActorID;
    battleStatus->currentTargetPart = actor->targetPartIndex;
    battleStatus->statusChance = statusChance;

    if (statusChance == STATUS_KEY_NEVER) {
        battleStatus->statusChance = 0;
    }

    battleStatus->statusDuration = (battleStatus->currentAttackStatus & 0xF00) >> 8;
    damageResult = calc_partner_damage_enemy();

    if (damageResult < 0) {
        return ApiStatus_FINISH;
    }

    evt_set_variable(script, returnValue, damageResult);

    if (!does_script_exist_by_ref(script)) {
        return ApiStatus_FINISH;
    }

    return ApiStatus_DONE2;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel update_entity_shadow_position
/* A8A44 80112344 27BDFFC0 */  addiu     $sp, $sp, -0x40
/* A8A48 80112348 AFB10034 */  sw        $s1, 0x34($sp)
/* A8A4C 8011234C 0080882D */  daddu     $s1, $a0, $zero
/* A8A50 80112350 AFBF0038 */  sw        $ra, 0x38($sp)
/* A8A54 80112354 AFB00030 */  sw        $s0, 0x30($sp)
/* A8A58 80112358 0C044181 */  jal       get_shadow_by_index
/* A8A5C 8011235C 86240016 */   lh       $a0, 0x16($s1)
/* A8A60 80112360 0040802D */  daddu     $s0, $v0, $zero
/* A8A64 80112364 5200009B */  beql      $s0, $zero, .L801125D4
/* A8A68 80112368 AE20006C */   sw       $zero, 0x6C($s1)
/* A8A6C 8011236C 9222000B */  lbu       $v0, 0xB($s1)
/* A8A70 80112370 2C4200FF */  sltiu     $v0, $v0, 0xFF
/* A8A74 80112374 10400005 */  beqz      $v0, .L8011238C
/* A8A78 80112378 3C030080 */   lui      $v1, (0x800000 >> 16)
/* A8A7C 8011237C 9222000B */  lbu       $v0, 0xB($s1)
/* A8A80 80112380 00021042 */  srl       $v0, $v0, 1
/* A8A84 80112384 080448E9 */  j         .L801123A4
/* A8A88 80112388 A2020005 */   sb       $v0, 0x5($s0)
.L8011238C:
/* A8A8C 8011238C 8E020000 */  lw        $v0, 0x0($s0)
/* A8A90 80112390 00431024 */  and       $v0, $v0, $v1
/* A8A94 80112394 10400002 */  beqz      $v0, .L801123A0
/* A8A98 80112398 24040080 */   addiu    $a0, $zero, 0x80
/* A8A9C 8011239C 240400A0 */  addiu     $a0, $zero, 0xA0
.L801123A0:
/* A8AA0 801123A0 A2040005 */  sb        $a0, 0x5($s0)
.L801123A4:
/* A8AA4 801123A4 8E220000 */  lw        $v0, 0x0($s1)
/* A8AA8 801123A8 30420004 */  andi      $v0, $v0, 0x4
/* A8AAC 801123AC 1440000A */  bnez      $v0, .L801123D8
/* A8AB0 801123B0 27A40018 */   addiu    $a0, $sp, 0x18
/* A8AB4 801123B4 8E030000 */  lw        $v1, 0x0($s0)
/* A8AB8 801123B8 3C020040 */  lui       $v0, (0x400000 >> 16)
/* A8ABC 801123BC 00621024 */  and       $v0, $v1, $v0
/* A8AC0 801123C0 10400084 */  beqz      $v0, .L801125D4
/* A8AC4 801123C4 3C02FFBF */   lui      $v0, (0xFFBFFFFF >> 16)
/* A8AC8 801123C8 3442FFFF */  ori       $v0, $v0, (0xFFBFFFFF & 0xFFFF)
/* A8ACC 801123CC 00621024 */  and       $v0, $v1, $v0
/* A8AD0 801123D0 AE020000 */  sw        $v0, 0x0($s0)
/* A8AD4 801123D4 27A40018 */  addiu     $a0, $sp, 0x18
.L801123D8:
/* A8AD8 801123D8 27A20028 */  addiu     $v0, $sp, 0x28
/* A8ADC 801123DC 27A5001C */  addiu     $a1, $sp, 0x1C
/* A8AE0 801123E0 27A60020 */  addiu     $a2, $sp, 0x20
/* A8AE4 801123E4 C6200048 */  lwc1      $f0, 0x48($s1)
/* A8AE8 801123E8 C622004C */  lwc1      $f2, 0x4C($s1)
/* A8AEC 801123EC C6240050 */  lwc1      $f4, 0x50($s1)
/* A8AF0 801123F0 27A70024 */  addiu     $a3, $sp, 0x24
/* A8AF4 801123F4 E7A00018 */  swc1      $f0, 0x18($sp)
/* A8AF8 801123F8 E7A2001C */  swc1      $f2, 0x1C($sp)
/* A8AFC 801123FC E7A40020 */  swc1      $f4, 0x20($sp)
/* A8B00 80112400 AFA20010 */  sw        $v0, 0x10($sp)
/* A8B04 80112404 27A2002C */  addiu     $v0, $sp, 0x2C
/* A8B08 80112408 0C04497A */  jal       entity_raycast_down
/* A8B0C 8011240C AFA20014 */   sw       $v0, 0x14($sp)
/* A8B10 80112410 1440000A */  bnez      $v0, .L8011243C
/* A8B14 80112414 00000000 */   nop
/* A8B18 80112418 C7A2002C */  lwc1      $f2, 0x2C($sp)
/* A8B1C 8011241C 3C0146FF */  lui       $at, (0x46FFFE00 >> 16)
/* A8B20 80112420 3421FE00 */  ori       $at, $at, (0x46FFFE00 & 0xFFFF)
/* A8B24 80112424 44810000 */  mtc1      $at, $f0
/* A8B28 80112428 00000000 */  nop
/* A8B2C 8011242C 46001032 */  c.eq.s    $f2, $f0
/* A8B30 80112430 00000000 */  nop
/* A8B34 80112434 45030001 */  bc1tl     .L8011243C
/* A8B38 80112438 AFA0002C */   sw       $zero, 0x2C($sp)
.L8011243C:
/* A8B3C 8011243C 8E020000 */  lw        $v0, 0x0($s0)
/* A8B40 80112440 C7A8002C */  lwc1      $f8, 0x2C($sp)
/* A8B44 80112444 30420200 */  andi      $v0, $v0, 0x200
/* A8B48 80112448 10400012 */  beqz      $v0, .L80112494
/* A8B4C 8011244C 00000000 */   nop
/* A8B50 80112450 8622000C */  lh        $v0, 0xC($s1)
/* A8B54 80112454 3C014354 */  lui       $at, (0x43548000 >> 16)
/* A8B58 80112458 34218000 */  ori       $at, $at, (0x43548000 & 0xFFFF)
/* A8B5C 8011245C 44811000 */  mtc1      $at, $f2
/* A8B60 80112460 44820000 */  mtc1      $v0, $f0
/* A8B64 80112464 00000000 */  nop
/* A8B68 80112468 46800020 */  cvt.s.w   $f0, $f0
/* A8B6C 8011246C 46020003 */  div.s     $f0, $f0, $f2
/* A8B70 80112470 E600001C */  swc1      $f0, 0x1C($s0)
/* A8B74 80112474 86220010 */  lh        $v0, 0x10($s1)
/* A8B78 80112478 E7A2002C */  swc1      $f2, 0x2C($sp)
/* A8B7C 8011247C 44820000 */  mtc1      $v0, $f0
/* A8B80 80112480 00000000 */  nop
/* A8B84 80112484 46800020 */  cvt.s.w   $f0, $f0
/* A8B88 80112488 46020003 */  div.s     $f0, $f0, $f2
/* A8B8C 8011248C 08044944 */  j         .L80112510
/* A8B90 80112490 E6000024 */   swc1     $f0, 0x24($s0)
.L80112494:
/* A8B94 80112494 3C014316 */  lui       $at, (0x43160000 >> 16)
/* A8B98 80112498 44810000 */  mtc1      $at, $f0
/* A8B9C 8011249C 3C018015 */  lui       $at, %hi(D_8014F940)
/* A8BA0 801124A0 D422F940 */  ldc1      $f2, %lo(D_8014F940)($at)
/* A8BA4 801124A4 46004003 */  div.s     $f0, $f8, $f0
/* A8BA8 801124A8 46000021 */  cvt.d.s   $f0, $f0
/* A8BAC 801124AC 46220000 */  add.d     $f0, $f0, $f2
/* A8BB0 801124B0 3C018015 */  lui       $at, %hi(D_8014F948)
/* A8BB4 801124B4 D422F948 */  ldc1      $f2, %lo(D_8014F948)($at)
/* A8BB8 801124B8 46220002 */  mul.d     $f0, $f0, $f2
/* A8BBC 801124BC 00000000 */  nop
/* A8BC0 801124C0 8622000C */  lh        $v0, 0xC($s1)
/* A8BC4 801124C4 C6240054 */  lwc1      $f4, 0x54($s1)
/* A8BC8 801124C8 44821000 */  mtc1      $v0, $f2
/* A8BCC 801124CC 00000000 */  nop
/* A8BD0 801124D0 468010A0 */  cvt.s.w   $f2, $f2
/* A8BD4 801124D4 46200020 */  cvt.s.d   $f0, $f0
/* A8BD8 801124D8 46001083 */  div.s     $f2, $f2, $f0
/* A8BDC 801124DC 46041082 */  mul.s     $f2, $f2, $f4
/* A8BE0 801124E0 00000000 */  nop
/* A8BE4 801124E4 E602001C */  swc1      $f2, 0x1C($s0)
/* A8BE8 801124E8 86220010 */  lh        $v0, 0x10($s1)
/* A8BEC 801124EC C624005C */  lwc1      $f4, 0x5C($s1)
/* A8BF0 801124F0 44821000 */  mtc1      $v0, $f2
/* A8BF4 801124F4 00000000 */  nop
/* A8BF8 801124F8 468010A0 */  cvt.s.w   $f2, $f2
/* A8BFC 801124FC 46001083 */  div.s     $f2, $f2, $f0
/* A8C00 80112500 46041082 */  mul.s     $f2, $f2, $f4
/* A8C04 80112504 00000000 */  nop
/* A8C08 80112508 E7A0002C */  swc1      $f0, 0x2C($sp)
/* A8C0C 8011250C E6020024 */  swc1      $f2, 0x24($s0)
.L80112510:
/* A8C10 80112510 C6200048 */  lwc1      $f0, 0x48($s1)
/* A8C14 80112514 E6000010 */  swc1      $f0, 0x10($s0)
/* A8C18 80112518 C7A6001C */  lwc1      $f6, 0x1C($sp)
/* A8C1C 8011251C C6200050 */  lwc1      $f0, 0x50($s1)
/* A8C20 80112520 C7A20024 */  lwc1      $f2, 0x24($sp)
/* A8C24 80112524 C7A40028 */  lwc1      $f4, 0x28($sp)
/* A8C28 80112528 E6060014 */  swc1      $f6, 0x14($s0)
/* A8C2C 8011252C E6000018 */  swc1      $f0, 0x18($s0)
/* A8C30 80112530 E626006C */  swc1      $f6, 0x6C($s1)
/* A8C34 80112534 E6020028 */  swc1      $f2, 0x28($s0)
/* A8C38 80112538 E6040030 */  swc1      $f4, 0x30($s0)
/* A8C3C 8011253C C6200064 */  lwc1      $f0, 0x64($s1)
/* A8C40 80112540 E600002C */  swc1      $f0, 0x2C($s0)
/* A8C44 80112544 C620004C */  lwc1      $f0, 0x4C($s1)
/* A8C48 80112548 4606003C */  c.lt.s    $f0, $f6
/* A8C4C 8011254C 00000000 */  nop
/* A8C50 80112550 45000009 */  bc1f      .L80112578
/* A8C54 80112554 3C034000 */   lui      $v1, (0x40000000 >> 16)
/* A8C58 80112558 3C014120 */  lui       $at, (0x41200000 >> 16)
/* A8C5C 8011255C 44810000 */  mtc1      $at, $f0
/* A8C60 80112560 8E020000 */  lw        $v0, 0x0($s0)
/* A8C64 80112564 46003000 */  add.s     $f0, $f6, $f0
/* A8C68 80112568 00431025 */  or        $v0, $v0, $v1
/* A8C6C 8011256C AE020000 */  sw        $v0, 0x0($s0)
/* A8C70 80112570 08044963 */  j         .L8011258C
/* A8C74 80112574 E620004C */   swc1     $f0, 0x4C($s1)
.L80112578:
/* A8C78 80112578 3C03BFFF */  lui       $v1, (0xBFFFFFFF >> 16)
/* A8C7C 8011257C 8E020000 */  lw        $v0, 0x0($s0)
/* A8C80 80112580 3463FFFF */  ori       $v1, $v1, (0xBFFFFFFF & 0xFFFF)
/* A8C84 80112584 00431024 */  and       $v0, $v0, $v1
/* A8C88 80112588 AE020000 */  sw        $v0, 0x0($s0)
.L8011258C:
/* A8C8C 8011258C 2404FFFE */  addiu     $a0, $zero, -0x2
/* A8C90 80112590 8E030000 */  lw        $v1, 0x0($s0)
/* A8C94 80112594 96220002 */  lhu       $v0, 0x2($s1)
/* A8C98 80112598 00641824 */  and       $v1, $v1, $a0
/* A8C9C 8011259C 30420001 */  andi      $v0, $v0, 0x1
/* A8CA0 801125A0 00621825 */  or        $v1, $v1, $v0
/* A8CA4 801125A4 AE030000 */  sw        $v1, 0x0($s0)
/* A8CA8 801125A8 8E220000 */  lw        $v0, 0x0($s1)
/* A8CAC 801125AC 30420400 */  andi      $v0, $v0, 0x400
/* A8CB0 801125B0 14400008 */  bnez      $v0, .L801125D4
/* A8CB4 801125B4 00000000 */   nop
/* A8CB8 801125B8 44800000 */  mtc1      $zero, $f0
/* A8CBC 801125BC 00000000 */  nop
/* A8CC0 801125C0 46004032 */  c.eq.s    $f8, $f0
/* A8CC4 801125C4 00000000 */  nop
/* A8CC8 801125C8 45000002 */  bc1f      .L801125D4
/* A8CCC 801125CC 34620001 */   ori      $v0, $v1, 0x1
/* A8CD0 801125D0 AE020000 */  sw        $v0, 0x0($s0)
.L801125D4:
/* A8CD4 801125D4 8FBF0038 */  lw        $ra, 0x38($sp)
/* A8CD8 801125D8 8FB10034 */  lw        $s1, 0x34($sp)
/* A8CDC 801125DC 8FB00030 */  lw        $s0, 0x30($sp)
/* A8CE0 801125E0 03E00008 */  jr        $ra
/* A8CE4 801125E4 27BD0040 */   addiu    $sp, $sp, 0x40

### DECOMPILED C INSTRUCTIONS:

void update_entity_shadow_position(Entity* entity) {
    Shadow* shadow = get_shadow_by_index(entity->shadowIndex);

    if (shadow != NULL) {
        f32 rayX;
        f32 rayY;
        f32 rayZ;
        f32 hitYaw;
        f32 hitPitch;
        f32 hitLength;
        f32 origHitLength;

        if (entity->alpha < 255) {
            shadow->alpha = entity->alpha / 2;
        } else {
            u8 alphaTemp;

            if (shadow->flags & ENTITY_FLAG_DARK_SHADOW) {
                alphaTemp = 160;
            } else {
                alphaTemp = 128;
            }
            shadow->alpha = alphaTemp;
        }

        if (!(entity->flags & ENTITY_FLAG_HAS_DYNAMIC_SHADOW)) {
            if (shadow->flags & ENTITY_FLAG_SHADOW_POS_DIRTY) {
                shadow->flags &= ~ENTITY_FLAG_SHADOW_POS_DIRTY;
            } else {
                return;
            }
        }

        rayX = entity->position.x;
        rayY = entity->position.y;
        rayZ = entity->position.z;

        if (!entity_raycast_down(&rayX, &rayY, &rayZ, &hitYaw, &hitPitch, &hitLength) && hitLength == 32767.0f) {
            hitLength = 0.0f;
        }

        origHitLength = hitLength;

        if (shadow->flags & ENTITY_FLAG_FIXED_SHADOW_SIZE) {
            hitLength = 212.5f;
            shadow->scale.x = entity->aabb.x / hitLength;
            shadow->scale.z = entity->aabb.z / hitLength;
        } else {
            hitLength = ((hitLength / 150.0f) + 0.95) * 250.0;
            shadow->scale.x = (entity->aabb.x / hitLength) * entity->scale.x;
            shadow->scale.z = (entity->aabb.z / hitLength) * entity->scale.z;
        }

        shadow->position.x = entity->position.x;
        shadow->position.z = entity->position.z;
        shadow->position.y = rayY;
        entity->shadowPosY = rayY;
        shadow->rotation.x = hitYaw;
        shadow->rotation.z = hitPitch;
        shadow->rotation.y = entity->rotation.y;

        if (entity->position.y < rayY) {
            shadow->flags |= ENTITY_FLAG_SKIP_UPDATE;
            entity->position.y = rayY + 10.0f;
        } else {
            shadow->flags &= ~ENTITY_FLAG_SKIP_UPDATE;
        }

        shadow->flags = (shadow->flags & ~ENTITY_FLAG_HIDDEN) | ((u16)entity->flags & ENTITY_FLAG_HIDDEN);
        if (!(entity->flags & ENTITY_FLAG_400) && origHitLength == 0.0f) {
            shadow->flags |= ENTITY_FLAG_HIDDEN;
        }
    } else {
        entity->shadowPosY = 0.0f;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel func_800F0D80
/* 8A230 800F0D80 27BDFFA8 */  addiu     $sp, $sp, -0x58
/* 8A234 800F0D84 F7B60040 */  sdc1      $f22, 0x40($sp)
/* 8A238 800F0D88 3C018011 */  lui       $at, %hi(D_8010C310)
/* 8A23C 800F0D8C D436C310 */  ldc1      $f22, %lo(D_8010C310)($at)
/* 8A240 800F0D90 F7B40038 */  sdc1      $f20, 0x38($sp)
/* 8A244 800F0D94 3C018011 */  lui       $at, %hi(D_8010C318)
/* 8A248 800F0D98 D434C318 */  ldc1      $f20, %lo(D_8010C318)($at)
/* 8A24C 800F0D9C AFB40020 */  sw        $s4, 0x20($sp)
/* 8A250 800F0DA0 0000A02D */  daddu     $s4, $zero, $zero
/* 8A254 800F0DA4 AFBE0030 */  sw        $fp, 0x30($sp)
/* 8A258 800F0DA8 3C1E8011 */  lui       $fp, %hi(D_80109820)
/* 8A25C 800F0DAC 27DE9820 */  addiu     $fp, $fp, %lo(D_80109820)
/* 8A260 800F0DB0 AFB60028 */  sw        $s6, 0x28($sp)
/* 8A264 800F0DB4 2416007F */  addiu     $s6, $zero, 0x7F
/* 8A268 800F0DB8 AFB7002C */  sw        $s7, 0x2C($sp)
/* 8A26C 800F0DBC 3C178011 */  lui       $s7, %hi(D_80109800)
/* 8A270 800F0DC0 26F79800 */  addiu     $s7, $s7, %lo(D_80109800)
/* 8A274 800F0DC4 AFB3001C */  sw        $s3, 0x1C($sp)
/* 8A278 800F0DC8 0280982D */  daddu     $s3, $s4, $zero
/* 8A27C 800F0DCC AFBF0034 */  sw        $ra, 0x34($sp)
/* 8A280 800F0DD0 AFB50024 */  sw        $s5, 0x24($sp)
/* 8A284 800F0DD4 AFB20018 */  sw        $s2, 0x18($sp)
/* 8A288 800F0DD8 AFB10014 */  sw        $s1, 0x14($sp)
/* 8A28C 800F0DDC AFB00010 */  sw        $s0, 0x10($sp)
/* 8A290 800F0DE0 F7BA0050 */  sdc1      $f26, 0x50($sp)
/* 8A294 800F0DE4 F7B80048 */  sdc1      $f24, 0x48($sp)
.L800F0DE8:
/* 8A298 800F0DE8 3C058011 */  lui       $a1, %hi(D_8010D000)
/* 8A29C 800F0DEC 24A5D000 */  addiu     $a1, $a1, %lo(D_8010D000)
/* 8A2A0 800F0DF0 02651821 */  addu      $v1, $s3, $a1
/* 8A2A4 800F0DF4 90620000 */  lbu       $v0, 0x0($v1)
/* 8A2A8 800F0DF8 5040007A */  beql      $v0, $zero, .L800F0FE4
/* 8A2AC 800F0DFC 26940001 */   addiu    $s4, $s4, 0x1
/* 8A2B0 800F0E00 90620001 */  lbu       $v0, 0x1($v1)
/* 8A2B4 800F0E04 2442FFFF */  addiu     $v0, $v0, -0x1
/* 8A2B8 800F0E08 A0620001 */  sb        $v0, 0x1($v1)
/* 8A2BC 800F0E0C 90620002 */  lbu       $v0, 0x2($v1)
/* 8A2C0 800F0E10 80640001 */  lb        $a0, 0x1($v1)
/* 8A2C4 800F0E14 24420001 */  addiu     $v0, $v0, 0x1
/* 8A2C8 800F0E18 04810003 */  bgez      $a0, .L800F0E28
/* 8A2CC 800F0E1C A0620002 */   sb       $v0, 0x2($v1)
/* 8A2D0 800F0E20 0803C3F8 */  j         .L800F0FE0
/* 8A2D4 800F0E24 A0600000 */   sb       $zero, 0x0($v1)
.L800F0E28:
/* 8A2D8 800F0E28 0080A82D */  daddu     $s5, $a0, $zero
/* 8A2DC 800F0E2C 24120001 */  addiu     $s2, $zero, 0x1
/* 8A2E0 800F0E30 24700034 */  addiu     $s0, $v1, 0x34
/* 8A2E4 800F0E34 0000882D */  daddu     $s1, $zero, $zero
/* 8A2E8 800F0E38 C47A0008 */  lwc1      $f26, 0x8($v1)
/* 8A2EC 800F0E3C C478000C */  lwc1      $f24, 0xC($v1)
.L800F0E40:
/* 8A2F0 800F0E40 9202FFEF */  lbu       $v0, -0x11($s0)
/* 8A2F4 800F0E44 24420001 */  addiu     $v0, $v0, 0x1
/* 8A2F8 800F0E48 A202FFEF */  sb        $v0, -0x11($s0)
/* 8A2FC 800F0E4C 00021600 */  sll       $v0, $v0, 24
/* 8A300 800F0E50 00021603 */  sra       $v0, $v0, 24
/* 8A304 800F0E54 2842001E */  slti      $v0, $v0, 0x1E
/* 8A308 800F0E58 14400006 */  bnez      $v0, .L800F0E74
/* 8A30C 800F0E5C 2AA2001E */   slti     $v0, $s5, 0x1E
/* 8A310 800F0E60 10400003 */  beqz      $v0, .L800F0E70
/* 8A314 800F0E64 2402FFE1 */   addiu    $v0, $zero, -0x1F
/* 8A318 800F0E68 0803C39D */  j         .L800F0E74
/* 8A31C 800F0E6C A202FFEF */   sb       $v0, -0x11($s0)
.L800F0E70:
/* 8A320 800F0E70 A200FFEF */  sb        $zero, -0x11($s0)
.L800F0E74:
/* 8A324 800F0E74 8202FFEF */  lb        $v0, -0x11($s0)
/* 8A328 800F0E78 04420055 */  bltzl     $v0, .L800F0FD0
/* 8A32C 800F0E7C 26310002 */   addiu    $s1, $s1, 0x2
/* 8A330 800F0E80 14400031 */  bnez      $v0, .L800F0F48
/* 8A334 800F0E84 023E1821 */   addu     $v1, $s1, $fp
/* 8A338 800F0E88 80620000 */  lb        $v0, 0x0($v1)
/* 8A33C 800F0E8C 44821000 */  mtc1      $v0, $f2
/* 8A340 800F0E90 00000000 */  nop
/* 8A344 800F0E94 468010A0 */  cvt.s.w   $f2, $f2
/* 8A348 800F0E98 460010A1 */  cvt.d.s   $f2, $f2
/* 8A34C 800F0E9C 46361082 */  mul.d     $f2, $f2, $f22
/* 8A350 800F0EA0 00000000 */  nop
/* 8A354 800F0EA4 80620001 */  lb        $v0, 0x1($v1)
/* 8A358 800F0EA8 44820000 */  mtc1      $v0, $f0
/* 8A35C 800F0EAC 00000000 */  nop
/* 8A360 800F0EB0 46800020 */  cvt.s.w   $f0, $f0
/* 8A364 800F0EB4 46000007 */  neg.s     $f0, $f0
/* 8A368 800F0EB8 46000021 */  cvt.d.s   $f0, $f0
/* 8A36C 800F0EBC 46360002 */  mul.d     $f0, $f0, $f22
/* 8A370 800F0EC0 00000000 */  nop
/* 8A374 800F0EC4 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 8A378 800F0EC8 44812000 */  mtc1      $at, $f4
/* 8A37C 800F0ECC 2404007F */  addiu     $a0, $zero, 0x7F
/* 8A380 800F0ED0 E61AFFF0 */  swc1      $f26, -0x10($s0)
/* 8A384 800F0ED4 E618FFF4 */  swc1      $f24, -0xC($s0)
/* 8A388 800F0ED8 E6040000 */  swc1      $f4, 0x0($s0)
/* 8A38C 800F0EDC 462010A0 */  cvt.s.d   $f2, $f2
/* 8A390 800F0EE0 E602FFF8 */  swc1      $f2, -0x8($s0)
/* 8A394 800F0EE4 46200020 */  cvt.s.d   $f0, $f0
/* 8A398 800F0EE8 0C00A67F */  jal       rand_int
/* 8A39C 800F0EEC E600FFFC */   swc1     $f0, -0x4($s0)
/* 8A3A0 800F0EF0 A202FFEB */  sb        $v0, -0x15($s0)
/* 8A3A4 800F0EF4 304400FF */  andi      $a0, $v0, 0xFF
/* 8A3A8 800F0EF8 0C00A67F */  jal       rand_int
/* 8A3AC 800F0EFC 02C42023 */   subu     $a0, $s6, $a0
/* 8A3B0 800F0F00 A202FFEC */  sb        $v0, -0x14($s0)
/* 8A3B4 800F0F04 304400FF */  andi      $a0, $v0, 0xFF
/* 8A3B8 800F0F08 9202FFEB */  lbu       $v0, -0x15($s0)
/* 8A3BC 800F0F0C 02C42023 */  subu      $a0, $s6, $a0
/* 8A3C0 800F0F10 0C00A67F */  jal       rand_int
/* 8A3C4 800F0F14 00822023 */   subu     $a0, $a0, $v0
/* 8A3C8 800F0F18 9203FFEB */  lbu       $v1, -0x15($s0)
/* 8A3CC 800F0F1C A202FFED */  sb        $v0, -0x13($s0)
/* 8A3D0 800F0F20 240200FF */  addiu     $v0, $zero, 0xFF
/* 8A3D4 800F0F24 A202FFEE */  sb        $v0, -0x12($s0)
/* 8A3D8 800F0F28 9202FFEC */  lbu       $v0, -0x14($s0)
/* 8A3DC 800F0F2C 24630080 */  addiu     $v1, $v1, 0x80
/* 8A3E0 800F0F30 A203FFEB */  sb        $v1, -0x15($s0)
/* 8A3E4 800F0F34 9203FFED */  lbu       $v1, -0x13($s0)
/* 8A3E8 800F0F38 24420080 */  addiu     $v0, $v0, 0x80
/* 8A3EC 800F0F3C A202FFEC */  sb        $v0, -0x14($s0)
/* 8A3F0 800F0F40 24630080 */  addiu     $v1, $v1, 0x80
/* 8A3F4 800F0F44 A203FFED */  sb        $v1, -0x13($s0)
.L800F0F48:
/* 8A3F8 800F0F48 C600FFF8 */  lwc1      $f0, -0x8($s0)
/* 8A3FC 800F0F4C 46000021 */  cvt.d.s   $f0, $f0
/* 8A400 800F0F50 46340002 */  mul.d     $f0, $f0, $f20
/* 8A404 800F0F54 00000000 */  nop
/* 8A408 800F0F58 C602FFFC */  lwc1      $f2, -0x4($s0)
/* 8A40C 800F0F5C 460010A1 */  cvt.d.s   $f2, $f2
/* 8A410 800F0F60 46341082 */  mul.d     $f2, $f2, $f20
/* 8A414 800F0F64 00000000 */  nop
/* 8A418 800F0F68 C608FFF0 */  lwc1      $f8, -0x10($s0)
/* 8A41C 800F0F6C C604FFF8 */  lwc1      $f4, -0x8($s0)
/* 8A420 800F0F70 C606FFF4 */  lwc1      $f6, -0xC($s0)
/* 8A424 800F0F74 46044200 */  add.s     $f8, $f8, $f4
/* 8A428 800F0F78 C604FFFC */  lwc1      $f4, -0x4($s0)
/* 8A42C 800F0F7C 8202FFEF */  lb        $v0, -0x11($s0)
/* 8A430 800F0F80 46043180 */  add.s     $f6, $f6, $f4
/* 8A434 800F0F84 00571021 */  addu      $v0, $v0, $s7
/* 8A438 800F0F88 E608FFF0 */  swc1      $f8, -0x10($s0)
/* 8A43C 800F0F8C E606FFF4 */  swc1      $f6, -0xC($s0)
/* 8A440 800F0F90 46200020 */  cvt.s.d   $f0, $f0
/* 8A444 800F0F94 462010A0 */  cvt.s.d   $f2, $f2
/* 8A448 800F0F98 E600FFF8 */  swc1      $f0, -0x8($s0)
/* 8A44C 800F0F9C E602FFFC */  swc1      $f2, -0x4($s0)
/* 8A450 800F0FA0 90420000 */  lbu       $v0, 0x0($v0)
/* 8A454 800F0FA4 3C018011 */  lui       $at, %hi(D_8010C320)
/* 8A458 800F0FA8 D422C320 */  ldc1      $f2, %lo(D_8010C320)($at)
/* 8A45C 800F0FAC 44820000 */  mtc1      $v0, $f0
/* 8A460 800F0FB0 00000000 */  nop
/* 8A464 800F0FB4 46800020 */  cvt.s.w   $f0, $f0
/* 8A468 800F0FB8 46000021 */  cvt.d.s   $f0, $f0
/* 8A46C 800F0FBC 46220002 */  mul.d     $f0, $f0, $f2
/* 8A470 800F0FC0 00000000 */  nop
/* 8A474 800F0FC4 46200020 */  cvt.s.d   $f0, $f0
/* 8A478 800F0FC8 E6000000 */  swc1      $f0, 0x0($s0)
/* 8A47C 800F0FCC 26310002 */  addiu     $s1, $s1, 0x2
.L800F0FD0:
/* 8A480 800F0FD0 26520001 */  addiu     $s2, $s2, 0x1
/* 8A484 800F0FD4 2A420039 */  slti      $v0, $s2, 0x39
/* 8A488 800F0FD8 1440FF99 */  bnez      $v0, .L800F0E40
/* 8A48C 800F0FDC 2610001C */   addiu    $s0, $s0, 0x1C
.L800F0FE0:
/* 8A490 800F0FE0 26940001 */  addiu     $s4, $s4, 0x1
.L800F0FE4:
/* 8A494 800F0FE4 1A80FF80 */  blez      $s4, .L800F0DE8
/* 8A498 800F0FE8 2673063C */   addiu    $s3, $s3, 0x63C
/* 8A49C 800F0FEC 8FBF0034 */  lw        $ra, 0x34($sp)
/* 8A4A0 800F0FF0 8FBE0030 */  lw        $fp, 0x30($sp)
/* 8A4A4 800F0FF4 8FB7002C */  lw        $s7, 0x2C($sp)
/* 8A4A8 800F0FF8 8FB60028 */  lw        $s6, 0x28($sp)
/* 8A4AC 800F0FFC 8FB50024 */  lw        $s5, 0x24($sp)
/* 8A4B0 800F1000 8FB40020 */  lw        $s4, 0x20($sp)
/* 8A4B4 800F1004 8FB3001C */  lw        $s3, 0x1C($sp)
/* 8A4B8 800F1008 8FB20018 */  lw        $s2, 0x18($sp)
/* 8A4BC 800F100C 8FB10014 */  lw        $s1, 0x14($sp)
/* 8A4C0 800F1010 8FB00010 */  lw        $s0, 0x10($sp)
/* 8A4C4 800F1014 D7BA0050 */  ldc1      $f26, 0x50($sp)
/* 8A4C8 800F1018 D7B80048 */  ldc1      $f24, 0x48($sp)
/* 8A4CC 800F101C D7B60040 */  ldc1      $f22, 0x40($sp)
/* 8A4D0 800F1020 D7B40038 */  ldc1      $f20, 0x38($sp)
/* 8A4D4 800F1024 03E00008 */  jr        $ra
/* 8A4D8 800F1028 27BD0058 */   addiu    $sp, $sp, 0x58

### DECOMPILED C INSTRUCTIONS:

void func_800F0D80(void) {
    Unk8a160Outer* outer;
    s32 i;
    s32 j;

    for (i = 0; i < ARRAY_COUNT(D_8010D000); i++, outer++) {
        outer = &D_8010D000[i];

        if (outer->subs[0].alive) {
            outer->subs[0].timeLeft--;
            outer->subs[0].lifetime++;

            if (outer->subs[0].timeLeft < 0) {
                outer->subs[0].alive = FALSE;
            } else {
                Unk8a160* sub = &outer->subs[0];
                s32 baseTimeLeft = sub->timeLeft;
                f32 baseX = sub->x;
                f32 baseY = sub->y;

                sub++;
                for (j = 1; j < ARRAY_COUNT(outer->subs); j++, sub++) {
                    sub->lodVal++;
                    if (sub->lodVal >= 30) {
                        if (baseTimeLeft < 30) {
                            sub->lodVal = -31;
                        } else {
                            sub->lodVal = 0;
                        }
                    }

                    if (sub->lodVal >= 0) {
                        if (sub->lodVal == 0) {
                            f32 tx = D_80109820[j - 1].x;
                            f32 ty = D_80109820[j - 1].y;
                            u8 t = 127;

                            sub->vel.x = tx * 0.1;
                            sub->vel.y = -ty * 0.1;
                            sub->x = baseX;
                            sub->y = baseY;
                            sub->scale = 1.0f;
                            sub->rgba.r = rand_int(t);
                            sub->rgba.g = rand_int(t - sub->rgba.r);
                            sub->rgba.b = rand_int(t - sub->rgba.g - sub->rgba.r);
                            sub->rgba.a = 255;
                            sub->rgba.r += 128;
                            sub->rgba.g += 128;
                            sub->rgba.b += 128;
                        }
                        sub->x += sub->vel.x;
                        sub->y += sub->vel.y;
                        sub->vel.x *= 0.92;
                        sub->vel.y *= 0.92;
                        sub->scale = (f32) D_80109800[sub->lodVal] * 0.04;
                    }
                }
            }
        }
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel spr_load_sprite
/* 101BFC 802DEB0C 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* 101C00 802DEB10 AFB50024 */  sw        $s5, 0x24($sp)
/* 101C04 802DEB14 0080A82D */  daddu     $s5, $a0, $zero
/* 101C08 802DEB18 AFB40020 */  sw        $s4, 0x20($sp)
/* 101C0C 802DEB1C 00A0A02D */  daddu     $s4, $a1, $zero
/* 101C10 802DEB20 AFB60028 */  sw        $s6, 0x28($sp)
/* 101C14 802DEB24 00C0B02D */  daddu     $s6, $a2, $zero
/* 101C18 802DEB28 AFBF002C */  sw        $ra, 0x2C($sp)
/* 101C1C 802DEB2C AFB3001C */  sw        $s3, 0x1C($sp)
/* 101C20 802DEB30 AFB20018 */  sw        $s2, 0x18($sp)
/* 101C24 802DEB34 AFB10014 */  sw        $s1, 0x14($sp)
/* 101C28 802DEB38 12800005 */  beqz      $s4, .L802DEB50
/* 101C2C 802DEB3C AFB00010 */   sw       $s0, 0x10($sp)
/* 101C30 802DEB40 3C13802E */  lui       $s3, %hi(D_802E0C64)
/* 101C34 802DEB44 8E730C64 */  lw        $s3, %lo(D_802E0C64)($s3)
/* 101C38 802DEB48 080B7AD7 */  j         .L802DEB5C
/* 101C3C 802DEB4C 00152080 */   sll      $a0, $s5, 2
.L802DEB50:
/* 101C40 802DEB50 3C13802E */  lui       $s3, %hi(D_802E0C68)
/* 101C44 802DEB54 8E730C68 */  lw        $s3, %lo(D_802E0C68)($s3)
/* 101C48 802DEB58 00152080 */  sll       $a0, $s5, 2
.L802DEB5C:
/* 101C4C 802DEB5C 02642021 */  addu      $a0, $s3, $a0
/* 101C50 802DEB60 3C11802E */  lui       $s1, %hi(spr_asset_entry)
/* 101C54 802DEB64 2631FEB0 */  addiu     $s1, $s1, %lo(spr_asset_entry)
/* 101C58 802DEB68 0220282D */  daddu     $a1, $s1, $zero
/* 101C5C 802DEB6C 0C017D24 */  jal       nuPiReadRom
/* 101C60 802DEB70 24060008 */   addiu    $a2, $zero, 0x8
/* 101C64 802DEB74 8E300004 */  lw        $s0, 0x4($s1)
/* 101C68 802DEB78 8E220000 */  lw        $v0, 0x0($s1)
/* 101C6C 802DEB7C 02028023 */  subu      $s0, $s0, $v0
/* 101C70 802DEB80 26100007 */  addiu     $s0, $s0, 0x7
/* 101C74 802DEB84 2402FFF8 */  addiu     $v0, $zero, -0x8
/* 101C78 802DEB88 02028024 */  and       $s0, $s0, $v0
/* 101C7C 802DEB8C 0C00AB0A */  jal       general_heap_malloc
/* 101C80 802DEB90 0200202D */   daddu    $a0, $s0, $zero
/* 101C84 802DEB94 0040902D */  daddu     $s2, $v0, $zero
/* 101C88 802DEB98 0240282D */  daddu     $a1, $s2, $zero
/* 101C8C 802DEB9C 8E240000 */  lw        $a0, 0x0($s1)
/* 101C90 802DEBA0 0200302D */  daddu     $a2, $s0, $zero
/* 101C94 802DEBA4 0C017D24 */  jal       nuPiReadRom
/* 101C98 802DEBA8 02642021 */   addu     $a0, $s3, $a0
/* 101C9C 802DEBAC 12C00008 */  beqz      $s6, .L802DEBD0
/* 101CA0 802DEBB0 26450004 */   addiu    $a1, $s2, 0x4
/* 101CA4 802DEBB4 8CA50000 */  lw        $a1, 0x0($a1)
/* 101CA8 802DEBB8 3C048035 */  lui       $a0, %hi(heap_spriteHead)
/* 101CAC 802DEBBC 2484F800 */  addiu     $a0, $a0, %lo(heap_spriteHead)
/* 101CB0 802DEBC0 0C00A459 */  jal       _heap_malloc_tail
/* 101CB4 802DEBC4 00000000 */   nop
/* 101CB8 802DEBC8 080B7AFA */  j         .L802DEBE8
/* 101CBC 802DEBCC 0040882D */   daddu    $s1, $v0, $zero
.L802DEBD0:
/* 101CC0 802DEBD0 8CA50000 */  lw        $a1, 0x0($a1)
/* 101CC4 802DEBD4 3C048035 */  lui       $a0, %hi(heap_spriteHead)
/* 101CC8 802DEBD8 2484F800 */  addiu     $a0, $a0, %lo(heap_spriteHead)
/* 101CCC 802DEBDC 0C00A41B */  jal       _heap_malloc
/* 101CD0 802DEBE0 00000000 */   nop
/* 101CD4 802DEBE4 0040882D */  daddu     $s1, $v0, $zero
.L802DEBE8:
/* 101CD8 802DEBE8 0240202D */  daddu     $a0, $s2, $zero
/* 101CDC 802DEBEC 0C01BB7C */  jal       decode_yay0
/* 101CE0 802DEBF0 0220282D */   daddu    $a1, $s1, $zero
/* 101CE4 802DEBF4 0C00AB1E */  jal       general_heap_free
/* 101CE8 802DEBF8 0240202D */   daddu    $a0, $s2, $zero
/* 101CEC 802DEBFC 2404FFFF */  addiu     $a0, $zero, -0x1
/* 101CF0 802DEC00 00111082 */  srl       $v0, $s1, 2
/* 101CF4 802DEC04 8E320000 */  lw        $s2, 0x0($s1)
/* 101CF8 802DEC08 00021080 */  sll       $v0, $v0, 2
/* 101CFC 802DEC0C 02429021 */  addu      $s2, $s2, $v0
/* 101D00 802DEC10 AE320000 */  sw        $s2, 0x0($s1)
.L802DEC14:
/* 101D04 802DEC14 8E450000 */  lw        $a1, 0x0($s2)
/* 101D08 802DEC18 10A40008 */  beq       $a1, $a0, .L802DEC3C
/* 101D0C 802DEC1C 00A22821 */   addu     $a1, $a1, $v0
/* 101D10 802DEC20 AE450000 */  sw        $a1, 0x0($s2)
/* 101D14 802DEC24 8CA30000 */  lw        $v1, 0x0($a1)
/* 101D18 802DEC28 1680FFFA */  bnez      $s4, .L802DEC14
/* 101D1C 802DEC2C 26520004 */   addiu    $s2, $s2, 0x4
/* 101D20 802DEC30 00621821 */  addu      $v1, $v1, $v0
/* 101D24 802DEC34 080B7B05 */  j         .L802DEC14
/* 101D28 802DEC38 ACA30000 */   sw       $v1, 0x0($a1)
.L802DEC3C:
/* 101D2C 802DEC3C 1280002D */  beqz      $s4, .L802DECF4
/* 101D30 802DEC40 00151880 */   sll      $v1, $s5, 2
/* 101D34 802DEC44 3C13802E */  lui       $s3, %hi(PlayerRasterLoadDescBuffer)
/* 101D38 802DEC48 2673FEB8 */  addiu     $s3, $s3, %lo(PlayerRasterLoadDescBuffer)
/* 101D3C 802DEC4C 0260282D */  daddu     $a1, $s3, $zero
/* 101D40 802DEC50 24060194 */  addiu     $a2, $zero, 0x194
/* 101D44 802DEC54 3C12802E */  lui       $s2, %hi(PlayerRasterLoadDescNumLoaded)
/* 101D48 802DEC58 2652004C */  addiu     $s2, $s2, %lo(PlayerRasterLoadDescNumLoaded)
/* 101D4C 802DEC5C 8E420000 */  lw        $v0, 0x0($s2)
/* 101D50 802DEC60 3C04802E */  lui       $a0, %hi(PlayerSpriteRasterSets)
/* 101D54 802DEC64 24840C20 */  addiu     $a0, $a0, %lo(PlayerSpriteRasterSets)
/* 101D58 802DEC68 3C01802E */  lui       $at, %hi(PlayerRasterLoadDescBeginSpriteIndex)
/* 101D5C 802DEC6C 00230821 */  addu      $at, $at, $v1
/* 101D60 802DEC70 AC220050 */  sw        $v0, %lo(PlayerRasterLoadDescBeginSpriteIndex)($at)
/* 101D64 802DEC74 26A20001 */  addiu     $v0, $s5, 0x1
/* 101D68 802DEC78 00021080 */  sll       $v0, $v0, 2
/* 101D6C 802DEC7C 00441021 */  addu      $v0, $v0, $a0
/* 101D70 802DEC80 00641821 */  addu      $v1, $v1, $a0
/* 101D74 802DEC84 3C04802E */  lui       $a0, %hi(SpriteDataHeader)
/* 101D78 802DEC88 8C840C60 */  lw        $a0, %lo(SpriteDataHeader)($a0)
/* 101D7C 802DEC8C 3C07802E */  lui       $a3, %hi(D_802E0C14)
/* 101D80 802DEC90 8CE70C14 */  lw        $a3, %lo(D_802E0C14)($a3)
/* 101D84 802DEC94 8C680000 */  lw        $t0, 0x0($v1)
/* 101D88 802DEC98 8C420000 */  lw        $v0, 0x0($v0)
/* 101D8C 802DEC9C 00872021 */  addu      $a0, $a0, $a3
/* 101D90 802DECA0 00081880 */  sll       $v1, $t0, 2
/* 101D94 802DECA4 00832021 */  addu      $a0, $a0, $v1
/* 101D98 802DECA8 0C017D24 */  jal       nuPiReadRom
/* 101D9C 802DECAC 00488023 */   subu     $s0, $v0, $t0
/* 101DA0 802DECB0 1A000010 */  blez      $s0, .L802DECF4
/* 101DA4 802DECB4 0000302D */   daddu    $a2, $zero, $zero
/* 101DA8 802DECB8 3C08802E */  lui       $t0, %hi(PlayerRasterLoadDesc)
/* 101DAC 802DECBC 25080090 */  addiu     $t0, $t0, %lo(PlayerRasterLoadDesc)
/* 101DB0 802DECC0 0240382D */  daddu     $a3, $s2, $zero
/* 101DB4 802DECC4 0260282D */  daddu     $a1, $s3, $zero
.L802DECC8:
/* 101DB8 802DECC8 8CA40000 */  lw        $a0, 0x0($a1)
/* 101DBC 802DECCC 24A50004 */  addiu     $a1, $a1, 0x4
/* 101DC0 802DECD0 8CE30000 */  lw        $v1, 0x0($a3)
/* 101DC4 802DECD4 24C60001 */  addiu     $a2, $a2, 0x1
/* 101DC8 802DECD8 00031080 */  sll       $v0, $v1, 2
/* 101DCC 802DECDC 24630001 */  addiu     $v1, $v1, 0x1
/* 101DD0 802DECE0 00481021 */  addu      $v0, $v0, $t0
/* 101DD4 802DECE4 AC440000 */  sw        $a0, 0x0($v0)
/* 101DD8 802DECE8 00D0102A */  slt       $v0, $a2, $s0
/* 101DDC 802DECEC 1440FFF6 */  bnez      $v0, .L802DECC8
/* 101DE0 802DECF0 ACE30000 */   sw       $v1, 0x0($a3)
.L802DECF4:
/* 101DE4 802DECF4 2404FFFF */  addiu     $a0, $zero, -0x1
/* 101DE8 802DECF8 00111082 */  srl       $v0, $s1, 2
/* 101DEC 802DECFC 8E230004 */  lw        $v1, 0x4($s1)
/* 101DF0 802DED00 00021080 */  sll       $v0, $v0, 2
/* 101DF4 802DED04 00621821 */  addu      $v1, $v1, $v0
/* 101DF8 802DED08 AE230004 */  sw        $v1, 0x4($s1)
.L802DED0C:
/* 101DFC 802DED0C 8C650000 */  lw        $a1, 0x0($v1)
/* 101E00 802DED10 10A40004 */  beq       $a1, $a0, .L802DED24
/* 101E04 802DED14 00A22821 */   addu     $a1, $a1, $v0
/* 101E08 802DED18 AC650000 */  sw        $a1, 0x0($v1)
/* 101E0C 802DED1C 080B7B43 */  j         .L802DED0C
/* 101E10 802DED20 24630004 */   addiu    $v1, $v1, 0x4
.L802DED24:
/* 101E14 802DED24 0000202D */  daddu     $a0, $zero, $zero
/* 101E18 802DED28 0080282D */  daddu     $a1, $a0, $zero
/* 101E1C 802DED2C 0C0B7AA8 */  jal       spr_swizzle_anim_offsets
/* 101E20 802DED30 0220302D */   daddu    $a2, $s1, $zero
/* 101E24 802DED34 0220102D */  daddu     $v0, $s1, $zero
/* 101E28 802DED38 8FBF002C */  lw        $ra, 0x2C($sp)
/* 101E2C 802DED3C 8FB60028 */  lw        $s6, 0x28($sp)
/* 101E30 802DED40 8FB50024 */  lw        $s5, 0x24($sp)
/* 101E34 802DED44 8FB40020 */  lw        $s4, 0x20($sp)
/* 101E38 802DED48 8FB3001C */  lw        $s3, 0x1C($sp)
/* 101E3C 802DED4C 8FB20018 */  lw        $s2, 0x18($sp)
/* 101E40 802DED50 8FB10014 */  lw        $s1, 0x14($sp)
/* 101E44 802DED54 8FB00010 */  lw        $s0, 0x10($sp)
/* 101E48 802DED58 03E00008 */  jr        $ra
/* 101E4C 802DED5C 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

SpriteAnimData* spr_load_sprite(s32 idx, s32 isPlayerSprite, s32 useTailAlloc) {
    SpriteAnimData* animData;
    s32 base;
    s32 i;
    s32 compressedSize;
    s32* ptr1;
    IMG_PTR image;
    s32 count;
    s32** data;
    s32** palettes;

    if (isPlayerSprite) {
        base = SpriteDataHeader[1];
    } else {
        base = SpriteDataHeader[2];
    }

    // read current and next sprite offsets, so we can find the difference
    nuPiReadRom(base + idx * 4, &spr_asset_entry, sizeof(spr_asset_entry));

    compressedSize = ALIGN8(spr_asset_entry[1] - spr_asset_entry[0]);
    data = general_heap_malloc(compressedSize);
    nuPiReadRom(base + spr_asset_entry[0], data, compressedSize);

    ptr1 = (s32*)data;
    // skip 4 bytes: 'YAY0' signature
    ptr1++;

    if (useTailAlloc) {
        animData = _heap_malloc_tail(&heap_spriteHead, *ptr1);
    } else {
        animData = _heap_malloc(&heap_spriteHead, *ptr1);
    }
    decode_yay0(data, animData);
    general_heap_free(data);

    // swizzle raster array
    data = (s32**)animData->rastersOffset;
    data = SPR_SWIZZLE(ALIGN4(animData), data);
    animData->rastersOffset = (SpriteRasterCacheEntry**)data;

    while (TRUE) {
        ptr1 = *data;
        if (ptr1 == PTR_LIST_END) {
            break;
        }
        // swizzle each raster cache entry
        ptr1 = SPR_SWIZZLE(ALIGN4(animData), ptr1);
        *data++ = ptr1;
        image = ((SpriteRasterCacheEntry*)ptr1)->image;

        if (!isPlayerSprite) {
            // swizzle image pointer in the cache entry
            image = SPR_SWIZZLE(ALIGN4(animData), image);
            *ptr1 = (s32)image;
        }
    }

    if (isPlayerSprite) {
        PlayerRasterLoadDescBeginSpriteIndex[idx] = PlayerRasterLoadDescNumLoaded;
        count = PlayerSpriteRasterSets[idx + 1] - PlayerSpriteRasterSets[idx];
        // load a range of raster loading desciptors to a buffer and copy contents into PlayerRasterLoadDesc
        nuPiReadRom(SpriteDataHeader[0] + PlayerRasterHeader.loadDescriptors + sizeof(u32) * PlayerSpriteRasterSets[idx],
            PlayerRasterLoadDescBuffer, sizeof(PlayerRasterLoadDescBuffer));
        for (i = 0; i < count; i++) {
            PlayerRasterLoadDesc[PlayerRasterLoadDescNumLoaded++] = PlayerRasterLoadDescBuffer[i];
        }
    }

    // swizzle palettes array
    palettes = SPR_SWIZZLE(ALIGN4(animData), animData->palettesOffset);
    animData->palettesOffset = (PAL_PTR*)palettes;
    while (TRUE) {
        ptr1 = *palettes;
        if (ptr1 == PTR_LIST_END) {
            break;
        }
        // swizzle each palette pointer
        ptr1 = SPR_SWIZZLE(ALIGN4(animData), ptr1);
        *palettes++ = ptr1;
    }

    spr_swizzle_anim_offsets(0, 0, animData);
    return animData;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel entity_ItemBlock_replace_with_inactive
/* 105A9C 802E421C 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* 105AA0 802E4220 AFB1001C */  sw        $s1, 0x1C($sp)
/* 105AA4 802E4224 0080882D */  daddu     $s1, $a0, $zero
/* 105AA8 802E4228 AFBF0024 */  sw        $ra, 0x24($sp)
/* 105AAC 802E422C AFB20020 */  sw        $s2, 0x20($sp)
/* 105AB0 802E4230 AFB00018 */  sw        $s0, 0x18($sp)
/* 105AB4 802E4234 0C0441A9 */  jal       get_entity_type
/* 105AB8 802E4238 92240004 */   lbu      $a0, 0x4($s1)
/* 105ABC 802E423C 3C04802F */  lui       $a0, %hi(Entity_InertYellowBlock)
/* 105AC0 802E4240 2484A07C */  addiu     $a0, $a0, %lo(Entity_InertYellowBlock)
/* 105AC4 802E4244 0040182D */  daddu     $v1, $v0, $zero
/* 105AC8 802E4248 28620015 */  slti      $v0, $v1, 0x15
/* 105ACC 802E424C 10400005 */  beqz      $v0, .L802E4264
/* 105AD0 802E4250 28620012 */   slti     $v0, $v1, 0x12
/* 105AD4 802E4254 14400003 */  bnez      $v0, .L802E4264
/* 105AD8 802E4258 00000000 */   nop
/* 105ADC 802E425C 3C04802F */  lui       $a0, %hi(Entity_InertRedBlock)
/* 105AE0 802E4260 2484A0A0 */  addiu     $a0, $a0, %lo(Entity_InertRedBlock)
.L802E4264:
/* 105AE4 802E4264 C6220048 */  lwc1      $f2, 0x48($s1)
/* 105AE8 802E4268 C624004C */  lwc1      $f4, 0x4C($s1)
/* 105AEC 802E426C C6260050 */  lwc1      $f6, 0x50($s1)
/* 105AF0 802E4270 C6200064 */  lwc1      $f0, 0x64($s1)
/* 105AF4 802E4274 3C028000 */  lui       $v0, (0x80000000 >> 16)
/* 105AF8 802E4278 AFA20014 */  sw        $v0, 0x14($sp)
/* 105AFC 802E427C 4600020D */  trunc.w.s $f8, $f0
/* 105B00 802E4280 E7A80010 */  swc1      $f8, 0x10($sp)
/* 105B04 802E4284 4600120D */  trunc.w.s $f8, $f2
/* 105B08 802E4288 44054000 */  mfc1      $a1, $f8
/* 105B0C 802E428C 4600220D */  trunc.w.s $f8, $f4
/* 105B10 802E4290 44064000 */  mfc1      $a2, $f8
/* 105B14 802E4294 4600320D */  trunc.w.s $f8, $f6
/* 105B18 802E4298 44074000 */  mfc1      $a3, $f8
/* 105B1C 802E429C 0C044631 */  jal       create_entity
/* 105B20 802E42A0 00000000 */   nop
/* 105B24 802E42A4 0040902D */  daddu     $s2, $v0, $zero
/* 105B28 802E42A8 0C04417A */  jal       get_entity_by_index
/* 105B2C 802E42AC 0240202D */   daddu    $a0, $s2, $zero
/* 105B30 802E42B0 0040802D */  daddu     $s0, $v0, $zero
/* 105B34 802E42B4 8E020000 */  lw        $v0, 0x0($s0)
/* 105B38 802E42B8 34430001 */  ori       $v1, $v0, 0x1
/* 105B3C 802E42BC AE030000 */  sw        $v1, 0x0($s0)
/* 105B40 802E42C0 8E220000 */  lw        $v0, 0x0($s1)
/* 105B44 802E42C4 3C040004 */  lui       $a0, (0x40000 >> 16)
/* 105B48 802E42C8 00441024 */  and       $v0, $v0, $a0
/* 105B4C 802E42CC 10400002 */  beqz      $v0, .L802E42D8
/* 105B50 802E42D0 00641025 */   or       $v0, $v1, $a0
/* 105B54 802E42D4 AE020000 */  sw        $v0, 0x0($s0)
.L802E42D8:
/* 105B58 802E42D8 8E220000 */  lw        $v0, 0x0($s1)
/* 105B5C 802E42DC 30420004 */  andi      $v0, $v0, 0x4
/* 105B60 802E42E0 10400004 */  beqz      $v0, .L802E42F4
/* 105B64 802E42E4 00000000 */   nop
/* 105B68 802E42E8 8E020000 */  lw        $v0, 0x0($s0)
/* 105B6C 802E42EC 34420004 */  ori       $v0, $v0, 0x4
/* 105B70 802E42F0 AE020000 */  sw        $v0, 0x0($s0)
.L802E42F4:
/* 105B74 802E42F4 0C044181 */  jal       get_shadow_by_index
/* 105B78 802E42F8 86040016 */   lh       $a0, 0x16($s0)
/* 105B7C 802E42FC 0040282D */  daddu     $a1, $v0, $zero
/* 105B80 802E4300 3C020040 */  lui       $v0, (0x400001 >> 16)
/* 105B84 802E4304 34420001 */  ori       $v0, $v0, (0x400001 & 0xFFFF)
/* 105B88 802E4308 8CA30000 */  lw        $v1, 0x0($a1)
/* 105B8C 802E430C 0220202D */  daddu     $a0, $s1, $zero
/* 105B90 802E4310 00621825 */  or        $v1, $v1, $v0
/* 105B94 802E4314 0C044AC8 */  jal       is_block_on_ground
/* 105B98 802E4318 ACA30000 */   sw       $v1, 0x0($a1)
/* 105B9C 802E431C 92240004 */  lbu       $a0, 0x4($s1)
/* 105BA0 802E4320 0C0441A9 */  jal       get_entity_type
/* 105BA4 802E4324 0040802D */   daddu    $s0, $v0, $zero
/* 105BA8 802E4328 0040182D */  daddu     $v1, $v0, $zero
/* 105BAC 802E432C 24020012 */  addiu     $v0, $zero, 0x12
/* 105BB0 802E4330 10620003 */  beq       $v1, $v0, .L802E4340
/* 105BB4 802E4334 24020014 */   addiu    $v0, $zero, 0x14
/* 105BB8 802E4338 14620005 */  bne       $v1, $v0, .L802E4350
/* 105BBC 802E433C 00000000 */   nop
.L802E4340:
/* 105BC0 802E4340 3C04802F */  lui       $a0, %hi(Entity_HitRedBlock)
/* 105BC4 802E4344 2484A660 */  addiu     $a0, $a0, %lo(Entity_HitRedBlock)
/* 105BC8 802E4348 080B90DA */  j         .L802E4368
/* 105BCC 802E434C 00000000 */   nop
.L802E4350:
/* 105BD0 802E4350 3C04802F */  lui       $a0, %hi(Entity_HitFloatingYellowBlock)
/* 105BD4 802E4354 2484A63C */  addiu     $a0, $a0, %lo(Entity_HitFloatingYellowBlock)
/* 105BD8 802E4358 12000003 */  beqz      $s0, .L802E4368
/* 105BDC 802E435C 00000000 */   nop
/* 105BE0 802E4360 3C04802F */  lui       $a0, %hi(Entity_HitGroundedYellowBlock)
/* 105BE4 802E4364 2484A618 */  addiu     $a0, $a0, %lo(Entity_HitGroundedYellowBlock)
.L802E4368:
/* 105BE8 802E4368 C6220048 */  lwc1      $f2, 0x48($s1)
/* 105BEC 802E436C C624004C */  lwc1      $f4, 0x4C($s1)
/* 105BF0 802E4370 C6260050 */  lwc1      $f6, 0x50($s1)
/* 105BF4 802E4374 C6200064 */  lwc1      $f0, 0x64($s1)
/* 105BF8 802E4378 3C028000 */  lui       $v0, (0x80000000 >> 16)
/* 105BFC 802E437C AFA20014 */  sw        $v0, 0x14($sp)
/* 105C00 802E4380 4600020D */  trunc.w.s $f8, $f0
/* 105C04 802E4384 E7A80010 */  swc1      $f8, 0x10($sp)
/* 105C08 802E4388 4600120D */  trunc.w.s $f8, $f2
/* 105C0C 802E438C 44054000 */  mfc1      $a1, $f8
/* 105C10 802E4390 4600220D */  trunc.w.s $f8, $f4
/* 105C14 802E4394 44064000 */  mfc1      $a2, $f8
/* 105C18 802E4398 4600320D */  trunc.w.s $f8, $f6
/* 105C1C 802E439C 44074000 */  mfc1      $a3, $f8
/* 105C20 802E43A0 0C044631 */  jal       create_entity
/* 105C24 802E43A4 00000000 */   nop
/* 105C28 802E43A8 0C04417A */  jal       get_entity_by_index
/* 105C2C 802E43AC 0040202D */   daddu    $a0, $v0, $zero
/* 105C30 802E43B0 9223000B */  lbu       $v1, 0xB($s1)
/* 105C34 802E43B4 0040802D */  daddu     $s0, $v0, $zero
/* 105C38 802E43B8 A203000B */  sb        $v1, 0xB($s0)
/* 105C3C 802E43BC 8E220000 */  lw        $v0, 0x0($s1)
/* 105C40 802E43C0 30420001 */  andi      $v0, $v0, 0x1
/* 105C44 802E43C4 14400005 */  bnez      $v0, .L802E43DC
/* 105C48 802E43C8 24020020 */   addiu    $v0, $zero, 0x20
/* 105C4C 802E43CC 9222000B */  lbu       $v0, 0xB($s1)
/* 105C50 802E43D0 2C4200FF */  sltiu     $v0, $v0, 0xFF
/* 105C54 802E43D4 10400002 */  beqz      $v0, .L802E43E0
/* 105C58 802E43D8 24020020 */   addiu    $v0, $zero, 0x20
.L802E43DC:
/* 105C5C 802E43DC A202000B */  sb        $v0, 0xB($s0)
.L802E43E0:
/* 105C60 802E43E0 8E220000 */  lw        $v0, 0x0($s1)
/* 105C64 802E43E4 3C030004 */  lui       $v1, (0x40000 >> 16)
/* 105C68 802E43E8 00431024 */  and       $v0, $v0, $v1
/* 105C6C 802E43EC 10400004 */  beqz      $v0, .L802E4400
/* 105C70 802E43F0 00000000 */   nop
/* 105C74 802E43F4 8E020000 */  lw        $v0, 0x0($s0)
/* 105C78 802E43F8 00431025 */  or        $v0, $v0, $v1
/* 105C7C 802E43FC AE020000 */  sw        $v0, 0x0($s0)
.L802E4400:
/* 105C80 802E4400 8E020040 */  lw        $v0, 0x40($s0)
/* 105C84 802E4404 A4520012 */  sh        $s2, 0x12($v0)
/* 105C88 802E4408 8E220000 */  lw        $v0, 0x0($s1)
/* 105C8C 802E440C 30420004 */  andi      $v0, $v0, 0x4
/* 105C90 802E4410 10400004 */  beqz      $v0, .L802E4424
/* 105C94 802E4414 2403FEFF */   addiu    $v1, $zero, -0x101
/* 105C98 802E4418 8E020000 */  lw        $v0, 0x0($s0)
/* 105C9C 802E441C 34420004 */  ori       $v0, $v0, 0x4
/* 105CA0 802E4420 AE020000 */  sw        $v0, 0x0($s0)
.L802E4424:
/* 105CA4 802E4424 8E220000 */  lw        $v0, 0x0($s1)
/* 105CA8 802E4428 86240016 */  lh        $a0, 0x16($s1)
/* 105CAC 802E442C 00431024 */  and       $v0, $v0, $v1
/* 105CB0 802E4430 0C044181 */  jal       get_shadow_by_index
/* 105CB4 802E4434 AE220000 */   sw       $v0, 0x0($s1)
/* 105CB8 802E4438 0040282D */  daddu     $a1, $v0, $zero
/* 105CBC 802E443C 3C031000 */  lui       $v1, (0x10000001 >> 16)
/* 105CC0 802E4440 8CA20000 */  lw        $v0, 0x0($a1)
/* 105CC4 802E4444 34630001 */  ori       $v1, $v1, (0x10000001 & 0xFFFF)
/* 105CC8 802E4448 00431025 */  or        $v0, $v0, $v1
/* 105CCC 802E444C ACA20000 */  sw        $v0, 0x0($a1)
/* 105CD0 802E4450 0C044181 */  jal       get_shadow_by_index
/* 105CD4 802E4454 86040016 */   lh       $a0, 0x16($s0)
/* 105CD8 802E4458 0040282D */  daddu     $a1, $v0, $zero
/* 105CDC 802E445C 8CA20000 */  lw        $v0, 0x0($a1)
/* 105CE0 802E4460 3C030040 */  lui       $v1, (0x400000 >> 16)
/* 105CE4 802E4464 00431025 */  or        $v0, $v0, $v1
/* 105CE8 802E4468 ACA20000 */  sw        $v0, 0x0($a1)
/* 105CEC 802E446C 8FBF0024 */  lw        $ra, 0x24($sp)
/* 105CF0 802E4470 8FB20020 */  lw        $s2, 0x20($sp)
/* 105CF4 802E4474 8FB1001C */  lw        $s1, 0x1C($sp)
/* 105CF8 802E4478 8FB00018 */  lw        $s0, 0x18($sp)
/* 105CFC 802E447C 03E00008 */  jr        $ra
/* 105D00 802E4480 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

void entity_ItemBlock_replace_with_inactive(Entity* entity) {
    s32 entityType = get_entity_type(entity->listIndex);
    EntityBlueprint* bp = &Entity_InertYellowBlock;
    s32 childEntityIndex;
    s32 isBlockOnGround;
    s32 parentEntityType;
    BlockData* childData;
    Entity* childEntity;
    Shadow* shadow;

    if (entityType < ENTITY_TYPE_HAMMER1_BLOCK) {
        bp = &Entity_InertYellowBlock;
        if (entityType >= ENTITY_TYPE_HIDDEN_RED_BLOCK) {
            bp = &Entity_InertRedBlock;
        }
    }

    // this child entity is the inert block
    childEntityIndex = create_entity(bp, (s32)entity->position.x, (s32)entity->position.y, (s32)entity->position.z, (s32)entity->rotation.y, MAKE_ENTITY_END);
    childEntity = get_entity_by_index(childEntityIndex);
    childEntity->flags |= ENTITY_FLAG_HIDDEN;

    if (entity->flags & ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2) {
        childEntity->flags |= ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2;
    }

    if (entity->flags & ENTITY_FLAG_HAS_DYNAMIC_SHADOW) {
        childEntity->flags |= ENTITY_FLAG_HAS_DYNAMIC_SHADOW;
    }

    shadow = get_shadow_by_index(childEntity->shadowIndex);
    shadow->flags |= (ENTITY_FLAG_SHADOW_POS_DIRTY | ENTITY_FLAG_HIDDEN);
    isBlockOnGround = is_block_on_ground(entity);

    parentEntityType = get_entity_type(entity->listIndex);
    if (parentEntityType == ENTITY_TYPE_HIDDEN_RED_BLOCK || parentEntityType == ENTITY_TYPE_RED_BLOCK) {
        bp = &Entity_HitRedBlock;
    } else if (isBlockOnGround != 0) {
        bp = &Entity_HitGroundedYellowBlock;
    } else {
        bp = &Entity_HitFloatingYellowBlock;
    }

    // child entity is now the animated block which appears before it turns inert
    childEntity = get_entity_by_index(create_entity(bp, (s32)entity->position.x, (s32)entity->position.y, (s32)entity->position.z, (s32)entity->rotation.y, MAKE_ENTITY_END));
    childEntity->alpha = entity->alpha;
    if ((entity->flags & ENTITY_FLAG_HIDDEN) || (entity->alpha < 255)) {
        childEntity->alpha = 32;
    }

    if (entity->flags & ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2) {
        childEntity->flags |= ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2;
    }

    childData = childEntity->dataBuf.block;
    childData->childEntityIndex = childEntityIndex;

    if (entity->flags & ENTITY_FLAG_HAS_DYNAMIC_SHADOW) {
        childEntity->flags |= ENTITY_FLAG_HAS_DYNAMIC_SHADOW;
    }

    entity->flags &= ~ENTITY_FLAG_HAS_SHADOW;
    shadow = get_shadow_by_index(entity->shadowIndex);
    shadow->flags |= (ENTITY_FLAG_FADING_AWAY | ENTITY_FLAG_HIDDEN);
    shadow = get_shadow_by_index(childEntity->shadowIndex);
    shadow->flags |= ENTITY_FLAG_SHADOW_POS_DIRTY;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel butterflies_update
/* 3AAA2C E00AA10C 27BDFFC8 */  addiu     $sp, $sp, -0x38
/* 3AAA30 E00AA110 AFBF0014 */  sw        $ra, 0x14($sp)
/* 3AAA34 E00AA114 AFB00010 */  sw        $s0, 0x10($sp)
/* 3AAA38 E00AA118 F7BA0030 */  sdc1      $f26, 0x30($sp)
/* 3AAA3C E00AA11C F7B80028 */  sdc1      $f24, 0x28($sp)
/* 3AAA40 E00AA120 F7B60020 */  sdc1      $f22, 0x20($sp)
/* 3AAA44 E00AA124 F7B40018 */  sdc1      $f20, 0x18($sp)
/* 3AAA48 E00AA128 8C830000 */  lw        $v1, 0x0($a0)
/* 3AAA4C E00AA12C 8C90000C */  lw        $s0, 0xC($a0)
/* 3AAA50 E00AA130 30620010 */  andi      $v0, $v1, 0x10
/* 3AAA54 E00AA134 10400005 */  beqz      $v0, .LE00AA14C
/* 3AAA58 E00AA138 2402FFEF */   addiu    $v0, $zero, -0x11
/* 3AAA5C E00AA13C 00621024 */  and       $v0, $v1, $v0
/* 3AAA60 E00AA140 AC820000 */  sw        $v0, 0x0($a0)
/* 3AAA64 E00AA144 24020384 */  addiu     $v0, $zero, 0x384
/* 3AAA68 E00AA148 AE020004 */  sw        $v0, 0x4($s0)
.LE00AA14C:
/* 3AAA6C E00AA14C 8E030004 */  lw        $v1, 0x4($s0)
/* 3AAA70 E00AA150 286203E8 */  slti      $v0, $v1, 0x3E8
/* 3AAA74 E00AA154 10400002 */  beqz      $v0, .LE00AA160
/* 3AAA78 E00AA158 2462FFFF */   addiu    $v0, $v1, -0x1
/* 3AAA7C E00AA15C AE020004 */  sw        $v0, 0x4($s0)
.LE00AA160:
/* 3AAA80 E00AA160 8E020008 */  lw        $v0, 0x8($s0)
/* 3AAA84 E00AA164 8E030004 */  lw        $v1, 0x4($s0)
/* 3AAA88 E00AA168 24420001 */  addiu     $v0, $v0, 0x1
/* 3AAA8C E00AA16C 04610005 */  bgez      $v1, .LE00AA184
/* 3AAA90 E00AA170 AE020008 */   sw       $v0, 0x8($s0)
/* 3AAA94 E00AA174 0C080128 */  jal       shim_remove_effect
/* 3AAA98 E00AA178 00000000 */   nop
/* 3AAA9C E00AA17C 0802A8E8 */  j         .LE00AA3A0
/* 3AAAA0 E00AA180 00000000 */   nop
.LE00AA184:
/* 3AAAA4 E00AA184 28620010 */  slti      $v0, $v1, 0x10
/* 3AAAA8 E00AA188 10400002 */  beqz      $v0, .LE00AA194
/* 3AAAAC E00AA18C 00031100 */   sll      $v0, $v1, 4
/* 3AAAB0 E00AA190 AE020024 */  sw        $v0, 0x24($s0)
.LE00AA194:
/* 3AAAB4 E00AA194 8E020030 */  lw        $v0, 0x30($s0)
/* 3AAAB8 E00AA198 2442FFFF */  addiu     $v0, $v0, -0x1
/* 3AAABC E00AA19C 1C40006D */  bgtz      $v0, .LE00AA354
/* 3AAAC0 E00AA1A0 AE020030 */   sw       $v0, 0x30($s0)
/* 3AAAC4 E00AA1A4 0C080138 */  jal       shim_rand_int
/* 3AAAC8 E00AA1A8 24040167 */   addiu    $a0, $zero, 0x167
/* 3AAACC E00AA1AC 4482A000 */  mtc1      $v0, $f20
/* 3AAAD0 E00AA1B0 00000000 */  nop
/* 3AAAD4 E00AA1B4 4680A520 */  cvt.s.w   $f20, $f20
/* 3AAAD8 E00AA1B8 0C080140 */  jal       shim_sin_deg
/* 3AAADC E00AA1BC 4600A306 */   mov.s    $f12, $f20
/* 3AAAE0 E00AA1C0 C6020034 */  lwc1      $f2, 0x34($s0)
/* 3AAAE4 E00AA1C4 46001082 */  mul.s     $f2, $f2, $f0
/* 3AAAE8 E00AA1C8 00000000 */  nop
/* 3AAAEC E00AA1CC C6000038 */  lwc1      $f0, 0x38($s0)
/* 3AAAF0 E00AA1D0 C6180018 */  lwc1      $f24, 0x18($s0)
/* 3AAAF4 E00AA1D4 4600028D */  trunc.w.s $f10, $f0
/* 3AAAF8 E00AA1D8 44045000 */  mfc1      $a0, $f10
/* 3AAAFC E00AA1DC 0C080138 */  jal       shim_rand_int
/* 3AAB00 E00AA1E0 4602C600 */   add.s    $f24, $f24, $f2
/* 3AAB04 E00AA1E4 4600A306 */  mov.s     $f12, $f20
/* 3AAB08 E00AA1E8 C616001C */  lwc1      $f22, 0x1C($s0)
/* 3AAB0C E00AA1EC 44820000 */  mtc1      $v0, $f0
/* 3AAB10 E00AA1F0 00000000 */  nop
/* 3AAB14 E00AA1F4 46800020 */  cvt.s.w   $f0, $f0
/* 3AAB18 E00AA1F8 0C080144 */  jal       shim_cos_deg
/* 3AAB1C E00AA1FC 4600B580 */   add.s    $f22, $f22, $f0
/* 3AAB20 E00AA200 C6020034 */  lwc1      $f2, 0x34($s0)
/* 3AAB24 E00AA204 46001082 */  mul.s     $f2, $f2, $f0
/* 3AAB28 E00AA208 00000000 */  nop
/* 3AAB2C E00AA20C C6140020 */  lwc1      $f20, 0x20($s0)
/* 3AAB30 E00AA210 24040064 */  addiu     $a0, $zero, 0x64
/* 3AAB34 E00AA214 0C080138 */  jal       shim_rand_int
/* 3AAB38 E00AA218 4602A500 */   add.s    $f20, $f20, $f2
/* 3AAB3C E00AA21C C604000C */  lwc1      $f4, 0xC($s0)
/* 3AAB40 E00AA220 4604C601 */  sub.s     $f24, $f24, $f4
/* 3AAB44 E00AA224 C6060010 */  lwc1      $f6, 0x10($s0)
/* 3AAB48 E00AA228 4606B581 */  sub.s     $f22, $f22, $f6
/* 3AAB4C E00AA22C C6080014 */  lwc1      $f8, 0x14($s0)
/* 3AAB50 E00AA230 44801000 */  mtc1      $zero, $f2
/* 3AAB54 E00AA234 4608A501 */  sub.s     $f20, $f20, $f8
/* 3AAB58 E00AA238 2442000A */  addiu     $v0, $v0, 0xA
/* 3AAB5C E00AA23C 4602C032 */  c.eq.s    $f24, $f2
/* 3AAB60 E00AA240 00000000 */  nop
/* 3AAB64 E00AA244 4500001E */  bc1f      .LE00AA2C0
/* 3AAB68 E00AA248 AE020030 */   sw       $v0, 0x30($s0)
/* 3AAB6C E00AA24C 4602B032 */  c.eq.s    $f22, $f2
/* 3AAB70 E00AA250 00000000 */  nop
/* 3AAB74 E00AA254 4500001A */  bc1f      .LE00AA2C0
/* 3AAB78 E00AA258 00000000 */   nop
/* 3AAB7C E00AA25C 4602A032 */  c.eq.s    $f20, $f2
/* 3AAB80 E00AA260 00000000 */  nop
/* 3AAB84 E00AA264 45000016 */  bc1f      .LE00AA2C0
/* 3AAB88 E00AA268 00000000 */   nop
/* 3AAB8C E00AA26C C6000018 */  lwc1      $f0, 0x18($s0)
/* 3AAB90 E00AA270 46040601 */  sub.s     $f24, $f0, $f4
/* 3AAB94 E00AA274 C600001C */  lwc1      $f0, 0x1C($s0)
/* 3AAB98 E00AA278 46060581 */  sub.s     $f22, $f0, $f6
/* 3AAB9C E00AA27C C6000020 */  lwc1      $f0, 0x20($s0)
/* 3AABA0 E00AA280 4602C032 */  c.eq.s    $f24, $f2
/* 3AABA4 E00AA284 00000000 */  nop
/* 3AABA8 E00AA288 4500000D */  bc1f      .LE00AA2C0
/* 3AABAC E00AA28C 46080501 */   sub.s    $f20, $f0, $f8
/* 3AABB0 E00AA290 4602B032 */  c.eq.s    $f22, $f2
/* 3AABB4 E00AA294 00000000 */  nop
/* 3AABB8 E00AA298 45000009 */  bc1f      .LE00AA2C0
/* 3AABBC E00AA29C 00000000 */   nop
/* 3AABC0 E00AA2A0 4602A032 */  c.eq.s    $f20, $f2
/* 3AABC4 E00AA2A4 00000000 */  nop
/* 3AABC8 E00AA2A8 45000005 */  bc1f      .LE00AA2C0
/* 3AABCC E00AA2AC 00000000 */   nop
/* 3AABD0 E00AA2B0 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 3AABD4 E00AA2B4 4481C000 */  mtc1      $at, $f24
/* 3AABD8 E00AA2B8 46001506 */  mov.s     $f20, $f2
/* 3AABDC E00AA2BC 46001586 */  mov.s     $f22, $f2
.LE00AA2C0:
/* 3AABE0 E00AA2C0 4618C002 */  mul.s     $f0, $f24, $f24
/* 3AABE4 E00AA2C4 00000000 */  nop
/* 3AABE8 E00AA2C8 4616B082 */  mul.s     $f2, $f22, $f22
/* 3AABEC E00AA2CC 00000000 */  nop
/* 3AABF0 E00AA2D0 4614A102 */  mul.s     $f4, $f20, $f20
/* 3AABF4 E00AA2D4 00000000 */  nop
/* 3AABF8 E00AA2D8 46020000 */  add.s     $f0, $f0, $f2
/* 3AABFC E00AA2DC 46040300 */  add.s     $f12, $f0, $f4
/* 3AAC00 E00AA2E0 4480D000 */  mtc1      $zero, $f26
/* 3AAC04 E00AA2E4 00000000 */  nop
/* 3AAC08 E00AA2E8 461A6032 */  c.eq.s    $f12, $f26
/* 3AAC0C E00AA2EC 00000000 */  nop
/* 3AAC10 E00AA2F0 45010007 */  bc1t      .LE00AA310
/* 3AAC14 E00AA2F4 00000000 */   nop
/* 3AAC18 E00AA2F8 0C080154 */  jal       shim_sqrtf
/* 3AAC1C E00AA2FC 00000000 */   nop
/* 3AAC20 E00AA300 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 3AAC24 E00AA304 44811000 */  mtc1      $at, $f2
/* 3AAC28 E00AA308 00000000 */  nop
/* 3AAC2C E00AA30C 46001303 */  div.s     $f12, $f2, $f0
.LE00AA310:
/* 3AAC30 E00AA310 460CC602 */  mul.s     $f24, $f24, $f12
/* 3AAC34 E00AA314 00000000 */  nop
/* 3AAC38 E00AA318 460CA502 */  mul.s     $f20, $f20, $f12
/* 3AAC3C E00AA31C 00000000 */  nop
/* 3AAC40 E00AA320 460CB582 */  mul.s     $f22, $f22, $f12
/* 3AAC44 E00AA324 00000000 */  nop
/* 3AAC48 E00AA328 4600D306 */  mov.s     $f12, $f26
/* 3AAC4C E00AA32C E618003C */  swc1      $f24, 0x3C($s0)
/* 3AAC50 E00AA330 4600C006 */  mov.s     $f0, $f24
/* 3AAC54 E00AA334 4407A000 */  mfc1      $a3, $f20
/* 3AAC58 E00AA338 46000007 */  neg.s     $f0, $f0
/* 3AAC5C E00AA33C 44060000 */  mfc1      $a2, $f0
/* 3AAC60 E00AA340 46006386 */  mov.s     $f14, $f12
/* 3AAC64 E00AA344 E6160040 */  swc1      $f22, 0x40($s0)
/* 3AAC68 E00AA348 0C080148 */  jal       shim_atan2
/* 3AAC6C E00AA34C E6140044 */   swc1     $f20, 0x44($s0)
/* 3AAC70 E00AA350 E6000028 */  swc1      $f0, 0x28($s0)
.LE00AA354:
/* 3AAC74 E00AA354 8E03002C */  lw        $v1, 0x2C($s0)
/* 3AAC78 E00AA358 24620003 */  addiu     $v0, $v1, 0x3
/* 3AAC7C E00AA35C AE02002C */  sw        $v0, 0x2C($s0)
/* 3AAC80 E00AA360 2842001E */  slti      $v0, $v0, 0x1E
/* 3AAC84 E00AA364 14400002 */  bnez      $v0, .LE00AA370
/* 3AAC88 E00AA368 2462FFE5 */   addiu    $v0, $v1, -0x1B
/* 3AAC8C E00AA36C AE02002C */  sw        $v0, 0x2C($s0)
.LE00AA370:
/* 3AAC90 E00AA370 C606000C */  lwc1      $f6, 0xC($s0)
/* 3AAC94 E00AA374 C600003C */  lwc1      $f0, 0x3C($s0)
/* 3AAC98 E00AA378 C6040010 */  lwc1      $f4, 0x10($s0)
/* 3AAC9C E00AA37C 46003180 */  add.s     $f6, $f6, $f0
/* 3AACA0 E00AA380 C6000040 */  lwc1      $f0, 0x40($s0)
/* 3AACA4 E00AA384 C6020014 */  lwc1      $f2, 0x14($s0)
/* 3AACA8 E00AA388 46002100 */  add.s     $f4, $f4, $f0
/* 3AACAC E00AA38C C6000044 */  lwc1      $f0, 0x44($s0)
/* 3AACB0 E00AA390 46001080 */  add.s     $f2, $f2, $f0
/* 3AACB4 E00AA394 E606000C */  swc1      $f6, 0xC($s0)
/* 3AACB8 E00AA398 E6040010 */  swc1      $f4, 0x10($s0)
/* 3AACBC E00AA39C E6020014 */  swc1      $f2, 0x14($s0)
.LE00AA3A0:
/* 3AACC0 E00AA3A0 8FBF0014 */  lw        $ra, 0x14($sp)
/* 3AACC4 E00AA3A4 8FB00010 */  lw        $s0, 0x10($sp)
/* 3AACC8 E00AA3A8 D7BA0030 */  ldc1      $f26, 0x30($sp)
/* 3AACCC E00AA3AC D7B80028 */  ldc1      $f24, 0x28($sp)
/* 3AACD0 E00AA3B0 D7B60020 */  ldc1      $f22, 0x20($sp)
/* 3AACD4 E00AA3B4 D7B40018 */  ldc1      $f20, 0x18($sp)
/* 3AACD8 E00AA3B8 03E00008 */  jr        $ra
/* 3AACDC E00AA3BC 27BD0038 */   addiu    $sp, $sp, 0x38

### DECOMPILED C INSTRUCTIONS:

void butterflies_update(EffectInstance* effect) {
    ButterfliesFXData* temp_s0;
    f32 temp_f20;
    f32 temp_f20_2;
    f32 temp_f22;
    f32 temp_f24;
    f32 temp_f4;
    f32 temp_f6;
    f32 temp_f8;
    f32 var_f12;
    f32 var_f20;
    f32 var_f22;
    f32 var_f24;

    temp_s0 = effect->data.butterflies;
    if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
        effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
        temp_s0->unk_04 = 900;
    }

    if (temp_s0->unk_04 < 1000) {
        temp_s0->unk_04--;
    }
    temp_s0->unk_08 += 1;
    if (temp_s0->unk_04 < 0) {
        shim_remove_effect(effect);
        return;
    }
    if (temp_s0->unk_04 < 0x10) {
        temp_s0->unk_24 = temp_s0->unk_04 * 0x10;
    }

    temp_s0->unk_30--;
    if (temp_s0->unk_30 <= 0) {
        s32 t;

        temp_f20 = shim_rand_int(359);
        temp_f24 = temp_s0->unk_18 + (temp_s0->unk_34 * shim_sin_deg(temp_f20));
        temp_f22 = temp_s0->unk_1C + shim_rand_int(temp_s0->unk_38);
        temp_f20_2 = temp_s0->unk_20 + (temp_s0->unk_34 * shim_cos_deg(temp_f20));
        t = shim_rand_int(100) + 10;
        temp_f4 = temp_s0->unk_0C;
        temp_f6 = temp_s0->unk_10;
        temp_f8 = temp_s0->unk_14;
        var_f24 = temp_f24 - temp_f4;
        var_f22 = temp_f22 - temp_f6;
        var_f20 = temp_f20_2 - temp_f8;
        temp_s0->unk_30 = t;
        if (var_f24 == 0.0f && var_f22 == 0.0f && var_f20 == 0.0f) {
            var_f24 = temp_s0->unk_18 - temp_f4;
            var_f22 = temp_s0->unk_1C - temp_f6;
            var_f20 = temp_s0->unk_20 - temp_f8;
            if (var_f24 == 0.0f && var_f22 == 0.0f && var_f20 == 0.0f) {
                var_f24 = 1.0f;
                var_f20 = 0.0f;
                var_f22 = 0.0f;
            }
        }
        var_f12 = SQ(var_f24) + SQ(var_f22) + SQ(var_f20);
        if (var_f12 != 0.0f) {
            var_f12 = 1.0f / shim_sqrtf(var_f12);
        }
        var_f24 *= var_f12;
        var_f22 *= var_f12;
        var_f20 *= var_f12;
        temp_s0->unk_3C = var_f24;
        temp_s0->unk_40 = var_f22;
        temp_s0->unk_44 = var_f20;
        temp_s0->unk_28 = shim_atan2(0.0f, 0.0f, -temp_s0->unk_3C, temp_s0->unk_44);
    }
    temp_s0->unk_2C += 3;
    if (temp_s0->unk_2C >= 30) {
        temp_s0->unk_2C -= 30;
    }
    temp_s0->unk_0C += temp_s0->unk_3C;
    temp_s0->unk_10 += temp_s0->unk_40;
    temp_s0->unk_14 += temp_s0->unk_44;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel FallToGoal
/* 1A84CC 80279BEC 27BDFFA8 */  addiu     $sp, $sp, -0x58
/* 1A84D0 80279BF0 AFB20020 */  sw        $s2, 0x20($sp)
/* 1A84D4 80279BF4 0080902D */  daddu     $s2, $a0, $zero
/* 1A84D8 80279BF8 AFBF0024 */  sw        $ra, 0x24($sp)
/* 1A84DC 80279BFC AFB1001C */  sw        $s1, 0x1C($sp)
/* 1A84E0 80279C00 AFB00018 */  sw        $s0, 0x18($sp)
/* 1A84E4 80279C04 F7BE0050 */  sdc1      $f30, 0x50($sp)
/* 1A84E8 80279C08 F7BC0048 */  sdc1      $f28, 0x48($sp)
/* 1A84EC 80279C0C F7BA0040 */  sdc1      $f26, 0x40($sp)
/* 1A84F0 80279C10 F7B80038 */  sdc1      $f24, 0x38($sp)
/* 1A84F4 80279C14 F7B60030 */  sdc1      $f22, 0x30($sp)
/* 1A84F8 80279C18 F7B40028 */  sdc1      $f20, 0x28($sp)
/* 1A84FC 80279C1C 8E51000C */  lw        $s1, 0xC($s2)
/* 1A8500 80279C20 54A00001 */  bnel      $a1, $zero, .L80279C28
/* 1A8504 80279C24 AE400070 */   sw       $zero, 0x70($s2)
.L80279C28:
/* 1A8508 80279C28 8E420070 */  lw        $v0, 0x70($s2)
/* 1A850C 80279C2C 1440005A */  bnez      $v0, .L80279D98
/* 1A8510 80279C30 00000000 */   nop
/* 1A8514 80279C34 8E250000 */  lw        $a1, 0x0($s1)
/* 1A8518 80279C38 26310004 */  addiu     $s1, $s1, 0x4
/* 1A851C 80279C3C 0C0B1EAF */  jal       evt_get_variable
/* 1A8520 80279C40 0240202D */   daddu    $a0, $s2, $zero
/* 1A8524 80279C44 0040202D */  daddu     $a0, $v0, $zero
/* 1A8528 80279C48 2402FF81 */  addiu     $v0, $zero, -0x7F
/* 1A852C 80279C4C 14820002 */  bne       $a0, $v0, .L80279C58
/* 1A8530 80279C50 00000000 */   nop
/* 1A8534 80279C54 8E440148 */  lw        $a0, 0x148($s2)
.L80279C58:
/* 1A8538 80279C58 0C09A75B */  jal       get_actor
/* 1A853C 80279C5C 00000000 */   nop
/* 1A8540 80279C60 0040802D */  daddu     $s0, $v0, $zero
/* 1A8544 80279C64 AE500074 */  sw        $s0, 0x74($s2)
/* 1A8548 80279C68 8E250000 */  lw        $a1, 0x0($s1)
/* 1A854C 80279C6C 0C0B1EAF */  jal       evt_get_variable
/* 1A8550 80279C70 0240202D */   daddu    $a0, $s2, $zero
/* 1A8554 80279C74 C6000148 */  lwc1      $f0, 0x148($s0)
/* 1A8558 80279C78 C61A0018 */  lwc1      $f26, 0x18($s0)
/* 1A855C 80279C7C C61C0020 */  lwc1      $f28, 0x20($s0)
/* 1A8560 80279C80 C614014C */  lwc1      $f20, 0x14C($s0)
/* 1A8564 80279C84 C618001C */  lwc1      $f24, 0x1C($s0)
/* 1A8568 80279C88 A6020070 */  sh        $v0, 0x70($s0)
/* 1A856C 80279C8C E6000010 */  swc1      $f0, 0x10($s0)
/* 1A8570 80279C90 46000786 */  mov.s     $f30, $f0
/* 1A8574 80279C94 4406D000 */  mfc1      $a2, $f26
/* 1A8578 80279C98 4407E000 */  mfc1      $a3, $f28
/* 1A857C 80279C9C C6000144 */  lwc1      $f0, 0x144($s0)
/* 1A8580 80279CA0 4600A386 */  mov.s     $f14, $f20
/* 1A8584 80279CA4 E6140014 */  swc1      $f20, 0x14($s0)
/* 1A8588 80279CA8 E600000C */  swc1      $f0, 0xC($s0)
/* 1A858C 80279CAC 46000586 */  mov.s     $f22, $f0
/* 1A8590 80279CB0 0C00A720 */  jal       atan2
/* 1A8594 80279CB4 4600B306 */   mov.s    $f12, $f22
/* 1A8598 80279CB8 4600B306 */  mov.s     $f12, $f22
/* 1A859C 80279CBC 4600A386 */  mov.s     $f14, $f20
/* 1A85A0 80279CC0 4406D000 */  mfc1      $a2, $f26
/* 1A85A4 80279CC4 4407E000 */  mfc1      $a3, $f28
/* 1A85A8 80279CC8 461EC781 */  sub.s     $f30, $f24, $f30
/* 1A85AC 80279CCC 0C00A7B5 */  jal       dist2D
/* 1A85B0 80279CD0 E6000054 */   swc1     $f0, 0x54($s0)
/* 1A85B4 80279CD4 46000086 */  mov.s     $f2, $f0
/* 1A85B8 80279CD8 86020070 */  lh        $v0, 0x70($s0)
/* 1A85BC 80279CDC 2611000C */  addiu     $s1, $s0, 0xC
/* 1A85C0 80279CE0 14400007 */  bnez      $v0, .L80279D00
/* 1A85C4 80279CE4 E6020058 */   swc1     $f2, 0x58($s0)
/* 1A85C8 80279CE8 C600004C */  lwc1      $f0, 0x4C($s0)
/* 1A85CC 80279CEC 46001003 */  div.s     $f0, $f2, $f0
/* 1A85D0 80279CF0 4600018D */  trunc.w.s $f6, $f0
/* 1A85D4 80279CF4 44023000 */  mfc1      $v0, $f6
/* 1A85D8 80279CF8 0809E745 */  j         .L80279D14
/* 1A85DC 80279CFC A6020070 */   sh       $v0, 0x70($s0)
.L80279D00:
/* 1A85E0 80279D00 44820000 */  mtc1      $v0, $f0
/* 1A85E4 80279D04 00000000 */  nop
/* 1A85E8 80279D08 46800020 */  cvt.s.w   $f0, $f0
/* 1A85EC 80279D0C 46001003 */  div.s     $f0, $f2, $f0
/* 1A85F0 80279D10 E600004C */  swc1      $f0, 0x4C($s0)
.L80279D14:
/* 1A85F4 80279D14 86230064 */  lh        $v1, 0x64($s1)
/* 1A85F8 80279D18 3C013FE0 */  lui       $at, (0x3FE00000 >> 16)
/* 1A85FC 80279D1C 44810800 */  mtc1      $at, $f1
/* 1A8600 80279D20 44800000 */  mtc1      $zero, $f0
/* 1A8604 80279D24 00031023 */  negu      $v0, $v1
/* 1A8608 80279D28 44821000 */  mtc1      $v0, $f2
/* 1A860C 80279D2C 00000000 */  nop
/* 1A8610 80279D30 468010A1 */  cvt.d.w   $f2, $f2
/* 1A8614 80279D34 46201082 */  mul.d     $f2, $f2, $f0
/* 1A8618 80279D38 00000000 */  nop
/* 1A861C 80279D3C AE200044 */  sw        $zero, 0x44($s1)
/* 1A8620 80279D40 C6240044 */  lwc1      $f4, 0x44($s1)
/* 1A8624 80279D44 44830000 */  mtc1      $v1, $f0
/* 1A8628 80279D48 00000000 */  nop
/* 1A862C 80279D4C 46800020 */  cvt.s.w   $f0, $f0
/* 1A8630 80279D50 4600F003 */  div.s     $f0, $f30, $f0
/* 1A8634 80279D54 46040001 */  sub.s     $f0, $f0, $f4
/* 1A8638 80279D58 46000021 */  cvt.d.s   $f0, $f0
/* 1A863C 80279D5C 46220003 */  div.d     $f0, $f0, $f2
/* 1A8640 80279D60 46200020 */  cvt.s.d   $f0, $f0
/* 1A8644 80279D64 E620003C */  swc1      $f0, 0x3C($s1)
/* 1A8648 80279D68 8E0201AC */  lw        $v0, 0x1AC($s0)
/* 1A864C 80279D6C 10400009 */  beqz      $v0, .L80279D94
/* 1A8650 80279D70 24020001 */   addiu    $v0, $zero, 0x1
/* 1A8654 80279D74 C600014C */  lwc1      $f0, 0x14C($s0)
/* 1A8658 80279D78 E7A00010 */  swc1      $f0, 0x10($sp)
/* 1A865C 80279D7C 8E0401AC */  lw        $a0, 0x1AC($s0)
/* 1A8660 80279D80 8E060144 */  lw        $a2, 0x144($s0)
/* 1A8664 80279D84 8E070148 */  lw        $a3, 0x148($s0)
/* 1A8668 80279D88 0C052757 */  jal       sfx_play_sound_at_position
/* 1A866C 80279D8C 0000282D */   daddu    $a1, $zero, $zero
/* 1A8670 80279D90 24020001 */  addiu     $v0, $zero, 0x1
.L80279D94:
/* 1A8674 80279D94 AE420070 */  sw        $v0, 0x70($s2)
.L80279D98:
/* 1A8678 80279D98 8E500074 */  lw        $s0, 0x74($s2)
/* 1A867C 80279D9C C6040010 */  lwc1      $f4, 0x10($s0)
/* 1A8680 80279DA0 C6000050 */  lwc1      $f0, 0x50($s0)
/* 1A8684 80279DA4 8E05004C */  lw        $a1, 0x4C($s0)
/* 1A8688 80279DA8 46002100 */  add.s     $f4, $f4, $f0
/* 1A868C 80279DAC C6020048 */  lwc1      $f2, 0x48($s0)
/* 1A8690 80279DB0 8E060054 */  lw        $a2, 0x54($s0)
/* 1A8694 80279DB4 46020001 */  sub.s     $f0, $f0, $f2
/* 1A8698 80279DB8 2604000C */  addiu     $a0, $s0, 0xC
/* 1A869C 80279DBC E6040010 */  swc1      $f4, 0x10($s0)
/* 1A86A0 80279DC0 0C09904A */  jal       add_xz_vec3f
/* 1A86A4 80279DC4 E6000050 */   swc1     $f0, 0x50($s0)
/* 1A86A8 80279DC8 C600000C */  lwc1      $f0, 0xC($s0)
/* 1A86AC 80279DCC C6020010 */  lwc1      $f2, 0x10($s0)
/* 1A86B0 80279DD0 96020070 */  lhu       $v0, 0x70($s0)
/* 1A86B4 80279DD4 C6040014 */  lwc1      $f4, 0x14($s0)
/* 1A86B8 80279DD8 2442FFFF */  addiu     $v0, $v0, -0x1
/* 1A86BC 80279DDC A6020070 */  sh        $v0, 0x70($s0)
/* 1A86C0 80279DE0 00021400 */  sll       $v0, $v0, 16
/* 1A86C4 80279DE4 E6000144 */  swc1      $f0, 0x144($s0)
/* 1A86C8 80279DE8 E6020148 */  swc1      $f2, 0x148($s0)
/* 1A86CC 80279DEC 18400003 */  blez      $v0, .L80279DFC
/* 1A86D0 80279DF0 E604014C */   swc1     $f4, 0x14C($s0)
/* 1A86D4 80279DF4 0809E78D */  j         .L80279E34
/* 1A86D8 80279DF8 0000102D */   daddu    $v0, $zero, $zero
.L80279DFC:
/* 1A86DC 80279DFC C6000054 */  lwc1      $f0, 0x54($s0)
/* 1A86E0 80279E00 E7A00010 */  swc1      $f0, 0x10($sp)
/* 1A86E4 80279E04 8E050018 */  lw        $a1, 0x18($s0)
/* 1A86E8 80279E08 8E06001C */  lw        $a2, 0x1C($s0)
/* 1A86EC 80279E0C 8E070020 */  lw        $a3, 0x20($s0)
/* 1A86F0 80279E10 0C0990BC */  jal       play_movement_dust_effects
/* 1A86F4 80279E14 24040002 */   addiu    $a0, $zero, 0x2
/* 1A86F8 80279E18 C6000018 */  lwc1      $f0, 0x18($s0)
/* 1A86FC 80279E1C C602001C */  lwc1      $f2, 0x1C($s0)
/* 1A8700 80279E20 C6040020 */  lwc1      $f4, 0x20($s0)
/* 1A8704 80279E24 24020001 */  addiu     $v0, $zero, 0x1
/* 1A8708 80279E28 E6000144 */  swc1      $f0, 0x144($s0)
/* 1A870C 80279E2C E6020148 */  swc1      $f2, 0x148($s0)
/* 1A8710 80279E30 E604014C */  swc1      $f4, 0x14C($s0)
.L80279E34:
/* 1A8714 80279E34 8FBF0024 */  lw        $ra, 0x24($sp)
/* 1A8718 80279E38 8FB20020 */  lw        $s2, 0x20($sp)
/* 1A871C 80279E3C 8FB1001C */  lw        $s1, 0x1C($sp)
/* 1A8720 80279E40 8FB00018 */  lw        $s0, 0x18($sp)
/* 1A8724 80279E44 D7BE0050 */  ldc1      $f30, 0x50($sp)
/* 1A8728 80279E48 D7BC0048 */  ldc1      $f28, 0x48($sp)
/* 1A872C 80279E4C D7BA0040 */  ldc1      $f26, 0x40($sp)
/* 1A8730 80279E50 D7B80038 */  ldc1      $f24, 0x38($sp)
/* 1A8734 80279E54 D7B60030 */  ldc1      $f22, 0x30($sp)
/* 1A8738 80279E58 D7B40028 */  ldc1      $f20, 0x28($sp)
/* 1A873C 80279E5C 03E00008 */  jr        $ra
/* 1A8740 80279E60 27BD0058 */   addiu    $sp, $sp, 0x58

### DECOMPILED C INSTRUCTIONS:

ApiStatus FallToGoal(Evt* script, s32 isInitialCall) {
    Bytecode* args = script->ptrReadPos;
    Actor* actor;
    ActorState* state;
    f32 posX, posY, posZ;
    f32 goalX, goalY, goalZ;

    if (isInitialCall) {
        script->functionTemp[0] = 0;
    }

    if (script->functionTemp[0] == 0) {
        s32 actorID = evt_get_variable(script, *args++);

        if (actorID == ACTOR_SELF) {
            actorID = script->owner1.enemyID;
        }
        actor = get_actor(actorID);
        state = &actor->state;
        script->functionTempPtr[1] = actor;

        actor->state.moveTime = evt_get_variable(script, *args++);

        actor->state.currentPos.x = actor->currentPos.x;
        actor->state.currentPos.y = actor->currentPos.y;
        actor->state.currentPos.z = actor->currentPos.z;

        posX = actor->state.currentPos.x;
        posY = actor->state.currentPos.y;
        posZ = actor->state.currentPos.z;
        goalX = actor->state.goalPos.x;
        goalY = actor->state.goalPos.y;
        goalZ = actor->state.goalPos.z;

        actor->state.angle = atan2(posX, posZ, goalX, goalZ);
        actor->state.distance = dist2D(posX, posZ, goalX, goalZ);

        // make relative
        posX = (goalX - posX);
        posY = (goalY - posY);
        posZ = (goalZ - posZ);

        if (actor->state.moveTime == 0) {
            actor->state.moveTime = actor->state.distance / actor->state.speed;
        } else {
            actor->state.speed = actor->state.distance / actor->state.moveTime;
        }

        state->velocity = 0.0f;
        state->acceleration = (posY / state->moveTime - state->velocity) / (-state->moveTime * 0.5);

        if (actor->actorTypeData1[4] != 0) {
            sfx_play_sound_at_position(actor->actorTypeData1[4], SOUND_SPACE_MODE_0, actor->currentPos.x, actor->currentPos.y, actor->currentPos.z);
        }
        script->functionTemp[0] = 1;
    }

    actor = script->functionTempPtr[1];
    actor->state.currentPos.y += actor->state.velocity;
    actor->state.velocity -= actor->state.acceleration;
    add_xz_vec3f(&actor->state.currentPos, actor->state.speed, actor->state.angle);
    actor->currentPos.x = actor->state.currentPos.x;
    actor->currentPos.y = actor->state.currentPos.y;
    actor->currentPos.z = actor->state.currentPos.z;
    actor->state.moveTime--;

    if (actor->state.moveTime <= 0) {
        play_movement_dust_effects(2, actor->state.goalPos.x, actor->state.goalPos.y, actor->state.goalPos.z, actor->state.angle);
        actor->currentPos.x = actor->state.goalPos.x;
        actor->currentPos.y = actor->state.goalPos.y;
        actor->currentPos.z = actor->state.goalPos.z;
        return ApiStatus_DONE1;
    } else {
        return ApiStatus_BLOCK;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel falling_leaves_update
/* 35EAD4 E00581B4 27BDFFC8 */  addiu     $sp, $sp, -0x38
/* 35EAD8 E00581B8 AFB3001C */  sw        $s3, 0x1C($sp)
/* 35EADC E00581BC 0080982D */  daddu     $s3, $a0, $zero
/* 35EAE0 E00581C0 AFBF0020 */  sw        $ra, 0x20($sp)
/* 35EAE4 E00581C4 AFB20018 */  sw        $s2, 0x18($sp)
/* 35EAE8 E00581C8 AFB10014 */  sw        $s1, 0x14($sp)
/* 35EAEC E00581CC AFB00010 */  sw        $s0, 0x10($sp)
/* 35EAF0 E00581D0 F7B60030 */  sdc1      $f22, 0x30($sp)
/* 35EAF4 E00581D4 F7B40028 */  sdc1      $f20, 0x28($sp)
/* 35EAF8 E00581D8 8E65000C */  lw        $a1, 0xC($s3)
/* 35EAFC E00581DC 8CA2002C */  lw        $v0, 0x2C($a1)
/* 35EB00 E00581E0 8CB20000 */  lw        $s2, 0x0($a1)
/* 35EB04 E00581E4 2442FFFB */  addiu     $v0, $v0, -0x5
/* 35EB08 E00581E8 2C42000A */  sltiu     $v0, $v0, 0xA
/* 35EB0C E00581EC 10400007 */  beqz      $v0, .LE005820C
/* 35EB10 E00581F0 3C020004 */   lui      $v0, (0x4F1A0 >> 16)
/* 35EB14 E00581F4 16400006 */  bnez      $s2, .LE0058210
/* 35EB18 E00581F8 3442F1A0 */   ori      $v0, $v0, (0x4F1A0 & 0xFFFF)
/* 35EB1C E00581FC 3C028011 */  lui       $v0, %hi(gPlayerStatus + 0xB4)
/* 35EB20 E0058200 8042F07C */  lb        $v0, %lo(gPlayerStatus + 0xB4)($v0)
/* 35EB24 E0058204 10400099 */  beqz      $v0, .LE005846C
/* 35EB28 E0058208 3C020004 */   lui      $v0, (0x4F1A0 >> 16)
.LE005820C:
/* 35EB2C E005820C 3442F1A0 */  ori       $v0, $v0, (0x4F1A0 & 0xFFFF)
.LE0058210:
/* 35EB30 E0058210 8CA30028 */  lw        $v1, 0x28($a1)
/* 35EB34 E0058214 8CA4002C */  lw        $a0, 0x2C($a1)
/* 35EB38 E0058218 2463FFFF */  addiu     $v1, $v1, -0x1
/* 35EB3C E005821C 24840001 */  addiu     $a0, $a0, 0x1
/* 35EB40 E0058220 0044102A */  slt       $v0, $v0, $a0
/* 35EB44 E0058224 ACA30028 */  sw        $v1, 0x28($a1)
/* 35EB48 E0058228 10400003 */  beqz      $v0, .LE0058238
/* 35EB4C E005822C ACA4002C */   sw       $a0, 0x2C($a1)
/* 35EB50 E0058230 24020100 */  addiu     $v0, $zero, 0x100
/* 35EB54 E0058234 ACA2002C */  sw        $v0, 0x2C($a1)
.LE0058238:
/* 35EB58 E0058238 8CA40028 */  lw        $a0, 0x28($a1)
/* 35EB5C E005823C 04810005 */  bgez      $a0, .LE0058254
/* 35EB60 E0058240 00000000 */   nop
/* 35EB64 E0058244 0C080128 */  jal       shim_remove_effect
/* 35EB68 E0058248 0260202D */   daddu    $a0, $s3, $zero
/* 35EB6C E005824C 0801611B */  j         .LE005846C
/* 35EB70 E0058250 00000000 */   nop
.LE0058254:
/* 35EB74 E0058254 8CA2002C */  lw        $v0, 0x2C($a1)
/* 35EB78 E0058258 2842000A */  slti      $v0, $v0, 0xA
/* 35EB7C E005825C 10400010 */  beqz      $v0, .LE00582A0
/* 35EB80 E0058260 240200FF */   addiu    $v0, $zero, 0xFF
/* 35EB84 E0058264 8CA30024 */  lw        $v1, 0x24($a1)
/* 35EB88 E0058268 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35EB8C E005826C D4208780 */  ldc1      $f0, -0x7880($at)
/* 35EB90 E0058270 00431023 */  subu      $v0, $v0, $v1
/* 35EB94 E0058274 44821000 */  mtc1      $v0, $f2
/* 35EB98 E0058278 00000000 */  nop
/* 35EB9C E005827C 468010A1 */  cvt.d.w   $f2, $f2
/* 35EBA0 E0058280 46201082 */  mul.d     $f2, $f2, $f0
/* 35EBA4 E0058284 00000000 */  nop
/* 35EBA8 E0058288 44830000 */  mtc1      $v1, $f0
/* 35EBAC E005828C 00000000 */  nop
/* 35EBB0 E0058290 46800021 */  cvt.d.w   $f0, $f0
/* 35EBB4 E0058294 46220000 */  add.d     $f0, $f0, $f2
/* 35EBB8 E0058298 4620020D */  trunc.w.d $f8, $f0
/* 35EBBC E005829C E4A80024 */  swc1      $f8, 0x24($a1)
.LE00582A0:
/* 35EBC0 E00582A0 2882000A */  slti      $v0, $a0, 0xA
/* 35EBC4 E00582A4 10400009 */  beqz      $v0, .LE00582CC
/* 35EBC8 E00582A8 00000000 */   nop
/* 35EBCC E00582AC 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35EBD0 E00582B0 D4228788 */  ldc1      $f2, -0x7878($at)
/* 35EBD4 E00582B4 C4A00024 */  lwc1      $f0, 0x24($a1)
/* 35EBD8 E00582B8 46800021 */  cvt.d.w   $f0, $f0
/* 35EBDC E00582BC 46220002 */  mul.d     $f0, $f0, $f2
/* 35EBE0 E00582C0 00000000 */  nop
/* 35EBE4 E00582C4 4620020D */  trunc.w.d $f8, $f0
/* 35EBE8 E00582C8 E4A80024 */  swc1      $f8, 0x24($a1)
.LE00582CC:
/* 35EBEC E00582CC 8E620008 */  lw        $v0, 0x8($s3)
/* 35EBF0 E00582D0 24110001 */  addiu     $s1, $zero, 0x1
/* 35EBF4 E00582D4 0222102A */  slt       $v0, $s1, $v0
/* 35EBF8 E00582D8 10400064 */  beqz      $v0, .LE005846C
/* 35EBFC E00582DC 24A50034 */   addiu    $a1, $a1, 0x34
/* 35EC00 E00582E0 24B00008 */  addiu     $s0, $a1, 0x8
/* 35EC04 E00582E4 3C01BD4C */  lui       $at, (0xBD4CCCCD >> 16)
/* 35EC08 E00582E8 3421CCCD */  ori       $at, $at, (0xBD4CCCCD & 0xFFFF)
/* 35EC0C E00582EC 4481B000 */  mtc1      $at, $f22
/* 35EC10 E00582F0 3C014120 */  lui       $at, (0x41200000 >> 16)
/* 35EC14 E00582F4 4481A000 */  mtc1      $at, $f20
.LE00582F8:
/* 35EC18 E00582F8 C60C0010 */  lwc1      $f12, 0x10($s0)
/* 35EC1C E00582FC 0C080140 */  jal       shim_sin_deg
/* 35EC20 E0058300 460C6300 */   add.s    $f12, $f12, $f12
/* 35EC24 E0058304 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35EC28 E0058308 D4228790 */  ldc1      $f2, -0x7870($at)
/* 35EC2C E005830C 46000021 */  cvt.d.s   $f0, $f0
/* 35EC30 E0058310 46220002 */  mul.d     $f0, $f0, $f2
/* 35EC34 E0058314 00000000 */  nop
/* 35EC38 E0058318 C602000C */  lwc1      $f2, 0xC($s0)
/* 35EC3C E005831C 46161080 */  add.s     $f2, $f2, $f22
/* 35EC40 E0058320 C6040008 */  lwc1      $f4, 0x8($s0)
/* 35EC44 E0058324 46200020 */  cvt.s.d   $f0, $f0
/* 35EC48 E0058328 46002000 */  add.s     $f0, $f4, $f0
/* 35EC4C E005832C E602000C */  swc1      $f2, 0xC($s0)
/* 35EC50 E0058330 16400019 */  bnez      $s2, .LE0058398
/* 35EC54 E0058334 E6000008 */   swc1     $f0, 0x8($s0)
/* 35EC58 E0058338 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35EC5C E005833C D4228798 */  ldc1      $f2, -0x7868($at)
/* 35EC60 E0058340 46000021 */  cvt.d.s   $f0, $f0
/* 35EC64 E0058344 46220002 */  mul.d     $f0, $f0, $f2
/* 35EC68 E0058348 00000000 */  nop
/* 35EC6C E005834C C60C0010 */  lwc1      $f12, 0x10($s0)
/* 35EC70 E0058350 46200020 */  cvt.s.d   $f0, $f0
/* 35EC74 E0058354 0C080140 */  jal       shim_sin_deg
/* 35EC78 E0058358 E6000008 */   swc1     $f0, 0x8($s0)
/* 35EC7C E005835C 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35EC80 E0058360 D42287A0 */  ldc1      $f2, -0x7860($at)
/* 35EC84 E0058364 46000021 */  cvt.d.s   $f0, $f0
/* 35EC88 E0058368 46220002 */  mul.d     $f0, $f0, $f2
/* 35EC8C E005836C 00000000 */  nop
/* 35EC90 E0058370 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35EC94 E0058374 D42487A8 */  ldc1      $f4, -0x7858($at)
/* 35EC98 E0058378 C602000C */  lwc1      $f2, 0xC($s0)
/* 35EC9C E005837C 46240000 */  add.d     $f0, $f0, $f4
/* 35ECA0 E0058380 460010A1 */  cvt.d.s   $f2, $f2
/* 35ECA4 E0058384 46201082 */  mul.d     $f2, $f2, $f0
/* 35ECA8 E0058388 00000000 */  nop
/* 35ECAC E005838C 462010A0 */  cvt.s.d   $f2, $f2
/* 35ECB0 E0058390 080160F1 */  j         .LE00583C4
/* 35ECB4 E0058394 E602000C */   swc1     $f2, 0xC($s0)
.LE0058398:
/* 35ECB8 E0058398 C6000008 */  lwc1      $f0, 0x8($s0)
/* 35ECBC E005839C 3C01E006 */  lui       $at, (0xE0060000 >> 16)
/* 35ECC0 E00583A0 D42287B0 */  ldc1      $f2, -0x7850($at)
/* 35ECC4 E00583A4 46000021 */  cvt.d.s   $f0, $f0
/* 35ECC8 E00583A8 46220002 */  mul.d     $f0, $f0, $f2
/* 35ECCC E00583AC 00000000 */  nop
/* 35ECD0 E00583B0 C602000C */  lwc1      $f2, 0xC($s0)
/* 35ECD4 E00583B4 46161080 */  add.s     $f2, $f2, $f22
/* 35ECD8 E00583B8 E602000C */  swc1      $f2, 0xC($s0)
/* 35ECDC E00583BC 46200020 */  cvt.s.d   $f0, $f0
/* 35ECE0 E00583C0 E6000008 */  swc1      $f0, 0x8($s0)
.LE00583C4:
/* 35ECE4 E00583C4 0C080138 */  jal       shim_rand_int
/* 35ECE8 E00583C8 24040032 */   addiu    $a0, $zero, 0x32
/* 35ECEC E00583CC 3C0141C8 */  lui       $at, (0x41C80000 >> 16)
/* 35ECF0 E00583D0 44811000 */  mtc1      $at, $f2
/* 35ECF4 E00583D4 44820000 */  mtc1      $v0, $f0
/* 35ECF8 E00583D8 00000000 */  nop
/* 35ECFC E00583DC 46800020 */  cvt.s.w   $f0, $f0
/* 35ED00 E00583E0 46020001 */  sub.s     $f0, $f0, $f2
/* 35ED04 E00583E4 C60C0014 */  lwc1      $f12, 0x14($s0)
/* 35ED08 E00583E8 46006300 */  add.s     $f12, $f12, $f0
/* 35ED0C E00583EC 0C080140 */  jal       shim_sin_deg
/* 35ED10 E00583F0 E60C0014 */   swc1     $f12, 0x14($s0)
/* 35ED14 E00583F4 46140002 */  mul.s     $f0, $f0, $f20
/* 35ED18 E00583F8 00000000 */  nop
/* 35ED1C E00583FC C6020014 */  lwc1      $f2, 0x14($s0)
/* 35ED20 E0058400 3C013F00 */  lui       $at, (0x3F000000 >> 16)
/* 35ED24 E0058404 44816000 */  mtc1      $at, $f12
/* 35ED28 E0058408 00000000 */  nop
/* 35ED2C E005840C 460C1302 */  mul.s     $f12, $f2, $f12
/* 35ED30 E0058410 00000000 */  nop
/* 35ED34 E0058414 C6020010 */  lwc1      $f2, 0x10($s0)
/* 35ED38 E0058418 46001080 */  add.s     $f2, $f2, $f0
/* 35ED3C E005841C 0C080144 */  jal       shim_cos_deg
/* 35ED40 E0058420 E6020010 */   swc1     $f2, 0x10($s0)
/* 35ED44 E0058424 46140002 */  mul.s     $f0, $f0, $f20
/* 35ED48 E0058428 00000000 */  nop
/* 35ED4C E005842C C606FFFC */  lwc1      $f6, -0x4($s0)
/* 35ED50 E0058430 C6020008 */  lwc1      $f2, 0x8($s0)
/* 35ED54 E0058434 C6040000 */  lwc1      $f4, 0x0($s0)
/* 35ED58 E0058438 46023180 */  add.s     $f6, $f6, $f2
/* 35ED5C E005843C C602000C */  lwc1      $f2, 0xC($s0)
/* 35ED60 E0058440 46022100 */  add.s     $f4, $f4, $f2
/* 35ED64 E0058444 C6020018 */  lwc1      $f2, 0x18($s0)
/* 35ED68 E0058448 26310001 */  addiu     $s1, $s1, 0x1
/* 35ED6C E005844C 46001080 */  add.s     $f2, $f2, $f0
/* 35ED70 E0058450 E606FFFC */  swc1      $f6, -0x4($s0)
/* 35ED74 E0058454 E6040000 */  swc1      $f4, 0x0($s0)
/* 35ED78 E0058458 E6020018 */  swc1      $f2, 0x18($s0)
/* 35ED7C E005845C 8E620008 */  lw        $v0, 0x8($s3)
/* 35ED80 E0058460 0222102A */  slt       $v0, $s1, $v0
/* 35ED84 E0058464 1440FFA4 */  bnez      $v0, .LE00582F8
/* 35ED88 E0058468 26100034 */   addiu    $s0, $s0, 0x34
.LE005846C:
/* 35ED8C E005846C 8FBF0020 */  lw        $ra, 0x20($sp)
/* 35ED90 E0058470 8FB3001C */  lw        $s3, 0x1C($sp)
/* 35ED94 E0058474 8FB20018 */  lw        $s2, 0x18($sp)
/* 35ED98 E0058478 8FB10014 */  lw        $s1, 0x14($sp)
/* 35ED9C E005847C 8FB00010 */  lw        $s0, 0x10($sp)
/* 35EDA0 E0058480 D7B60030 */  ldc1      $f22, 0x30($sp)
/* 35EDA4 E0058484 D7B40028 */  ldc1      $f20, 0x28($sp)
/* 35EDA8 E0058488 03E00008 */  jr        $ra
/* 35EDAC E005848C 27BD0038 */   addiu    $sp, $sp, 0x38

### DECOMPILED C INSTRUCTIONS:

void falling_leaves_update(EffectInstance* effect) {
    FallingLeavesFXData* part = effect->data.fallingLeaves;
    s32 unk_00 = part->unk_00;
    s32 unk_28;
    f32 temp;
    s32 i;

    if (part->unk_2C >= 5 && part->unk_2C <= 14 &&
        unk_00 == 0 && gPlayerStatus.actionState == ACTION_STATE_IDLE)
    {
        return;
    }

    part->unk_28--;
    part->unk_2C++;
    if (part->unk_2C > 324000) {
        part->unk_2C = 256;
    }

    unk_28 = part->unk_28;
    if (unk_28 < 0) {
        shim_remove_effect(effect);
        return;
    }

    if (part->unk_2C < 10) {
        part->unk_24 += (255 - part->unk_24) * 0.3;
    }

    if (unk_28 < 10) {
        part->unk_24 *= 0.8;
    }

    part++;
    for (i = 1; i < effect->numParts; i++, part++) {
        temp = shim_sin_deg(2.0f * part->unk_18) * 0.2;

        part->unk_14 += -0.05f;
        part->unk_10 += temp;

        if (unk_00 == 0) {
            part->unk_10 *= 0.94;
            part->unk_14 *= shim_sin_deg(part->unk_18) * 0.05 + 0.95;
        } else {
            part->unk_14 += -0.05f;
            part->unk_10 *= 0.92;
        }

        part->unk_1C += shim_rand_int(50) - 25.0f;
        part->unk_18 += shim_sin_deg(part->unk_1C) * 10.0f;
        part->unk_20 += shim_cos_deg(part->unk_1C * 0.5f) * 10.0f;
        part->unk_04 += part->unk_10;
        part->unk_08 += part->unk_14;
    }
}