### RAW ASSEMBLY INSTRUCTIONS:

glabel spawn_cloud_surface_effects
/* 19038 8003DC38 27BDFFA8 */  addiu     $sp, $sp, -0x58
/* 1903C 8003DC3C 3C028007 */  lui       $v0, %hi(D_80077C2C)
/* 19040 8003DC40 24427C2C */  addiu     $v0, $v0, %lo(D_80077C2C)
/* 19044 8003DC44 AFBF0020 */  sw        $ra, 0x20($sp)
/* 19048 8003DC48 AFB3001C */  sw        $s3, 0x1C($sp)
/* 1904C 8003DC4C AFB20018 */  sw        $s2, 0x18($sp)
/* 19050 8003DC50 AFB10014 */  sw        $s1, 0x14($sp)
/* 19054 8003DC54 AFB00010 */  sw        $s0, 0x10($sp)
/* 19058 8003DC58 F7BE0050 */  sdc1      $f30, 0x50($sp)
/* 1905C 8003DC5C F7BC0048 */  sdc1      $f28, 0x48($sp)
/* 19060 8003DC60 F7BA0040 */  sdc1      $f26, 0x40($sp)
/* 19064 8003DC64 F7B80038 */  sdc1      $f24, 0x38($sp)
/* 19068 8003DC68 F7B60030 */  sdc1      $f22, 0x30($sp)
/* 1906C 8003DC6C F7B40028 */  sdc1      $f20, 0x28($sp)
/* 19070 8003DC70 C4400000 */  lwc1      $f0, 0x0($v0)
/* 19074 8003DC74 3C013DCC */  lui       $at, (0x3DCCCCCD >> 16)
/* 19078 8003DC78 3421CCCD */  ori       $at, $at, (0x3DCCCCCD & 0xFFFF)
/* 1907C 8003DC7C 44811000 */  mtc1      $at, $f2
/* 19080 8003DC80 00000000 */  nop
/* 19084 8003DC84 46020000 */  add.s     $f0, $f0, $f2
/* 19088 8003DC88 E4400000 */  swc1      $f0, 0x0($v0)
/* 1908C 8003DC8C 24020002 */  addiu     $v0, $zero, 0x2
/* 19090 8003DC90 14A2006B */  bne       $a1, $v0, .L8003DE40
/* 19094 8003DC94 0080882D */   daddu    $s1, $a0, $zero
/* 19098 8003DC98 3C108007 */  lui       $s0, %hi(D_80077C24)
/* 1909C 8003DC9C 26107C24 */  addiu     $s0, $s0, %lo(D_80077C24)
/* 190A0 8003DCA0 C62E003C */  lwc1      $f14, 0x3C($s1)
/* 190A4 8003DCA4 3C014160 */  lui       $at, (0x41600000 >> 16)
/* 190A8 8003DCA8 44810000 */  mtc1      $at, $f0
/* 190AC 8003DCAC C62C0038 */  lwc1      $f12, 0x38($s1)
/* 190B0 8003DCB0 46007380 */  add.s     $f14, $f14, $f0
/* 190B4 8003DCB4 3C0140A0 */  lui       $at, (0x40A00000 >> 16)
/* 190B8 8003DCB8 44810000 */  mtc1      $at, $f0
/* 190BC 8003DCBC 8E260040 */  lw        $a2, 0x40($s1)
/* 190C0 8003DCC0 8E070000 */  lw        $a3, 0x0($s0)
/* 190C4 8003DCC4 0C01BF14 */  jal       fx_cloud_puff
/* 190C8 8003DCC8 46007381 */   sub.s    $f14, $f14, $f0
/* 190CC 8003DCCC C6000000 */  lwc1      $f0, 0x0($s0)
/* 190D0 8003DCD0 3C01420C */  lui       $at, (0x420C0000 >> 16)
/* 190D4 8003DCD4 44816000 */  mtc1      $at, $f12
/* 190D8 8003DCD8 0000982D */  daddu     $s3, $zero, $zero
/* 190DC 8003DCDC 460C0300 */  add.s     $f12, $f0, $f12
/* 190E0 8003DCE0 3C01BE99 */  lui       $at, (0xBE99999A >> 16)
/* 190E4 8003DCE4 3421999A */  ori       $at, $at, (0xBE99999A & 0xFFFF)
/* 190E8 8003DCE8 4481F000 */  mtc1      $at, $f30
/* 190EC 8003DCEC 0C00A6C9 */  jal       clamp_angle
/* 190F0 8003DCF0 0260902D */   daddu    $s2, $s3, $zero
/* 190F4 8003DCF4 E6000000 */  swc1      $f0, 0x0($s0)
.L8003DCF8:
/* 190F8 8003DCF8 0C00A67F */  jal       rand_int
/* 190FC 8003DCFC 2404000A */   addiu    $a0, $zero, 0xA
/* 19100 8003DD00 2442FFFB */  addiu     $v0, $v0, -0x5
/* 19104 8003DD04 4482B000 */  mtc1      $v0, $f22
/* 19108 8003DD08 00000000 */  nop
/* 1910C 8003DD0C 4680B5A0 */  cvt.s.w   $f22, $f22
/* 19110 8003DD10 0C00A67F */  jal       rand_int
/* 19114 8003DD14 2404000A */   addiu    $a0, $zero, 0xA
/* 19118 8003DD18 4616B082 */  mul.s     $f2, $f22, $f22
/* 1911C 8003DD1C 00000000 */  nop
/* 19120 8003DD20 2442FFFB */  addiu     $v0, $v0, -0x5
/* 19124 8003DD24 4482C000 */  mtc1      $v0, $f24
/* 19128 8003DD28 00000000 */  nop
/* 1912C 8003DD2C 4680C620 */  cvt.s.w   $f24, $f24
/* 19130 8003DD30 4618C102 */  mul.s     $f4, $f24, $f24
/* 19134 8003DD34 00000000 */  nop
/* 19138 8003DD38 C62C000C */  lwc1      $f12, 0xC($s1)
/* 1913C 8003DD3C 44920000 */  mtc1      $s2, $f0
/* 19140 8003DD40 00000000 */  nop
/* 19144 8003DD44 46800020 */  cvt.s.w   $f0, $f0
/* 19148 8003DD48 46006307 */  neg.s     $f12, $f12
/* 1914C 8003DD4C 46006300 */  add.s     $f12, $f12, $f0
/* 19150 8003DD50 3C01C000 */  lui       $at, (0xC0000000 >> 16)
/* 19154 8003DD54 4481A000 */  mtc1      $at, $f20
/* 19158 8003DD58 3C0140A0 */  lui       $at, (0x40A00000 >> 16)
/* 1915C 8003DD5C 44810000 */  mtc1      $at, $f0
/* 19160 8003DD60 46041080 */  add.s     $f2, $f2, $f4
/* 19164 8003DD64 3C018007 */  lui       $at, %hi(D_80077C28)
/* 19168 8003DD68 A4207C28 */  sh        $zero, %lo(D_80077C28)($at)
/* 1916C 8003DD6C 46001083 */  div.s     $f2, $f2, $f0
/* 19170 8003DD70 0C00A6C9 */  jal       clamp_angle
/* 19174 8003DD74 4602A501 */   sub.s    $f20, $f20, $f2
/* 19178 8003DD78 3C0140C9 */  lui       $at, (0x40C90FD0 >> 16)
/* 1917C 8003DD7C 34210FD0 */  ori       $at, $at, (0x40C90FD0 & 0xFFFF)
/* 19180 8003DD80 44811000 */  mtc1      $at, $f2
/* 19184 8003DD84 00000000 */  nop
/* 19188 8003DD88 46020002 */  mul.s     $f0, $f0, $f2
/* 1918C 8003DD8C 00000000 */  nop
/* 19190 8003DD90 3C0143B4 */  lui       $at, (0x43B40000 >> 16)
/* 19194 8003DD94 44811000 */  mtc1      $at, $f2
/* 19198 8003DD98 00000000 */  nop
/* 1919C 8003DD9C 46020683 */  div.s     $f26, $f0, $f2
/* 191A0 8003DDA0 0C00A85B */  jal       sin_rad
/* 191A4 8003DDA4 4600D306 */   mov.s    $f12, $f26
/* 191A8 8003DDA8 46000706 */  mov.s     $f28, $f0
/* 191AC 8003DDAC 0C00A874 */  jal       cos_rad
/* 191B0 8003DDB0 4600D306 */   mov.s    $f12, $f26
/* 191B4 8003DDB4 862200A6 */  lh        $v0, 0xA6($s1)
/* 191B8 8003DDB8 44822000 */  mtc1      $v0, $f4
/* 191BC 8003DDBC 00000000 */  nop
/* 191C0 8003DDC0 46802120 */  cvt.s.w   $f4, $f4
/* 191C4 8003DDC4 461C2182 */  mul.s     $f6, $f4, $f28
/* 191C8 8003DDC8 00000000 */  nop
/* 191CC 8003DDCC 46002102 */  mul.s     $f4, $f4, $f0
/* 191D0 8003DDD0 00000000 */  nop
/* 191D4 8003DDD4 3C014178 */  lui       $at, (0x41780000 >> 16)
/* 191D8 8003DDD8 44811000 */  mtc1      $at, $f2
/* 191DC 8003DDDC C620003C */  lwc1      $f0, 0x3C($s1)
/* 191E0 8003DDE0 46020000 */  add.s     $f0, $f0, $f2
/* 191E4 8003DDE4 46140000 */  add.s     $f0, $f0, $f20
/* 191E8 8003DDE8 461E3182 */  mul.s     $f6, $f6, $f30
/* 191EC 8003DDEC 00000000 */  nop
/* 191F0 8003DDF0 44060000 */  mfc1      $a2, $f0
/* 191F4 8003DDF4 C6200038 */  lwc1      $f0, 0x38($s1)
/* 191F8 8003DDF8 46060000 */  add.s     $f0, $f0, $f6
/* 191FC 8003DDFC 46160000 */  add.s     $f0, $f0, $f22
/* 19200 8003DE00 461E2102 */  mul.s     $f4, $f4, $f30
/* 19204 8003DE04 00000000 */  nop
/* 19208 8003DE08 44050000 */  mfc1      $a1, $f0
/* 1920C 8003DE0C C6200040 */  lwc1      $f0, 0x40($s1)
/* 19210 8003DE10 46040000 */  add.s     $f0, $f0, $f4
/* 19214 8003DE14 46180000 */  add.s     $f0, $f0, $f24
/* 19218 8003DE18 2652005A */  addiu     $s2, $s2, 0x5A
/* 1921C 8003DE1C 26730001 */  addiu     $s3, $s3, 0x1
/* 19220 8003DE20 44070000 */  mfc1      $a3, $f0
/* 19224 8003DE24 0C01BF2C */  jal       fx_cloud_trail
/* 19228 8003DE28 24040001 */   addiu    $a0, $zero, 0x1
/* 1922C 8003DE2C 2A620004 */  slti      $v0, $s3, 0x4
/* 19230 8003DE30 1040004E */  beqz      $v0, .L8003DF6C
/* 19234 8003DE34 00000000 */   nop
/* 19238 8003DE38 0800F73E */  j         .L8003DCF8
/* 1923C 8003DE3C 00000000 */   nop
.L8003DE40:
/* 19240 8003DE40 0C00A67F */  jal       rand_int
/* 19244 8003DE44 2404000A */   addiu    $a0, $zero, 0xA
/* 19248 8003DE48 2442FFFB */  addiu     $v0, $v0, -0x5
/* 1924C 8003DE4C 4482C000 */  mtc1      $v0, $f24
/* 19250 8003DE50 00000000 */  nop
/* 19254 8003DE54 4680C620 */  cvt.s.w   $f24, $f24
/* 19258 8003DE58 0C00A67F */  jal       rand_int
/* 1925C 8003DE5C 2404000A */   addiu    $a0, $zero, 0xA
/* 19260 8003DE60 4618C002 */  mul.s     $f0, $f24, $f24
/* 19264 8003DE64 00000000 */  nop
/* 19268 8003DE68 2442FFFB */  addiu     $v0, $v0, -0x5
/* 1926C 8003DE6C 4482B000 */  mtc1      $v0, $f22
/* 19270 8003DE70 00000000 */  nop
/* 19274 8003DE74 4680B5A0 */  cvt.s.w   $f22, $f22
/* 19278 8003DE78 4616B082 */  mul.s     $f2, $f22, $f22
/* 1927C 8003DE7C 00000000 */  nop
/* 19280 8003DE80 C62C000C */  lwc1      $f12, 0xC($s1)
/* 19284 8003DE84 3C01C000 */  lui       $at, (0xC0000000 >> 16)
/* 19288 8003DE88 4481A000 */  mtc1      $at, $f20
/* 1928C 8003DE8C 46020000 */  add.s     $f0, $f0, $f2
/* 19290 8003DE90 3C018007 */  lui       $at, %hi(D_80077C28)
/* 19294 8003DE94 A4207C28 */  sh        $zero, %lo(D_80077C28)($at)
/* 19298 8003DE98 3C0140A0 */  lui       $at, (0x40A00000 >> 16)
/* 1929C 8003DE9C 44811000 */  mtc1      $at, $f2
/* 192A0 8003DEA0 46006307 */  neg.s     $f12, $f12
/* 192A4 8003DEA4 46020003 */  div.s     $f0, $f0, $f2
/* 192A8 8003DEA8 0C00A6C9 */  jal       clamp_angle
/* 192AC 8003DEAC 4600A501 */   sub.s    $f20, $f20, $f0
/* 192B0 8003DEB0 3C0140C9 */  lui       $at, (0x40C90FD0 >> 16)
/* 192B4 8003DEB4 34210FD0 */  ori       $at, $at, (0x40C90FD0 & 0xFFFF)
/* 192B8 8003DEB8 44811000 */  mtc1      $at, $f2
/* 192BC 8003DEBC 00000000 */  nop
/* 192C0 8003DEC0 46020002 */  mul.s     $f0, $f0, $f2
/* 192C4 8003DEC4 00000000 */  nop
/* 192C8 8003DEC8 3C0143B4 */  lui       $at, (0x43B40000 >> 16)
/* 192CC 8003DECC 44811000 */  mtc1      $at, $f2
/* 192D0 8003DED0 00000000 */  nop
/* 192D4 8003DED4 46020683 */  div.s     $f26, $f0, $f2
/* 192D8 8003DED8 0C00A85B */  jal       sin_rad
/* 192DC 8003DEDC 4600D306 */   mov.s    $f12, $f26
/* 192E0 8003DEE0 46000706 */  mov.s     $f28, $f0
/* 192E4 8003DEE4 0C00A874 */  jal       cos_rad
/* 192E8 8003DEE8 4600D306 */   mov.s    $f12, $f26
/* 192EC 8003DEEC 862200A6 */  lh        $v0, 0xA6($s1)
/* 192F0 8003DEF0 44822000 */  mtc1      $v0, $f4
/* 192F4 8003DEF4 00000000 */  nop
/* 192F8 8003DEF8 46802120 */  cvt.s.w   $f4, $f4
/* 192FC 8003DEFC 461C2182 */  mul.s     $f6, $f4, $f28
/* 19300 8003DF00 00000000 */  nop
/* 19304 8003DF04 46002102 */  mul.s     $f4, $f4, $f0
/* 19308 8003DF08 00000000 */  nop
/* 1930C 8003DF0C 3C01BE99 */  lui       $at, (0xBE99999A >> 16)
/* 19310 8003DF10 3421999A */  ori       $at, $at, (0xBE99999A & 0xFFFF)
/* 19314 8003DF14 44810000 */  mtc1      $at, $f0
/* 19318 8003DF18 00000000 */  nop
/* 1931C 8003DF1C 46003182 */  mul.s     $f6, $f6, $f0
/* 19320 8003DF20 00000000 */  nop
/* 19324 8003DF24 46002102 */  mul.s     $f4, $f4, $f0
/* 19328 8003DF28 00000000 */  nop
/* 1932C 8003DF2C 3C014178 */  lui       $at, (0x41780000 >> 16)
/* 19330 8003DF30 44811000 */  mtc1      $at, $f2
/* 19334 8003DF34 C620003C */  lwc1      $f0, 0x3C($s1)
/* 19338 8003DF38 46020000 */  add.s     $f0, $f0, $f2
/* 1933C 8003DF3C 46140000 */  add.s     $f0, $f0, $f20
/* 19340 8003DF40 44060000 */  mfc1      $a2, $f0
/* 19344 8003DF44 C6200038 */  lwc1      $f0, 0x38($s1)
/* 19348 8003DF48 46060000 */  add.s     $f0, $f0, $f6
/* 1934C 8003DF4C 46180000 */  add.s     $f0, $f0, $f24
/* 19350 8003DF50 44050000 */  mfc1      $a1, $f0
/* 19354 8003DF54 C6200040 */  lwc1      $f0, 0x40($s1)
/* 19358 8003DF58 46040000 */  add.s     $f0, $f0, $f4
/* 1935C 8003DF5C 46160000 */  add.s     $f0, $f0, $f22
/* 19360 8003DF60 44070000 */  mfc1      $a3, $f0
/* 19364 8003DF64 0C01BF2C */  jal       fx_cloud_trail
/* 19368 8003DF68 24040001 */   addiu    $a0, $zero, 0x1
.L8003DF6C:
/* 1936C 8003DF6C 8FBF0020 */  lw        $ra, 0x20($sp)
/* 19370 8003DF70 8FB3001C */  lw        $s3, 0x1C($sp)
/* 19374 8003DF74 8FB20018 */  lw        $s2, 0x18($sp)
/* 19378 8003DF78 8FB10014 */  lw        $s1, 0x14($sp)
/* 1937C 8003DF7C 8FB00010 */  lw        $s0, 0x10($sp)
/* 19380 8003DF80 D7BE0050 */  ldc1      $f30, 0x50($sp)
/* 19384 8003DF84 D7BC0048 */  ldc1      $f28, 0x48($sp)
/* 19388 8003DF88 D7BA0040 */  ldc1      $f26, 0x40($sp)
/* 1938C 8003DF8C D7B80038 */  ldc1      $f24, 0x38($sp)
/* 19390 8003DF90 D7B60030 */  ldc1      $f22, 0x30($sp)
/* 19394 8003DF94 D7B40028 */  ldc1      $f20, 0x28($sp)
/* 19398 8003DF98 03E00008 */  jr        $ra
/* 1939C 8003DF9C 27BD0058 */   addiu    $sp, $sp, 0x58

### DECOMPILED C INSTRUCTIONS:

void spawn_cloud_surface_effects(Npc* npc, SurfaceInteractMode mode) {
    PlayerStatus* playerStatus = &gPlayerStatus;
    f32 xTemp, yTemp, zTemp;
    f32 xTemp2, yTemp2, zTemp2;
    f32 theta;
    f32 sinTheta;
    f32 cosTheta;
    f32 angle;
    s32 i;

    D_80077C2C += 0.1f;
    if (mode == SURFACE_INTERACT_LAND) {
        fx_cloud_puff(npc->pos.x, (npc->pos.y + 14.0f) - 5.0f, npc->pos.z, D_80077C24);

        D_80077C24 = clamp_angle(D_80077C24 + 35.0f);

        for (i = 0; i < 4; i++) {
            xTemp = rand_int(10) - 5;
            zTemp = rand_int(10) - 5;
            yTemp = -2.0f - ((SQ(xTemp) + SQ(zTemp)) / 5.0f);
            D_80077C28 = 0;

            theta = DEG_TO_RAD(clamp_angle(-npc->yaw + (i * 90)));
            sinTheta = sin_rad(theta);
            cosTheta = cos_rad(theta);

            fx_cloud_trail(
                1,
                npc->pos.x + (npc->collisionDiameter * sinTheta * -0.3f) + xTemp,
                npc->pos.y + 15.5f + yTemp,
                npc->pos.z + (npc->collisionDiameter * cosTheta * -0.3f) + zTemp
            );
        }
    } else {
        xTemp2 = rand_int(10) - 5;
        zTemp2 = rand_int(10) - 5;
        yTemp2 = -2.0f - ((SQ(xTemp2) + SQ(zTemp2)) / 5.0f);

        D_80077C28 = 0;

        theta = DEG_TO_RAD(clamp_angle(-npc->yaw));
        sinTheta = sin_rad(theta);
        cosTheta = cos_rad(theta);
        fx_cloud_trail(
            1,
            npc->pos.x + (npc->collisionDiameter * sinTheta * -0.3f) + xTemp2,
            npc->pos.y + 15.5f + yTemp2,
            npc->pos.z + (npc->collisionDiameter * cosTheta * -0.3f) + zTemp2
        );
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel make_item_entity_at_player
/* C8200 80131B00 27BDFFB8 */  addiu     $sp, $sp, -0x48
/* C8204 80131B04 AFB00028 */  sw        $s0, 0x28($sp)
/* C8208 80131B08 0080802D */  daddu     $s0, $a0, $zero
/* C820C 80131B0C AFB30034 */  sw        $s3, 0x34($sp)
/* C8210 80131B10 00A0982D */  daddu     $s3, $a1, $zero
/* C8214 80131B14 AFB40038 */  sw        $s4, 0x38($sp)
/* C8218 80131B18 00C0A02D */  daddu     $s4, $a2, $zero
/* C821C 80131B1C AFB20030 */  sw        $s2, 0x30($sp)
/* C8220 80131B20 3C128011 */  lui       $s2, %hi(gPlayerStatus)
/* C8224 80131B24 2652EFC8 */  addiu     $s2, $s2, %lo(gPlayerStatus)
/* C8228 80131B28 3C048015 */  lui       $a0, %hi(gCurrentItemEntities)
/* C822C 80131B2C 8C8465A0 */  lw        $a0, %lo(gCurrentItemEntities)($a0)
/* C8230 80131B30 0000182D */  daddu     $v1, $zero, $zero
/* C8234 80131B34 AFBF0040 */  sw        $ra, 0x40($sp)
/* C8238 80131B38 AFB5003C */  sw        $s5, 0x3C($sp)
/* C823C 80131B3C AFB1002C */  sw        $s1, 0x2C($sp)
.L80131B40:
/* C8240 80131B40 8C820000 */  lw        $v0, 0x0($a0)
/* C8244 80131B44 10400006 */  beqz      $v0, .L80131B60
/* C8248 80131B48 28620100 */   slti     $v0, $v1, 0x100
/* C824C 80131B4C 24630001 */  addiu     $v1, $v1, 0x1
/* C8250 80131B50 28620100 */  slti      $v0, $v1, 0x100
/* C8254 80131B54 1440FFFA */  bnez      $v0, .L80131B40
/* C8258 80131B58 24840004 */   addiu    $a0, $a0, 0x4
/* C825C 80131B5C 28620100 */  slti      $v0, $v1, 0x100
.L80131B60:
/* C8260 80131B60 54400003 */  bnel      $v0, $zero, .L80131B70
/* C8264 80131B64 2404005C */   addiu    $a0, $zero, 0x5C
.L80131B68:
/* C8268 80131B68 0804C6DA */  j         .L80131B68
/* C826C 80131B6C 00000000 */   nop
.L80131B70:
/* C8270 80131B70 0C00AB39 */  jal       heap_malloc
/* C8274 80131B74 0060A82D */   daddu    $s5, $v1, $zero
/* C8278 80131B78 00152080 */  sll       $a0, $s5, 2
/* C827C 80131B7C 3C038015 */  lui       $v1, %hi(gCurrentItemEntities)
/* C8280 80131B80 8C6365A0 */  lw        $v1, %lo(gCurrentItemEntities)($v1)
/* C8284 80131B84 3C058015 */  lui       $a1, %hi(ItemEntitiesCreated)
/* C8288 80131B88 24A512F8 */  addiu     $a1, $a1, %lo(ItemEntitiesCreated)
/* C828C 80131B8C 00832021 */  addu      $a0, $a0, $v1
/* C8290 80131B90 8CA30000 */  lw        $v1, 0x0($a1)
/* C8294 80131B94 0040882D */  daddu     $s1, $v0, $zero
/* C8298 80131B98 AC910000 */  sw        $s1, 0x0($a0)
/* C829C 80131B9C 24630001 */  addiu     $v1, $v1, 0x1
/* C82A0 80131BA0 16200003 */  bnez      $s1, .L80131BB0
/* C82A4 80131BA4 ACA30000 */   sw       $v1, 0x0($a1)
.L80131BA8:
/* C82A8 80131BA8 0804C6EA */  j         .L80131BA8
/* C82AC 80131BAC 00000000 */   nop
.L80131BB0:
/* C82B0 80131BB0 3210FFFF */  andi      $s0, $s0, 0xFFFF
/* C82B4 80131BB4 3C030200 */  lui       $v1, (0x2000017 >> 16)
/* C82B8 80131BB8 34630017 */  ori       $v1, $v1, (0x2000017 & 0xFFFF)
/* C82BC 80131BBC 2402FFFF */  addiu     $v0, $zero, -0x1
/* C82C0 80131BC0 A222001D */  sb        $v0, 0x1D($s1)
/* C82C4 80131BC4 12600004 */  beqz      $s3, .L80131BD8
/* C82C8 80131BC8 AE230000 */   sw       $v1, 0x0($s1)
/* C82CC 80131BCC 3C020600 */  lui       $v0, (0x6000017 >> 16)
/* C82D0 80131BD0 34420017 */  ori       $v0, $v0, (0x6000017 & 0xFFFF)
/* C82D4 80131BD4 AE220000 */  sw        $v0, 0x0($s1)
.L80131BD8:
/* C82D8 80131BD8 2402001C */  addiu     $v0, $zero, 0x1C
/* C82DC 80131BDC A6340006 */  sh        $s4, 0x6($s1)
/* C82E0 80131BE0 A222001B */  sb        $v0, 0x1B($s1)
/* C82E4 80131BE4 A220001A */  sb        $zero, 0x1A($s1)
/* C82E8 80131BE8 A6200004 */  sh        $zero, 0x4($s1)
/* C82EC 80131BEC C6400028 */  lwc1      $f0, 0x28($s2)
/* C82F0 80131BF0 8E230000 */  lw        $v1, 0x0($s1)
/* C82F4 80131BF4 E6200008 */  swc1      $f0, 0x8($s1)
/* C82F8 80131BF8 C640002C */  lwc1      $f0, 0x2C($s2)
/* C82FC 80131BFC 2402FFFF */  addiu     $v0, $zero, -0x1
/* C8300 80131C00 E620000C */  swc1      $f0, 0xC($s1)
/* C8304 80131C04 C6420030 */  lwc1      $f2, 0x30($s2)
/* C8308 80131C08 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* C830C 80131C0C 44810000 */  mtc1      $at, $f0
/* C8310 80131C10 34634000 */  ori       $v1, $v1, 0x4000
/* C8314 80131C14 A6220020 */  sh        $v0, 0x20($s1)
/* C8318 80131C18 24020001 */  addiu     $v0, $zero, 0x1
/* C831C 80131C1C A222002E */  sb        $v0, 0x2E($s1)
/* C8320 80131C20 2402D8F1 */  addiu     $v0, $zero, -0x270F
/* C8324 80131C24 A6220034 */  sh        $v0, 0x34($s1)
/* C8328 80131C28 A6220036 */  sh        $v0, 0x36($s1)
/* C832C 80131C2C A6220038 */  sh        $v0, 0x38($s1)
/* C8330 80131C30 00101140 */  sll       $v0, $s0, 5
/* C8334 80131C34 A6300018 */  sh        $s0, 0x18($s1)
/* C8338 80131C38 AE200014 */  sw        $zero, 0x14($s1)
/* C833C 80131C3C A220001C */  sb        $zero, 0x1C($s1)
/* C8340 80131C40 A620001E */  sh        $zero, 0x1E($s1)
/* C8344 80131C44 AE230000 */  sw        $v1, 0x0($s1)
/* C8348 80131C48 E6200030 */  swc1      $f0, 0x30($s1)
/* C834C 80131C4C E6220010 */  swc1      $f2, 0x10($s1)
/* C8350 80131C50 3C018008 */  lui       $at, %hi(gItemTable + 0x18)
/* C8354 80131C54 00220821 */  addu      $at, $at, $v0
/* C8358 80131C58 942278F8 */  lhu       $v0, %lo(gItemTable + 0x18)($at)
/* C835C 80131C5C 30421000 */  andi      $v0, $v0, 0x1000
/* C8360 80131C60 10400005 */  beqz      $v0, .L80131C78
/* C8364 80131C64 3C020004 */   lui      $v0, (0x40000 >> 16)
/* C8368 80131C68 00621025 */  or        $v0, $v1, $v0
/* C836C 80131C6C 2403BFFF */  addiu     $v1, $zero, -0x4001
/* C8370 80131C70 00431024 */  and       $v0, $v0, $v1
/* C8374 80131C74 AE220000 */  sw        $v0, 0x0($s1)
.L80131C78:
/* C8378 80131C78 3C088015 */  lui       $t0, %hi(ItemEntityAlternatingSpawn)
/* C837C 80131C7C 25085D84 */  addiu     $t0, $t0, %lo(ItemEntityAlternatingSpawn)
/* C8380 80131C80 8D020000 */  lw        $v0, 0x0($t0)
/* C8384 80131C84 10400004 */  beqz      $v0, .L80131C98
/* C8388 80131C88 3C030002 */   lui      $v1, (0x20000 >> 16)
/* C838C 80131C8C 8E220000 */  lw        $v0, 0x0($s1)
/* C8390 80131C90 00431025 */  or        $v0, $v0, $v1
/* C8394 80131C94 AE220000 */  sw        $v0, 0x0($s1)
.L80131C98:
/* C8398 80131C98 0000202D */  daddu     $a0, $zero, $zero
/* C839C 80131C9C 24020001 */  addiu     $v0, $zero, 0x1
/* C83A0 80131CA0 8E250008 */  lw        $a1, 0x8($s1)
/* C83A4 80131CA4 8E26000C */  lw        $a2, 0xC($s1)
/* C83A8 80131CA8 8D030000 */  lw        $v1, 0x0($t0)
/* C83AC 80131CAC 8E270010 */  lw        $a3, 0x10($s1)
/* C83B0 80131CB0 00431023 */  subu      $v0, $v0, $v1
/* C83B4 80131CB4 0C044898 */  jal       create_shadow_type
/* C83B8 80131CB8 AD020000 */   sw       $v0, 0x0($t0)
/* C83BC 80131CBC 00022400 */  sll       $a0, $v0, 16
/* C83C0 80131CC0 00042403 */  sra       $a0, $a0, 16
/* C83C4 80131CC4 0C044181 */  jal       get_shadow_by_index
/* C83C8 80131CC8 A6220020 */   sh       $v0, 0x20($s1)
/* C83CC 80131CCC 3C040002 */  lui       $a0, (0x20000 >> 16)
/* C83D0 80131CD0 27A50018 */  addiu     $a1, $sp, 0x18
/* C83D4 80131CD4 27A6001C */  addiu     $a2, $sp, 0x1C
/* C83D8 80131CD8 27A70020 */  addiu     $a3, $sp, 0x20
/* C83DC 80131CDC 0040802D */  daddu     $s0, $v0, $zero
/* C83E0 80131CE0 8E020000 */  lw        $v0, 0x0($s0)
/* C83E4 80131CE4 3C01447A */  lui       $at, (0x447A0000 >> 16)
/* C83E8 80131CE8 44810000 */  mtc1      $at, $f0
/* C83EC 80131CEC 3C014140 */  lui       $at, (0x41400000 >> 16)
/* C83F0 80131CF0 44811000 */  mtc1      $at, $f2
/* C83F4 80131CF4 34420001 */  ori       $v0, $v0, 0x1
/* C83F8 80131CF8 AE020000 */  sw        $v0, 0x0($s0)
/* C83FC 80131CFC 27A20024 */  addiu     $v0, $sp, 0x24
/* C8400 80131D00 E7A00024 */  swc1      $f0, 0x24($sp)
/* C8404 80131D04 C6260008 */  lwc1      $f6, 0x8($s1)
/* C8408 80131D08 C620000C */  lwc1      $f0, 0xC($s1)
/* C840C 80131D0C C6240010 */  lwc1      $f4, 0x10($s1)
/* C8410 80131D10 46020000 */  add.s     $f0, $f0, $f2
/* C8414 80131D14 E7A60018 */  swc1      $f6, 0x18($sp)
/* C8418 80131D18 E7A40020 */  swc1      $f4, 0x20($sp)
/* C841C 80131D1C E7A0001C */  swc1      $f0, 0x1C($sp)
/* C8420 80131D20 0C0372DF */  jal       npc_raycast_down_sides
/* C8424 80131D24 AFA20010 */   sw       $v0, 0x10($sp)
/* C8428 80131D28 C7A00018 */  lwc1      $f0, 0x18($sp)
/* C842C 80131D2C C7A2001C */  lwc1      $f2, 0x1C($sp)
/* C8430 80131D30 C7A40020 */  lwc1      $f4, 0x20($sp)
/* C8434 80131D34 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* C8438 80131D38 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* C843C 80131D3C E6000010 */  swc1      $f0, 0x10($s0)
/* C8440 80131D40 E6020014 */  swc1      $f2, 0x14($s0)
/* C8444 80131D44 E6040018 */  swc1      $f4, 0x18($s0)
/* C8448 80131D48 C7A20024 */  lwc1      $f2, 0x24($sp)
/* C844C 80131D4C 3C013F00 */  lui       $at, (0x3F000000 >> 16)
/* C8450 80131D50 44810000 */  mtc1      $at, $f0
/* C8454 80131D54 C444011C */  lwc1      $f4, 0x11C($v0)
/* C8458 80131D58 46001082 */  mul.s     $f2, $f2, $f0
/* C845C 80131D5C 00000000 */  nop
/* C8460 80131D60 AE00002C */  sw        $zero, 0x2C($s0)
/* C8464 80131D64 E6040028 */  swc1      $f4, 0x28($s0)
/* C8468 80131D68 C4400124 */  lwc1      $f0, 0x124($v0)
/* C846C 80131D6C 44051000 */  mfc1      $a1, $f2
/* C8470 80131D70 0200202D */  daddu     $a0, $s0, $zero
/* C8474 80131D74 0C044A17 */  jal       set_standard_shadow_scale
/* C8478 80131D78 E4800030 */   swc1     $f0, 0x30($a0)
/* C847C 80131D7C 0C04C44A */  jal       item_entity_load
/* C8480 80131D80 0220202D */   daddu    $a0, $s1, $zero
/* C8484 80131D84 86230018 */  lh        $v1, 0x18($s1)
/* C8488 80131D88 24020157 */  addiu     $v0, $zero, 0x157
/* C848C 80131D8C 14620008 */  bne       $v1, $v0, .L80131DB0
/* C8490 80131D90 02A0102D */   daddu    $v0, $s5, $zero
/* C8494 80131D94 3C058010 */  lui       $a1, %hi(SparkleScript_Coin)
/* C8498 80131D98 24A54AC0 */  addiu     $a1, $a1, %lo(SparkleScript_Coin)
/* C849C 80131D9C 0C04C27C */  jal       sparkle_script_init
/* C84A0 80131DA0 0220202D */   daddu    $a0, $s1, $zero
/* C84A4 80131DA4 0C04C2B3 */  jal       sparkle_script_update
/* C84A8 80131DA8 0220202D */   daddu    $a0, $s1, $zero
/* C84AC 80131DAC 02A0102D */  daddu     $v0, $s5, $zero
.L80131DB0:
/* C84B0 80131DB0 8FBF0040 */  lw        $ra, 0x40($sp)
/* C84B4 80131DB4 8FB5003C */  lw        $s5, 0x3C($sp)
/* C84B8 80131DB8 8FB40038 */  lw        $s4, 0x38($sp)
/* C84BC 80131DBC 8FB30034 */  lw        $s3, 0x34($sp)
/* C84C0 80131DC0 8FB20030 */  lw        $s2, 0x30($sp)
/* C84C4 80131DC4 8FB1002C */  lw        $s1, 0x2C($sp)
/* C84C8 80131DC8 8FB00028 */  lw        $s0, 0x28($sp)
/* C84CC 80131DCC 03E00008 */  jr        $ra
/* C84D0 80131DD0 27BD0048 */   addiu    $sp, $sp, 0x48

### DECOMPILED C INSTRUCTIONS:

s32 make_item_entity_at_player(s32 itemID, s32 category, s32 pickupMsgFlags) {
    PlayerStatus* playerStatus = &gPlayerStatus;
    ItemEntity* item;
    Shadow* shadow;
    s32 i;
    f32 posX;
    f32 posY;
    f32 posZ;
    f32 depth;
    s32 id;

    for (i = 0; i < MAX_ITEM_ENTITIES; i++) {
        if (gCurrentItemEntities[i] == NULL) {
            break;
        }
    }
    ASSERT(i < MAX_ITEM_ENTITIES);
    id = i;

    gCurrentItemEntities[id] = item = heap_malloc(sizeof(*item));
    ItemEntitiesCreated++;
    ASSERT(item != NULL);

    itemID &= 0xFFFF;
    item->renderGroup = -1;
    item->flags = (ITEM_ENTITY_FLAG_CAM0 | ITEM_ENTITY_FLAG_CAM1 | ITEM_ENTITY_FLAG_CAM2 | ITEM_ENTITY_FLAG_10 | ITEM_ENTITY_FLAG_2000000);
    if (category != ITEM_TYPE_CONSUMABLE) {
        item->flags |= ITEM_ENTITY_FLAG_4000000;
    }
    item->pickupMsgFlags = pickupMsgFlags;
    item->spawnType = ITEM_SPAWN_AT_PLAYER;
    item->state = ITEM_PICKUP_STATE_INIT;
    item->boundVar = 0;
    item->position.x = playerStatus->position.x;
    item->position.y = playerStatus->position.y;
    item->position.z = playerStatus->position.z;

    item->shadowIndex = -1;
    item->nextUpdate = 1;
    item->lastPos.x = -9999;
    item->lastPos.y = -9999;
    item->lastPos.z = -9999;
    item->scale = 1.0f;
    item->itemID = itemID;
    item->physicsData = NULL;
    item->pickupDelay = 0;
    item->spawnAngle = 0;
    item->flags |= ITEM_ENTITY_RESIZABLE;

    if (gItemTable[itemID].typeFlags & ITEM_TYPE_FLAG_ENTITY_FULLSIZE) {
        item->flags = (item->flags | ITEM_ENTITY_FLAG_40000) & ~ITEM_ENTITY_RESIZABLE;
    }
    if (ItemEntityAlternatingSpawn != 0) {
        item->flags |= ITEM_ENTITY_FLAG_20000;
    }
    ItemEntityAlternatingSpawn = 1 - ItemEntityAlternatingSpawn;

    item->shadowIndex = create_shadow_type(0, item->position.x, item->position.y, item->position.z);
    shadow = get_shadow_by_index(item->shadowIndex);
    shadow->flags |= ENTITY_FLAG_HIDDEN;

    posX = item->position.x;
    posY = item->position.y + 12.0f;
    posZ = item->position.z;
    depth = 1000.0f;
    npc_raycast_down_sides(COLLISION_CHANNEL_20000, &posX, &posY, &posZ, &depth);
    shadow->position.x = posX;
    shadow->position.y = posY;
    shadow->position.z = posZ;

    shadow->rotation.x = gGameStatusPtr->playerGroundTraceAngles.x;
    shadow->rotation.y = 0.0f;
    shadow->rotation.z = gGameStatusPtr->playerGroundTraceAngles.z;
    set_standard_shadow_scale(shadow, depth * 0.5f);

    item_entity_load(item);
    if (item->itemID == ITEM_COIN) {
        sparkle_script_init(item, &SparkleScript_Coin);
        sparkle_script_update(item);
    }
    return id;
}


### RAW ASSEMBLY INSTRUCTIONS:

dlabel func_8025AA80
/* 189360 8025AA80 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* 189364 8025AA84 AFB20018 */  sw        $s2, 0x18($sp)
/* 189368 8025AA88 0080902D */  daddu     $s2, $a0, $zero
/* 18936C 8025AA8C AFB10014 */  sw        $s1, 0x14($sp)
/* 189370 8025AA90 00A0882D */  daddu     $s1, $a1, $zero
/* 189374 8025AA94 AFBF0024 */  sw        $ra, 0x24($sp)
/* 189378 8025AA98 AFB40020 */  sw        $s4, 0x20($sp)
/* 18937C 8025AA9C AFB3001C */  sw        $s3, 0x1C($sp)
/* 189380 8025AAA0 AFB00010 */  sw        $s0, 0x10($sp)
/* 189384 8025AAA4 8E3000C0 */  lw        $s0, 0xC0($s1)
/* 189388 8025AAA8 00C0982D */  daddu     $s3, $a2, $zero
/* 18938C 8025AAAC 820206C1 */  lb        $v0, 0x6C1($s0)
/* 189390 8025AAB0 10400032 */  beqz      $v0, .L8025AB7C
/* 189394 8025AAB4 00E0A02D */   daddu    $s4, $a3, $zero
/* 189398 8025AAB8 16400017 */  bnez      $s2, .L8025AB18
/* 18939C 8025AABC 00000000 */   nop
/* 1893A0 8025AAC0 0C0B7830 */  jal       spr_get_player_palettes
/* 1893A4 8025AAC4 96240088 */   lhu      $a0, 0x88($s1)
/* 1893A8 8025AAC8 AE0206D0 */  sw        $v0, 0x6D0($s0)
/* 1893AC 8025AACC 0040202D */  daddu     $a0, $v0, $zero
/* 1893B0 8025AAD0 A20006CD */  sb        $zero, 0x6CD($s0)
/* 1893B4 8025AAD4 8C830000 */  lw        $v1, 0x0($a0)
/* 1893B8 8025AAD8 2402FFFF */  addiu     $v0, $zero, -0x1
/* 1893BC 8025AADC 50620024 */  beql      $v1, $v0, .L8025AB70
/* 1893C0 8025AAE0 A20006C2 */   sb       $zero, 0x6C2($s0)
/* 1893C4 8025AAE4 0080182D */  daddu     $v1, $a0, $zero
/* 1893C8 8025AAE8 0040202D */  daddu     $a0, $v0, $zero
.L8025AAEC:
/* 1893CC 8025AAEC 920206CD */  lbu       $v0, 0x6CD($s0)
/* 1893D0 8025AAF0 24420001 */  addiu     $v0, $v0, 0x1
/* 1893D4 8025AAF4 A20206CD */  sb        $v0, 0x6CD($s0)
/* 1893D8 8025AAF8 00021600 */  sll       $v0, $v0, 24
/* 1893DC 8025AAFC 00021583 */  sra       $v0, $v0, 22
/* 1893E0 8025AB00 00431021 */  addu      $v0, $v0, $v1
/* 1893E4 8025AB04 8C420000 */  lw        $v0, 0x0($v0)
/* 1893E8 8025AB08 1444FFF8 */  bne       $v0, $a0, .L8025AAEC
/* 1893EC 8025AB0C 00000000 */   nop
/* 1893F0 8025AB10 08096ADC */  j         .L8025AB70
/* 1893F4 8025AB14 A20006C2 */   sb       $zero, 0x6C2($s0)
.L8025AB18:
/* 1893F8 8025AB18 96240088 */  lhu       $a0, 0x88($s1)
D_8025AB1C:
/* 1893FC 8025AB1C 0C0B7A90 */  jal       spr_get_npc_palettes
/* 189400 8025AB20 00000000 */   nop
/* 189404 8025AB24 AE0206D0 */  sw        $v0, 0x6D0($s0)
/* 189408 8025AB28 0040202D */  daddu     $a0, $v0, $zero
/* 18940C 8025AB2C A20006CD */  sb        $zero, 0x6CD($s0)
/* 189410 8025AB30 8C830000 */  lw        $v1, 0x0($a0)
/* 189414 8025AB34 2402FFFF */  addiu     $v0, $zero, -0x1
/* 189418 8025AB38 5062000D */  beql      $v1, $v0, .L8025AB70
/* 18941C 8025AB3C A20006C2 */   sb       $zero, 0x6C2($s0)
/* 189420 8025AB40 0080182D */  daddu     $v1, $a0, $zero
/* 189424 8025AB44 0040202D */  daddu     $a0, $v0, $zero
.L8025AB48:
/* 189428 8025AB48 920206CD */  lbu       $v0, 0x6CD($s0)
/* 18942C 8025AB4C 24420001 */  addiu     $v0, $v0, 0x1
/* 189430 8025AB50 A20206CD */  sb        $v0, 0x6CD($s0)
/* 189434 8025AB54 00021600 */  sll       $v0, $v0, 24
/* 189438 8025AB58 00021583 */  sra       $v0, $v0, 22
/* 18943C 8025AB5C 00431021 */  addu      $v0, $v0, $v1
/* 189440 8025AB60 8C420000 */  lw        $v0, 0x0($v0)
/* 189444 8025AB64 1444FFF8 */  bne       $v0, $a0, .L8025AB48
/* 189448 8025AB68 00000000 */   nop
/* 18944C 8025AB6C A20006C2 */  sb        $zero, 0x6C2($s0)
.L8025AB70:
/* 189450 8025AB70 A60006CA */  sh        $zero, 0x6CA($s0)
/* 189454 8025AB74 A20006C2 */  sb        $zero, 0x6C2($s0)
/* 189458 8025AB78 A20006C1 */  sb        $zero, 0x6C1($s0)
.L8025AB7C:
/* 18945C 8025AB7C 820206CD */  lb        $v0, 0x6CD($s0)
/* 189460 8025AB80 18400066 */  blez      $v0, .L8025AD1C
/* 189464 8025AB84 0000402D */   daddu    $t0, $zero, $zero
/* 189468 8025AB88 3C0B8000 */  lui       $t3, (0x80000000 >> 16)
/* 18946C 8025AB8C 3C01802A */  lui       $at, %hi(D_8029D408)
/* 189470 8025AB90 D428D408 */  ldc1      $f8, %lo(D_8029D408)($at)
/* 189474 8025AB94 3C0141E0 */  lui       $at, (0x41E00000 >> 16)
/* 189478 8025AB98 44811800 */  mtc1      $at, $f3
/* 18947C 8025AB9C 44801000 */  mtc1      $zero, $f2
/* 189480 8025ABA0 3C01802A */  lui       $at, %hi(D_8029D410)
/* 189484 8025ABA4 D426D410 */  ldc1      $f6, %lo(D_8029D410)($at)
/* 189488 8025ABA8 3C01802A */  lui       $at, %hi(D_8029D418)
/* 18948C 8025ABAC D424D418 */  ldc1      $f4, %lo(D_8029D418)($at)
.L8025ABB0:
/* 189490 8025ABB0 8E0206D0 */  lw        $v0, 0x6D0($s0)
/* 189494 8025ABB4 00081880 */  sll       $v1, $t0, 2
D_8025ABB8:
/* 189498 8025ABB8 00621821 */  addu      $v1, $v1, $v0
/* 18949C 8025ABBC 00081140 */  sll       $v0, $t0, 5
/* 1894A0 8025ABC0 8C670000 */  lw        $a3, 0x0($v1)
/* 1894A4 8025ABC4 10E0004F */  beqz      $a3, .L8025AD04
/* 1894A8 8025ABC8 02025021 */   addu     $t2, $s0, $v0
/* 1894AC 8025ABCC 0000482D */  daddu     $t1, $zero, $zero
.L8025ABD0:
/* 1894B0 8025ABD0 94E30000 */  lhu       $v1, 0x0($a3)
/* 1894B4 8025ABD4 000312C2 */  srl       $v0, $v1, 11
/* 1894B8 8025ABD8 44820000 */  mtc1      $v0, $f0
/* 1894BC 8025ABDC 00000000 */  nop
/* 1894C0 8025ABE0 46800021 */  cvt.d.w   $f0, $f0
/* 1894C4 8025ABE4 46280002 */  mul.d     $f0, $f0, $f8
/* 1894C8 8025ABE8 00000000 */  nop
/* 1894CC 8025ABEC 90E40001 */  lbu       $a0, 0x1($a3)
/* 1894D0 8025ABF0 24E70002 */  addiu     $a3, $a3, 0x2
/* 1894D4 8025ABF4 00031182 */  srl       $v0, $v1, 6
/* 1894D8 8025ABF8 3042001F */  andi      $v0, $v0, 0x1F
/* 1894DC 8025ABFC 00031842 */  srl       $v1, $v1, 1
/* 1894E0 8025AC00 3066001F */  andi      $a2, $v1, 0x1F
/* 1894E4 8025AC04 4620103E */  c.le.d    $f2, $f0
/* 1894E8 8025AC08 00000000 */  nop
/* 1894EC 8025AC0C 45010005 */  bc1t      .L8025AC24
/* 1894F0 8025AC10 30840001 */   andi     $a0, $a0, 0x1
/* 1894F4 8025AC14 4620028D */  trunc.w.d $f10, $f0
/* 1894F8 8025AC18 44035000 */  mfc1      $v1, $f10
/* 1894FC 8025AC1C 08096B0F */  j         .L8025AC3C
/* 189500 8025AC20 304200FF */   andi     $v0, $v0, 0xFF
.L8025AC24:
/* 189504 8025AC24 46220001 */  sub.d     $f0, $f0, $f2
/* 189508 8025AC28 4620028D */  trunc.w.d $f10, $f0
/* 18950C 8025AC2C 44035000 */  mfc1      $v1, $f10
/* 189510 8025AC30 00000000 */  nop
/* 189514 8025AC34 006B1825 */  or        $v1, $v1, $t3
/* 189518 8025AC38 304200FF */  andi      $v0, $v0, 0xFF
.L8025AC3C:
/* 18951C 8025AC3C 44820000 */  mtc1      $v0, $f0
/* 189520 8025AC40 00000000 */  nop
/* 189524 8025AC44 46800021 */  cvt.d.w   $f0, $f0
/* 189528 8025AC48 46260002 */  mul.d     $f0, $f0, $f6
/* 18952C 8025AC4C 00000000 */  nop
/* 189530 8025AC50 4620103E */  c.le.d    $f2, $f0
/* 189534 8025AC54 00000000 */  nop
/* 189538 8025AC58 45030005 */  bc1tl     .L8025AC70
/* 18953C 8025AC5C 46220001 */   sub.d    $f0, $f0, $f2
/* 189540 8025AC60 4620028D */  trunc.w.d $f10, $f0
/* 189544 8025AC64 44055000 */  mfc1      $a1, $f10
/* 189548 8025AC68 08096B21 */  j         .L8025AC84
/* 18954C 8025AC6C 30C200FF */   andi     $v0, $a2, 0xFF
.L8025AC70:
/* 189550 8025AC70 4620028D */  trunc.w.d $f10, $f0
/* 189554 8025AC74 44055000 */  mfc1      $a1, $f10
/* 189558 8025AC78 00000000 */  nop
/* 18955C 8025AC7C 00AB2825 */  or        $a1, $a1, $t3
/* 189560 8025AC80 30C200FF */  andi      $v0, $a2, 0xFF
.L8025AC84:
/* 189564 8025AC84 44820000 */  mtc1      $v0, $f0
/* 189568 8025AC88 00000000 */  nop
/* 18956C 8025AC8C 46800021 */  cvt.d.w   $f0, $f0
/* 189570 8025AC90 46240002 */  mul.d     $f0, $f0, $f4
/* 189574 8025AC94 00000000 */  nop
/* 189578 8025AC98 4620103E */  c.le.d    $f2, $f0
/* 18957C 8025AC9C 00000000 */  nop
/* 189580 8025ACA0 45010005 */  bc1t      .L8025ACB8
/* 189584 8025ACA4 00A0102D */   daddu    $v0, $a1, $zero
/* 189588 8025ACA8 4620028D */  trunc.w.d $f10, $f0
/* 18958C 8025ACAC 44055000 */  mfc1      $a1, $f10
/* 189590 8025ACB0 08096B34 */  j         .L8025ACD0
/* 189594 8025ACB4 306300FF */   andi     $v1, $v1, 0xFF
.L8025ACB8:
/* 189598 8025ACB8 46220001 */  sub.d     $f0, $f0, $f2
/* 18959C 8025ACBC 4620028D */  trunc.w.d $f10, $f0
/* 1895A0 8025ACC0 44055000 */  mfc1      $a1, $f10
/* 1895A4 8025ACC4 00000000 */  nop
/* 1895A8 8025ACC8 00AB2825 */  or        $a1, $a1, $t3
/* 1895AC 8025ACCC 306300FF */  andi      $v1, $v1, 0xFF
.L8025ACD0:
/* 1895B0 8025ACD0 00031AC0 */  sll       $v1, $v1, 11
/* 1895B4 8025ACD4 304200FF */  andi      $v0, $v0, 0xFF
/* 1895B8 8025ACD8 00021180 */  sll       $v0, $v0, 6
/* 1895BC 8025ACDC 00621825 */  or        $v1, $v1, $v0
/* 1895C0 8025ACE0 30A200FF */  andi      $v0, $a1, 0xFF
/* 1895C4 8025ACE4 00021040 */  sll       $v0, $v0, 1
/* 1895C8 8025ACE8 00621825 */  or        $v1, $v1, $v0
/* 1895CC 8025ACEC 00831825 */  or        $v1, $a0, $v1
/* 1895D0 8025ACF0 A5430000 */  sh        $v1, 0x0($t2)
/* 1895D4 8025ACF4 25290001 */  addiu     $t1, $t1, 0x1
/* 1895D8 8025ACF8 29220010 */  slti      $v0, $t1, 0x10
/* 1895DC 8025ACFC 1440FFB4 */  bnez      $v0, .L8025ABD0
/* 1895E0 8025AD00 254A0002 */   addiu    $t2, $t2, 0x2
.L8025AD04:
/* 1895E4 8025AD04 820206CD */  lb        $v0, 0x6CD($s0)
/* 1895E8 8025AD08 25080001 */  addiu     $t0, $t0, 0x1
/* 1895EC 8025AD0C 0102102A */  slt       $v0, $t0, $v0
/* 1895F0 8025AD10 1440FFA7 */  bnez      $v0, .L8025ABB0
/* 1895F4 8025AD14 00000000 */   nop
/* 1895F8 8025AD18 820206CD */  lb        $v0, 0x6CD($s0)
.L8025AD1C:
/* 1895FC 8025AD1C 1840000A */  blez      $v0, .L8025AD48
/* 189600 8025AD20 0000402D */   daddu    $t0, $zero, $zero
/* 189604 8025AD24 0200202D */  daddu     $a0, $s0, $zero
/* 189608 8025AD28 0200182D */  daddu     $v1, $s0, $zero
.L8025AD2C:
/* 18960C 8025AD2C AC6406D4 */  sw        $a0, 0x6D4($v1)
/* 189610 8025AD30 24840020 */  addiu     $a0, $a0, 0x20
/* 189614 8025AD34 820206CD */  lb        $v0, 0x6CD($s0)
/* 189618 8025AD38 25080001 */  addiu     $t0, $t0, 0x1
/* 18961C 8025AD3C 0102102A */  slt       $v0, $t0, $v0
/* 189620 8025AD40 1440FFFA */  bnez      $v0, .L8025AD2C
/* 189624 8025AD44 24630004 */   addiu    $v1, $v1, 0x4
.L8025AD48:
/* 189628 8025AD48 16400006 */  bnez      $s2, .L8025AD64
/* 18962C 8025AD4C 0220202D */   daddu    $a0, $s1, $zero
/* 189630 8025AD50 0260282D */  daddu     $a1, $s3, $zero
/* 189634 8025AD54 0C096657 */  jal       func_8025995C
/* 189638 8025AD58 0280302D */   daddu    $a2, $s4, $zero
/* 18963C 8025AD5C 08096B5C */  j         .L8025AD70
/* 189640 8025AD60 00000000 */   nop
.L8025AD64:
/* 189644 8025AD64 0260282D */  daddu     $a1, $s3, $zero
/* 189648 8025AD68 0C0965B0 */  jal       func_802596C0
/* 18964C 8025AD6C 0280302D */   daddu    $a2, $s4, $zero
.L8025AD70:
/* 189650 8025AD70 8FBF0024 */  lw        $ra, 0x24($sp)
/* 189654 8025AD74 8FB40020 */  lw        $s4, 0x20($sp)
/* 189658 8025AD78 8FB3001C */  lw        $s3, 0x1C($sp)
/* 18965C 8025AD7C 8FB20018 */  lw        $s2, 0x18($sp)
/* 189660 8025AD80 8FB10014 */  lw        $s1, 0x14($sp)
/* 189664 8025AD84 8FB00010 */  lw        $s0, 0x10($sp)
/* 189668 8025AD88 03E00008 */  jr        $ra
/* 18966C 8025AD8C 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

void render_with_berserk_palettes(b32 isNpcSprite, ActorPart* part, s32 yaw, Matrix4f mtx, b32 skipAnimation) {
    DecorationTable* decorationTable = part->decorationTable;
    s32 i, j;

    if (decorationTable->resetPalAdjust) {
        if (isNpcSprite == SPRITE_MODE_PLAYER) {
            decorationTable->originalPalettesList = spr_get_player_palettes(part->currentAnimation >> 16);
            decorationTable->originalPalettesCount = 0;
            while ((s32)decorationTable->originalPalettesList[decorationTable->originalPalettesCount] != -1) {
                decorationTable->originalPalettesCount++;
            }
            decorationTable->palAnimState = 0;
        } else {
            decorationTable->originalPalettesList = spr_get_npc_palettes(part->currentAnimation >> 16);
            decorationTable->originalPalettesCount = 0;
            while ((s32)decorationTable->originalPalettesList[decorationTable->originalPalettesCount] != -1) {
                decorationTable->originalPalettesCount++;
            }
            decorationTable->palAnimState = 0;
        }
        decorationTable->palBlendAlpha = 0;
        decorationTable->palAnimState = 0;
        decorationTable->resetPalAdjust = FALSE;
    }

    // adjust each palette
    for (i = 0; i < decorationTable->originalPalettesCount; i++) {
        PAL_PTR palIn = decorationTable->originalPalettesList[i];
        PAL_PTR palOut = decorationTable->copiedPalettes[0][i];
        if (palIn != NULL) {
            for (j = 0; j < SPR_PAL_SIZE; j++) {
                u8 r = UNPACK_PAL_R(*palIn);
                u8 g = UNPACK_PAL_G(*palIn);
                u8 b = UNPACK_PAL_B(*palIn);
                u8 a = UNPACK_PAL_A(*palIn);
                palIn++;

                // make each color darker and redder
                r *= 0.8;
                g *= 0.6;
                b *= 0.1;

                *palOut++ = PACK_PAL_RGBA(r, g, b, a);
            }
        }
    }

    for (i = 0; i < decorationTable->originalPalettesCount; i++) {
        decorationTable->adjustedPalettes[i] = decorationTable->copiedPalettes[0][i];
    }

    if (isNpcSprite == SPRITE_MODE_PLAYER) {
        func_8025995C(part, yaw, mtx);
    } else {
        func_802596C0(part, yaw, mtx);
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel state_init_title_screen
/* 121F0 80036DF0 27BDFFC8 */  addiu     $sp, $sp, -0x38
/* 121F4 80036DF4 AFB20028 */  sw        $s2, 0x28($sp)
/* 121F8 80036DF8 3C12800A */  lui       $s2, %hi(gOverrideFlags)
/* 121FC 80036DFC 2652A650 */  addiu     $s2, $s2, %lo(gOverrideFlags)
/* 12200 80036E00 24020001 */  addiu     $v0, $zero, 0x1
/* 12204 80036E04 AFBF002C */  sw        $ra, 0x2C($sp)
/* 12208 80036E08 AFB10024 */  sw        $s1, 0x24($sp)
/* 1220C 80036E0C AFB00020 */  sw        $s0, 0x20($sp)
/* 12210 80036E10 F7B40030 */  sdc1      $f20, 0x30($sp)
/* 12214 80036E14 AE400000 */  sw        $zero, 0x0($s2)
/* 12218 80036E18 3C01800A */  lui       $at, %hi(timeFreezeMode)
/* 1221C 80036E1C AC20A5D8 */  sw        $zero, %lo(timeFreezeMode)($at)
/* 12220 80036E20 3C018015 */  lui       $at, %hi(D_8014C248)
/* 12224 80036E24 A022C248 */  sb        $v0, %lo(D_8014C248)($at)
/* 12228 80036E28 0C00AB00 */  jal       general_heap_create
/* 1222C 80036E2C 00000000 */   nop
/* 12230 80036E30 0C048D9D */  jal       clear_printers
/* 12234 80036E34 00000000 */   nop
/* 12238 80036E38 0C0525FF */  jal       sfx_set_reverb_mode
/* 1223C 80036E3C 0000202D */   daddu    $a0, $zero, $zero
/* 12240 80036E40 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* 12244 80036E44 2463419C */  addiu     $v1, $v1, %lo(gGameStatusPtr)
/* 12248 80036E48 8C620000 */  lw        $v0, 0x0($v1)
/* 1224C 80036E4C A04000AC */  sb        $zero, 0xAC($v0)
/* 12250 80036E50 8C620000 */  lw        $v0, 0x0($v1)
/* 12254 80036E54 A04000AD */  sb        $zero, 0xAD($v0)
/* 12258 80036E58 8C620000 */  lw        $v0, 0x0($v1)
/* 1225C 80036E5C A0400070 */  sb        $zero, 0x70($v0)
/* 12260 80036E60 8C630000 */  lw        $v1, 0x0($v1)
/* 12264 80036E64 2402FFFF */  addiu     $v0, $zero, -0x1
/* 12268 80036E68 0C00CE1D */  jal       intro_logos_update_fade
/* 1226C 80036E6C A06200A8 */   sb       $v0, 0xA8($v1)
/* 12270 80036E70 3C04800A */  lui       $a0, %hi(D_80098390)
/* 12274 80036E74 24848390 */  addiu     $a0, $a0, %lo(D_80098390)
/* 12278 80036E78 0C016B3A */  jal       load_asset_by_name
/* 1227C 80036E7C 27A50018 */   addiu    $a1, $sp, 0x18
/* 12280 80036E80 8FA40018 */  lw        $a0, 0x18($sp)
/* 12284 80036E84 0C00AB39 */  jal       heap_malloc
/* 12288 80036E88 0040882D */   daddu    $s1, $v0, $zero
/* 1228C 80036E8C 0220202D */  daddu     $a0, $s1, $zero
/* 12290 80036E90 0040282D */  daddu     $a1, $v0, $zero
/* 12294 80036E94 3C10800A */  lui       $s0, %hi(TitleScreen_ImgList)
/* 12298 80036E98 26100974 */  addiu     $s0, $s0, %lo(TitleScreen_ImgList)
/* 1229C 80036E9C 0C01BB7C */  jal       decode_yay0
/* 122A0 80036EA0 AE050000 */   sw       $a1, 0x0($s0)
/* 122A4 80036EA4 0C00AB1E */  jal       general_heap_free
/* 122A8 80036EA8 0220202D */   daddu    $a0, $s1, $zero
/* 122AC 80036EAC 8E040000 */  lw        $a0, 0x0($s0)
/* 122B0 80036EB0 8C820000 */  lw        $v0, 0x0($a0)
/* 122B4 80036EB4 8C830008 */  lw        $v1, 0x8($a0)
/* 122B8 80036EB8 00441021 */  addu      $v0, $v0, $a0
/* 122BC 80036EBC 3C01800A */  lui       $at, %hi(TitleScreen_ImgList_Logo)
/* 122C0 80036EC0 AC220978 */  sw        $v0, %lo(TitleScreen_ImgList_Logo)($at)
/* 122C4 80036EC4 8C820004 */  lw        $v0, 0x4($a0)
/* 122C8 80036EC8 00641821 */  addu      $v1, $v1, $a0
/* 122CC 80036ECC 3C01800A */  lui       $at, %hi(TitleScreen_ImgList_PressStart)
/* 122D0 80036ED0 AC230980 */  sw        $v1, %lo(TitleScreen_ImgList_PressStart)($at)
/* 122D4 80036ED4 00441021 */  addu      $v0, $v0, $a0
/* 122D8 80036ED8 3C01800A */  lui       $at, %hi(TitleScreen_ImgList_Copyright)
/* 122DC 80036EDC AC22097C */  sw        $v0, %lo(TitleScreen_ImgList_Copyright)($at)
/* 122E0 80036EE0 0C00B7BD */  jal       create_cameras_a
/* 122E4 80036EE4 00000000 */   nop
/* 122E8 80036EE8 0000202D */  daddu     $a0, $zero, $zero
/* 122EC 80036EEC 2405000C */  addiu     $a1, $zero, 0xC
/* 122F0 80036EF0 2406001C */  addiu     $a2, $zero, 0x1C
/* 122F4 80036EF4 24070128 */  addiu     $a3, $zero, 0x128
/* 122F8 80036EF8 3C10800B */  lui       $s0, %hi(gCameras)
/* 122FC 80036EFC 26101D80 */  addiu     $s0, $s0, %lo(gCameras)
/* 12300 80036F00 3C0141C8 */  lui       $at, (0x41C80000 >> 16)
/* 12304 80036F04 4481A000 */  mtc1      $at, $f20
/* 12308 80036F08 24020006 */  addiu     $v0, $zero, 0x6
/* 1230C 80036F0C A6020004 */  sh        $v0, 0x4($s0)
/* 12310 80036F10 24020001 */  addiu     $v0, $zero, 0x1
/* 12314 80036F14 A6020006 */  sh        $v0, 0x6($s0)
/* 12318 80036F18 24020010 */  addiu     $v0, $zero, 0x10
/* 1231C 80036F1C A6020012 */  sh        $v0, 0x12($s0)
/* 12320 80036F20 24021000 */  addiu     $v0, $zero, 0x1000
/* 12324 80036F24 A6020014 */  sh        $v0, 0x14($s0)
/* 12328 80036F28 240200B8 */  addiu     $v0, $zero, 0xB8
/* 1232C 80036F2C 3C018007 */  lui       $at, %hi(gCurrentCameraID)
/* 12330 80036F30 AC207410 */  sw        $zero, %lo(gCurrentCameraID)($at)
/* 12334 80036F34 E6140018 */  swc1      $f20, 0x18($s0)
/* 12338 80036F38 AFA20010 */  sw        $v0, 0x10($sp)
/* 1233C 80036F3C 96020000 */  lhu       $v0, 0x0($s0)
/* 12340 80036F40 96030558 */  lhu       $v1, 0x558($s0)
/* 12344 80036F44 34420002 */  ori       $v0, $v0, 0x2
/* 12348 80036F48 A6020000 */  sh        $v0, 0x0($s0)
/* 1234C 80036F4C 96020AB0 */  lhu       $v0, 0xAB0($s0)
/* 12350 80036F50 34630002 */  ori       $v1, $v1, 0x2
/* 12354 80036F54 A6030558 */  sh        $v1, 0x558($s0)
/* 12358 80036F58 96031008 */  lhu       $v1, 0x1008($s0)
/* 1235C 80036F5C 34420002 */  ori       $v0, $v0, 0x2
/* 12360 80036F60 34630002 */  ori       $v1, $v1, 0x2
/* 12364 80036F64 A6020AB0 */  sh        $v0, 0xAB0($s0)
/* 12368 80036F68 0C00B8C5 */  jal       set_cam_viewport
/* 1236C 80036F6C A6031008 */   sh       $v1, 0x1008($s0)
/* 12370 80036F70 3C0143FA */  lui       $at, (0x43FA0000 >> 16)
/* 12374 80036F74 44810000 */  mtc1      $at, $f0
/* 12378 80036F78 3C01447A */  lui       $at, (0x447A0000 >> 16)
/* 1237C 80036F7C 44811000 */  mtc1      $at, $f2
/* 12380 80036F80 3C0144BB */  lui       $at, (0x44BB8000 >> 16)
/* 12384 80036F84 34218000 */  ori       $at, $at, (0x44BB8000 & 0xFFFF)
/* 12388 80036F88 44812000 */  mtc1      $at, $f4
/* 1238C 80036F8C 3C014316 */  lui       $at, (0x43160000 >> 16)
/* 12390 80036F90 44813000 */  mtc1      $at, $f6
/* 12394 80036F94 24020028 */  addiu     $v0, $zero, 0x28
/* 12398 80036F98 A602001E */  sh        $v0, 0x1E($s0)
/* 1239C 80036F9C 24020064 */  addiu     $v0, $zero, 0x64
/* 123A0 80036FA0 A600002C */  sh        $zero, 0x2C($s0)
/* 123A4 80036FA4 A600002E */  sh        $zero, 0x2E($s0)
/* 123A8 80036FA8 A6000030 */  sh        $zero, 0x30($s0)
/* 123AC 80036FAC E6140054 */  swc1      $f20, 0x54($s0)
/* 123B0 80036FB0 E6140058 */  swc1      $f20, 0x58($s0)
/* 123B4 80036FB4 A600001C */  sh        $zero, 0x1C($s0)
/* 123B8 80036FB8 A6020020 */  sh        $v0, 0x20($s0)
/* 123BC 80036FBC A6000022 */  sh        $zero, 0x22($s0)
/* 123C0 80036FC0 E600003C */  swc1      $f0, 0x3C($s0)
/* 123C4 80036FC4 E6020040 */  swc1      $f2, 0x40($s0)
/* 123C8 80036FC8 E6040044 */  swc1      $f4, 0x44($s0)
/* 123CC 80036FCC 0C0B0C77 */  jal       clear_script_list
/* 123D0 80036FD0 E606005C */   swc1     $f6, 0x5C($s0)
/* 123D4 80036FD4 0C048C2E */  jal       clear_worker_list
/* 123D8 80036FD8 00000000 */   nop
/* 123DC 80036FDC 0C047624 */  jal       clear_render_tasks
/* 123E0 80036FE0 00000000 */   nop
/* 123E4 80036FE4 0C0B763E */  jal       spr_init_sprites
/* 123E8 80036FE8 0000202D */   daddu    $a0, $zero, $zero
/* 123EC 80036FEC 0C047889 */  jal       clear_animator_list
/* 123F0 80036FF0 00000000 */   nop
/* 123F4 80036FF4 0C0482EC */  jal       clear_entity_models
/* 123F8 80036FF8 00000000 */   nop
/* 123FC 80036FFC 0C00E12F */  jal       clear_npcs
/* 12400 80037000 00000000 */   nop
/* 12404 80037004 0C050440 */  jal       hud_element_clear_cache
/* 12408 80037008 00000000 */   nop
/* 1240C 8003700C 0C05177E */  jal       reset_background_settings
/* 12410 80037010 00000000 */   nop
/* 12414 80037014 0C04432E */  jal       clear_entity_data
/* 12418 80037018 24040001 */   addiu    $a0, $zero, 0x1
/* 1241C 8003701C 0C016727 */  jal       clear_effect_data
/* 12420 80037020 00000000 */   nop
/* 12424 80037024 8E420000 */  lw        $v0, 0x0($s2)
/* 12428 80037028 34420002 */  ori       $v0, $v0, 0x2
/* 1242C 8003702C 0C039CE8 */  jal       clear_player_data
/* 12430 80037030 AE420000 */   sw       $v0, 0x0($s2)
/* 12434 80037034 0000202D */  daddu     $a0, $zero, $zero
/* 12438 80037038 3C058003 */  lui       $a1, %hi(appendGfx_title_screen)
/* 1243C 8003703C 24A57638 */  addiu     $a1, $a1, %lo(appendGfx_title_screen)
/* 12440 80037040 8E420000 */  lw        $v0, 0x0($s2)
/* 12444 80037044 2403FFF7 */  addiu     $v1, $zero, -0x9
/* 12448 80037048 00431024 */  and       $v0, $v0, $v1
/* 1244C 8003704C 0C044B61 */  jal       game_mode_set_fpDrawAuxUI
/* 12450 80037050 AE420000 */   sw       $v0, 0x0($s2)
/* 12454 80037054 3C04800A */  lui       $a0, %hi(D_8009839C)
/* 12458 80037058 0C05175C */  jal       load_map_bg
/* 1245C 8003705C 2484839C */   addiu    $a0, $a0, %lo(D_8009839C)
/* 12460 80037060 3C048020 */  lui       $a0, %hi(vtx_C20F40)
/* 12464 80037064 24840000 */  addiu     $a0, $a0, %lo(vtx_C20F40)
/* 12468 80037068 0C05178A */  jal       read_background_size
/* 1246C 8003706C 00000000 */   nop
/* 12470 80037070 0000202D */  daddu     $a0, $zero, $zero
/* 12474 80037074 2405006A */  addiu     $a1, $zero, 0x6A
/* 12478 80037078 0080302D */  daddu     $a2, $a0, $zero
/* 1247C 8003707C 240701F4 */  addiu     $a3, $zero, 0x1F4
/* 12480 80037080 24020008 */  addiu     $v0, $zero, 0x8
/* 12484 80037084 0C052A46 */  jal       bgm_set_song
/* 12488 80037088 AFA20010 */   sw       $v0, 0x10($sp)
/* 1248C 8003708C 8FBF002C */  lw        $ra, 0x2C($sp)
/* 12490 80037090 8FB20028 */  lw        $s2, 0x28($sp)
/* 12494 80037094 8FB10024 */  lw        $s1, 0x24($sp)
/* 12498 80037098 8FB00020 */  lw        $s0, 0x20($sp)
/* 1249C 8003709C D7B40030 */  ldc1      $f20, 0x30($sp)
/* 124A0 800370A0 240201E0 */  addiu     $v0, $zero, 0x1E0
/* 124A4 800370A4 3C01800A */  lui       $at, %hi(D_800A0988)
/* 124A8 800370A8 A4220988 */  sh        $v0, %lo(D_800A0988)($at)
/* 124AC 800370AC 03E00008 */  jr        $ra
/* 124B0 800370B0 27BD0038 */   addiu    $sp, $sp, 0x38

### DECOMPILED C INSTRUCTIONS:

void state_init_title_screen(void) {
    s32 titleDataSize;
    void* titleDataDst;
    void* titleData;

    gOverrideFlags = 0;
    timeFreezeMode = 0;
    D_8014C248[0] = 1;
    general_heap_create();
    clear_printers();
    sfx_set_reverb_mode(0);
    gGameStatusPtr->introState = INTRO_STATE_0;
    gGameStatusPtr->introCounter = 0;
    gGameStatusPtr->isBattle = FALSE;
    gGameStatusPtr->creditsViewportMode = -1;
    intro_logos_update_fade();
    titleData = load_asset_by_name("title_data", &titleDataSize);
    titleDataDst = TitleScreen_ImgList = heap_malloc(titleDataSize);
    decode_yay0(titleData, titleDataDst);
    general_heap_free(titleData);

    TitleScreen_ImgList_Logo = (s32*)(TitleScreen_ImgList->logo + (s32) TitleScreen_ImgList);
    TitleScreen_ImgList_Copyright = (u8 (*)[COPYRIGHT_WIDTH]) ((s32*)(TitleScreen_ImgList->copyright + (s32) TitleScreen_ImgList));
    TitleScreen_ImgList_PressStart = (s32*)(TitleScreen_ImgList->pressStart + (s32) TitleScreen_ImgList);
#if VERSION_JP
    TitleScreen_ImgList_CopyrightPalette = (s32*)(TitleScreen_ImgList->copyrightPalette + (s32) TitleScreen_ImgList);
#endif

    create_cameras_a();
    gCameras[CAM_DEFAULT].updateMode = CAM_UPDATE_MODE_6;
    gCameras[CAM_DEFAULT].needsInit = TRUE;
    gCameras[CAM_DEFAULT].nearClip = CAM_NEAR_CLIP;
    gCameras[CAM_DEFAULT].farClip = CAM_FAR_CLIP;
    gCurrentCameraID = CAM_DEFAULT;
    gCameras[CAM_DEFAULT].vfov = 25.0f;
    gCameras[CAM_DEFAULT].flags |= CAMERA_FLAG_DISABLED;
    gCameras[CAM_BATTLE].flags |= CAMERA_FLAG_DISABLED;
    gCameras[CAM_TATTLE].flags |= CAMERA_FLAG_DISABLED;
    gCameras[CAM_3].flags |= CAMERA_FLAG_DISABLED;
    set_cam_viewport(0, 12, 28, 296, 184);
    gCameras[CAM_DEFAULT].auxBoomLength = 40;
    gCameras[CAM_DEFAULT].bgColor[0] = 0;
    gCameras[CAM_DEFAULT].bgColor[1] = 0;
    gCameras[CAM_DEFAULT].bgColor[2] = 0;
    gCameras[CAM_DEFAULT].lookAt_obj_target.x = 25.0f;
    gCameras[CAM_DEFAULT].lookAt_obj_target.y = 25.0f;
    gCameras[CAM_DEFAULT].auxPitch = 0;
    gCameras[CAM_DEFAULT].lookAt_dist = 100;
    gCameras[CAM_DEFAULT].auxBoomPitch = 0;
    gCameras[CAM_DEFAULT].lookAt_eye.x = 500.0f;
    gCameras[CAM_DEFAULT].lookAt_eye.y = 1000.0f;
    gCameras[CAM_DEFAULT].lookAt_eye.z = 1500.0f;
    gCameras[CAM_DEFAULT].lookAt_obj_target.z = 150.0f;
    clear_script_list();
    clear_worker_list();
    clear_render_tasks();
    spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD);
    clear_animator_list();
    clear_entity_models();
    clear_npcs();
    hud_element_clear_cache();
    reset_background_settings();
    clear_entity_data(1);
    clear_effect_data();
    gOverrideFlags |= GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
    clear_player_data();
    gOverrideFlags &= ~GLOBAL_OVERRIDES_8;
    game_mode_set_fpDrawAuxUI(0, appendGfx_title_screen);
    load_map_bg("title_bg");
    read_background_size(&gBackgroundImage);
    bgm_set_song(0, SONG_MAIN_THEME, 0, 500, 8);
    D_800A0988 = 480;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel BoostAttack
/* 19E5B4 8026FCD4 27BDFFC0 */  addiu     $sp, $sp, -0x40
/* 19E5B8 8026FCD8 AFB20020 */  sw        $s2, 0x20($sp)
/* 19E5BC 8026FCDC 0080902D */  daddu     $s2, $a0, $zero
/* 19E5C0 8026FCE0 AFBF0024 */  sw        $ra, 0x24($sp)
/* 19E5C4 8026FCE4 AFB1001C */  sw        $s1, 0x1C($sp)
/* 19E5C8 8026FCE8 AFB00018 */  sw        $s0, 0x18($sp)
/* 19E5CC 8026FCEC F7B80038 */  sdc1      $f24, 0x38($sp)
gPauseWS_18:
/* 19E5D0 8026FCF0 F7B60030 */  sdc1      $f22, 0x30($sp)
/* 19E5D4 8026FCF4 F7B40028 */  sdc1      $f20, 0x28($sp)
/* 19E5D8 8026FCF8 8E51000C */  lw        $s1, 0xC($s2)
/* 19E5DC 8026FCFC 54A00001 */  bnel      $a1, $zero, .L8026FD04
/* 19E5E0 8026FD00 AE400070 */   sw       $zero, 0x70($s2)
.L8026FD04:
/* 19E5E4 8026FD04 8E420070 */  lw        $v0, 0x70($s2)
/* 19E5E8 8026FD08 1440002D */  bnez      $v0, .L8026FDC0
/* 19E5EC 8026FD0C 00000000 */   nop
/* 19E5F0 8026FD10 8E250000 */  lw        $a1, 0x0($s1)
/* 19E5F4 8026FD14 26310004 */  addiu     $s1, $s1, 0x4
/* 19E5F8 8026FD18 0C0B1EAF */  jal       evt_get_variable
/* 19E5FC 8026FD1C 0240202D */   daddu    $a0, $s2, $zero
/* 19E600 8026FD20 0040802D */  daddu     $s0, $v0, $zero
/* 19E604 8026FD24 2402FF81 */  addiu     $v0, $zero, -0x7F
gPauseWS_19:
/* 19E608 8026FD28 16020002 */  bne       $s0, $v0, .L8026FD34
/* 19E60C 8026FD2C 00000000 */   nop
/* 19E610 8026FD30 8E500148 */  lw        $s0, 0x148($s2)
.L8026FD34:
/* 19E614 8026FD34 8E250000 */  lw        $a1, 0x0($s1)
/* 19E618 8026FD38 0C0B1EAF */  jal       evt_get_variable
/* 19E61C 8026FD3C 0240202D */   daddu    $a0, $s2, $zero
/* 19E620 8026FD40 0040882D */  daddu     $s1, $v0, $zero
/* 19E624 8026FD44 0C09A75B */  jal       get_actor
/* 19E628 8026FD48 0200202D */   daddu    $a0, $s0, $zero
/* 19E62C 8026FD4C 0040802D */  daddu     $s0, $v0, $zero
/* 19E630 8026FD50 24040008 */  addiu     $a0, $zero, 0x8
/* 19E634 8026FD54 AE500074 */  sw        $s0, 0x74($s2)
/* 19E638 8026FD58 0C093903 */  jal       func_8024E40C
/* 19E63C 8026FD5C AE510078 */   sw       $s1, 0x78($s2)
gPauseWS_20:
/* 19E640 8026FD60 0C093978 */  jal       func_8024E5E0
/* 19E644 8026FD64 2404000C */   addiu    $a0, $zero, 0xC
/* 19E648 8026FD68 86040192 */  lh        $a0, 0x192($s0)
/* 19E64C 8026FD6C 0C09390F */  jal       func_8024E43C
/* 19E650 8026FD70 00000000 */   nop
/* 19E654 8026FD74 0C093965 */  jal       func_8024E594
/* 19E658 8026FD78 240400FA */   addiu    $a0, $zero, 0xFA
/* 19E65C 8026FD7C 0C093936 */  jal       D_8024E4D8_C0BD58
/* 19E660 8026FD80 2404000A */   addiu    $a0, $zero, 0xA
/* 19E664 8026FD84 0C093983 */  jal       func_8024E60C
/* 19E668 8026FD88 00000000 */   nop
/* 19E66C 8026FD8C 8E020000 */  lw        $v0, 0x0($s0)
/* 19E670 8026FD90 30420800 */  andi      $v0, $v0, 0x800
/* 19E674 8026FD94 10400004 */  beqz      $v0, .L8026FDA8
gPauseWS_21:
/* 19E678 8026FD98 24020001 */   addiu    $v0, $zero, 0x1
/* 19E67C 8026FD9C 0C093978 */  jal       func_8024E5E0
/* 19E680 8026FDA0 0000202D */   daddu    $a0, $zero, $zero
/* 19E684 8026FDA4 24020001 */  addiu     $v0, $zero, 0x1
.L8026FDA8:
/* 19E688 8026FDA8 3C01802A */  lui       $at, %hi(D_8029FBD4)
/* 19E68C 8026FDAC A022FBD4 */  sb        $v0, %lo(D_8029FBD4)($at)
/* 19E690 8026FDB0 24020005 */  addiu     $v0, $zero, 0x5
/* 19E694 8026FDB4 AE42007C */  sw        $v0, 0x7C($s2)
/* 19E698 8026FDB8 24020001 */  addiu     $v0, $zero, 0x1
/* 19E69C 8026FDBC AE420070 */  sw        $v0, 0x70($s2)
.L8026FDC0:
/* 19E6A0 8026FDC0 0C09A75B */  jal       get_actor
/* 19E6A4 8026FDC4 8E440148 */   lw       $a0, 0x148($s2)
/* 19E6A8 8026FDC8 8E500074 */  lw        $s0, 0x74($s2)
/* 19E6AC 8026FDCC 8E510078 */  lw        $s1, 0x78($s2)
gPauseWS_22:
/* 19E6B0 8026FDD0 86020150 */  lh        $v0, 0x150($s0)
/* 19E6B4 8026FDD4 8E030000 */  lw        $v1, 0x0($s0)
/* 19E6B8 8026FDD8 C6000144 */  lwc1      $f0, 0x144($s0)
/* 19E6BC 8026FDDC 44821000 */  mtc1      $v0, $f2
/* 19E6C0 8026FDE0 00000000 */  nop
/* 19E6C4 8026FDE4 468010A0 */  cvt.s.w   $f2, $f2
/* 19E6C8 8026FDE8 30620800 */  andi      $v0, $v1, 0x800
/* 19E6CC 8026FDEC 1040000E */  beqz      $v0, .L8026FE28
/* 19E6D0 8026FDF0 46020280 */   add.s    $f10, $f0, $f2
/* 19E6D4 8026FDF4 86020152 */  lh        $v0, 0x152($s0)
/* 19E6D8 8026FDF8 C6020148 */  lwc1      $f2, 0x148($s0)
/* 19E6DC 8026FDFC 44820000 */  mtc1      $v0, $f0
/* 19E6E0 8026FE00 00000000 */  nop
/* 19E6E4 8026FE04 46800020 */  cvt.s.w   $f0, $f0
gPauseWS_23:
/* 19E6E8 8026FE08 92020191 */  lbu       $v0, 0x191($s0)
/* 19E6EC 8026FE0C 46001080 */  add.s     $f2, $f2, $f0
/* 19E6F0 8026FE10 00021042 */  srl       $v0, $v0, 1
/* 19E6F4 8026FE14 44820000 */  mtc1      $v0, $f0
/* 19E6F8 8026FE18 00000000 */  nop
/* 19E6FC 8026FE1C 46800020 */  cvt.s.w   $f0, $f0
/* 19E700 8026FE20 0809BFA5 */  j         .L8026FE94
/* 19E704 8026FE24 46001181 */   sub.s    $f6, $f2, $f0
.L8026FE28:
/* 19E708 8026FE28 30628000 */  andi      $v0, $v1, 0x8000
/* 19E70C 8026FE2C 1440000E */  bnez      $v0, .L8026FE68
/* 19E710 8026FE30 00000000 */   nop
/* 19E714 8026FE34 86020152 */  lh        $v0, 0x152($s0)
/* 19E718 8026FE38 C6020148 */  lwc1      $f2, 0x148($s0)
/* 19E71C 8026FE3C 44820000 */  mtc1      $v0, $f0
gPauseWS_24:
/* 19E720 8026FE40 00000000 */  nop
/* 19E724 8026FE44 46800020 */  cvt.s.w   $f0, $f0
/* 19E728 8026FE48 92020191 */  lbu       $v0, 0x191($s0)
/* 19E72C 8026FE4C 46001080 */  add.s     $f2, $f2, $f0
/* 19E730 8026FE50 00021042 */  srl       $v0, $v0, 1
/* 19E734 8026FE54 44820000 */  mtc1      $v0, $f0
/* 19E738 8026FE58 00000000 */  nop
/* 19E73C 8026FE5C 46800020 */  cvt.s.w   $f0, $f0
/* 19E740 8026FE60 0809BFA5 */  j         .L8026FE94
/* 19E744 8026FE64 46020180 */   add.s    $f6, $f0, $f2
.L8026FE68:
/* 19E748 8026FE68 86020152 */  lh        $v0, 0x152($s0)
/* 19E74C 8026FE6C C6000148 */  lwc1      $f0, 0x148($s0)
/* 19E750 8026FE70 44821000 */  mtc1      $v0, $f2
/* 19E754 8026FE74 00000000 */  nop
gPauseWS_25:
/* 19E758 8026FE78 468010A0 */  cvt.s.w   $f2, $f2
/* 19E75C 8026FE7C 92020191 */  lbu       $v0, 0x191($s0)
/* 19E760 8026FE80 46020000 */  add.s     $f0, $f0, $f2
/* 19E764 8026FE84 44821000 */  mtc1      $v0, $f2
/* 19E768 8026FE88 00000000 */  nop
/* 19E76C 8026FE8C 468010A0 */  cvt.s.w   $f2, $f2
/* 19E770 8026FE90 46020180 */  add.s     $f6, $f0, $f2
.L8026FE94:
/* 19E774 8026FE94 86020154 */  lh        $v0, 0x154($s0)
/* 19E778 8026FE98 86030150 */  lh        $v1, 0x150($s0)
/* 19E77C 8026FE9C C600014C */  lwc1      $f0, 0x14C($s0)
/* 19E780 8026FEA0 44821000 */  mtc1      $v0, $f2
/* 19E784 8026FEA4 00000000 */  nop
/* 19E788 8026FEA8 468010A0 */  cvt.s.w   $f2, $f2
/* 19E78C 8026FEAC 44832000 */  mtc1      $v1, $f4
gPauseWS_26:
/* 19E790 8026FEB0 00000000 */  nop
/* 19E794 8026FEB4 46802120 */  cvt.s.w   $f4, $f4
/* 19E798 8026FEB8 92020190 */  lbu       $v0, 0x190($s0)
/* 19E79C 8026FEBC 46020000 */  add.s     $f0, $f0, $f2
/* 19E7A0 8026FEC0 3C014120 */  lui       $at, (0x41200000 >> 16)
/* 19E7A4 8026FEC4 44811000 */  mtc1      $at, $f2
/* 19E7A8 8026FEC8 8E030000 */  lw        $v1, 0x0($s0)
/* 19E7AC 8026FECC 46020200 */  add.s     $f8, $f0, $f2
/* 19E7B0 8026FED0 C6000144 */  lwc1      $f0, 0x144($s0)
/* 19E7B4 8026FED4 00021042 */  srl       $v0, $v0, 1
/* 19E7B8 8026FED8 46040000 */  add.s     $f0, $f0, $f4
/* 19E7BC 8026FEDC 44821000 */  mtc1      $v0, $f2
/* 19E7C0 8026FEE0 00000000 */  nop
/* 19E7C4 8026FEE4 468010A0 */  cvt.s.w   $f2, $f2
gPauseWS_27:
/* 19E7C8 8026FEE8 30620800 */  andi      $v0, $v1, 0x800
/* 19E7CC 8026FEEC 1040000D */  beqz      $v0, .L8026FF24
/* 19E7D0 8026FEF0 46020600 */   add.s    $f24, $f0, $f2
/* 19E7D4 8026FEF4 86020152 */  lh        $v0, 0x152($s0)
/* 19E7D8 8026FEF8 C6000148 */  lwc1      $f0, 0x148($s0)
/* 19E7DC 8026FEFC 44821000 */  mtc1      $v0, $f2
/* 19E7E0 8026FF00 00000000 */  nop
/* 19E7E4 8026FF04 468010A0 */  cvt.s.w   $f2, $f2
/* 19E7E8 8026FF08 92020191 */  lbu       $v0, 0x191($s0)
/* 19E7EC 8026FF0C 46020000 */  add.s     $f0, $f0, $f2
/* 19E7F0 8026FF10 44821000 */  mtc1      $v0, $f2
/* 19E7F4 8026FF14 00000000 */  nop
/* 19E7F8 8026FF18 468010A0 */  cvt.s.w   $f2, $f2
/* 19E7FC 8026FF1C 0809BFE4 */  j         D_8026FF90
gPauseWS_28:
/* 19E800 8026FF20 46020501 */   sub.s    $f20, $f0, $f2
.L8026FF24:
/* 19E804 8026FF24 30628000 */  andi      $v0, $v1, 0x8000
/* 19E808 8026FF28 1440000D */  bnez      $v0, D_8026FF60
/* 19E80C 8026FF2C 00000000 */   nop
/* 19E810 8026FF30 86020152 */  lh        $v0, 0x152($s0)
/* 19E814 8026FF34 C6000148 */  lwc1      $f0, 0x148($s0)
/* 19E818 8026FF38 44821000 */  mtc1      $v0, $f2
/* 19E81C 8026FF3C 00000000 */  nop
/* 19E820 8026FF40 468010A0 */  cvt.s.w   $f2, $f2
/* 19E824 8026FF44 92020191 */  lbu       $v0, 0x191($s0)
/* 19E828 8026FF48 46020000 */  add.s     $f0, $f0, $f2
/* 19E82C 8026FF4C 44821000 */  mtc1      $v0, $f2
/* 19E830 8026FF50 00000000 */  nop
/* 19E834 8026FF54 468010A0 */  cvt.s.w   $f2, $f2
/* 19E838 8026FF58 0809BFE4 */  j         D_8026FF90
/* 19E83C 8026FF5C 46001500 */   add.s    $f20, $f2, $f0

### DECOMPILED C INSTRUCTIONS:

ApiStatus BoostAttack(Evt* script, s32 isInitialCall) {
    Bytecode* args = script->ptrReadPos;
    s32 actorID;
    Actor* actor;
    s32 flags;
    s32 flags2;
    f32 x1, y1, z1;
    f32 x2, y2, z2;
    s32 attackBoost;

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

    if (script->functionTemp[0] == 0) {
        actorID = evt_get_variable(script, *args++);
        if (actorID == ACTOR_SELF) {
            actorID = script->owner1.actorID;
        }
        attackBoost = evt_get_variable(script, *args++);
        actor = get_actor(actorID);
        script->functionTempPtr[1] = actor;
        script->functionTemp[2] = attackBoost;

        btl_cam_use_preset(BTL_CAM_PRESET_08);
        btl_cam_set_zoffset(12);
        btl_cam_target_actor(actor->actorID);
        btl_cam_set_zoom(250);
        btl_cam_move(10);
        func_8024E60C();
        if (actor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
            btl_cam_set_zoffset(0);
        }
        D_8029FBD4 = 1;
        script->functionTemp[3] = 5;
        script->functionTemp[0] = 1;
    }
    get_actor(script->owner1.actorID);
    actor = script->functionTempPtr[1];
    attackBoost = script->functionTemp[2];

    flags = actor->flags;
    x1 = actor->currentPos.x + actor->headOffset.x;
    if (flags & ACTOR_FLAG_UPSIDE_DOWN) {
        y1 = actor->currentPos.y + actor->headOffset.y - actor->size.y / 2;
    } else if (!(flags & ACTOR_FLAG_8000)) {
        y1 = actor->currentPos.y + actor->headOffset.y + actor->size.y / 2;
    } else {
        y1 = actor->currentPos.y + actor->headOffset.y + actor->size.y;
    }
    z1 = actor->currentPos.z + actor->headOffset.z + 10.0f;

    flags2 = actor->flags;
    x2 = actor->currentPos.x + actor->headOffset.x + actor->size.x / 2;
    if (flags2 & ACTOR_FLAG_UPSIDE_DOWN) {
        y2 = actor->currentPos.y + actor->headOffset.y - actor->size.y;
    } else if (!(flags2 & ACTOR_FLAG_8000)) {
        y2 = actor->currentPos.y + actor->headOffset.y + actor->size.y;
    } else {
        y2 = actor->currentPos.y + actor->headOffset.y + actor->size.y * 2;
    }
    z2 = actor->currentPos.z + actor->headOffset.z + 10.0f;

    switch (script->functionTemp[0]) {
        case 1:
            if (script->functionTemp[3] == 0) {
                fx_radial_shimmer(2, x1, y1, z1, 1.0f, 30);
                btl_cam_use_preset_immediately(BTL_CAM_PRESET_19);
                script->functionTemp[3] = 30;
                script->functionTemp[0] = 2;
            } else {
                script->functionTemp[3]--;
                break;
            }
            break;
        case 2:
            if (script->functionTemp[3] == 0) {
                dispatch_event_actor(actor, EVENT_SWAP_PARTNER);
                btl_cam_use_preset(BTL_CAM_DEFAULT);
                btl_cam_move(15);
                actor->isGlowing = 1;
                actor->attackBoost += attackBoost;
                if (actor->attackBoost > 20) {
                    actor->attackBoost = 20;
                }
                fx_stat_change(attackBoost - 1, x2, y2, z2, 1.0f, 60);
                script->functionTemp[3] = 15;
                script->functionTemp[0] = 3;
            } else {
                script->functionTemp[3]--;
                break;
            }
            break;
        case 3:
            if (script->functionTemp[3] == 0) {
                btl_show_variable_battle_message(BTL_MSG_ATTACK_UP, 60, attackBoost);
                script->functionTemp[0] = 4;
            } else {
                script->functionTemp[3]--;
                break;
            }
            break;
        case 4:
            if (btl_is_popup_displayed() == 0) {
                btl_cam_use_preset(BTL_CAM_DEFAULT);
                script->functionTemp[3] = 10;
                script->functionTemp[0] = 5;
            }
            break;
        case 5:
            if (script->functionTemp[3] != 0) {
                script->functionTemp[3]--;
                break;
            }
            if ((actor->handleEventScript == NULL) || !does_script_exist(actor->handleEventScriptID)) {
                D_8029FBD4 = 0;
                return ApiStatus_DONE2;
            }
            break;
    }
    return ApiStatus_BLOCK;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel bgm_update_music_settings
/* E0C48 8014A548 27BDFFC8 */  addiu     $sp, $sp, -0x38
/* E0C4C 8014A54C AFB1001C */  sw        $s1, 0x1C($sp)
/* E0C50 8014A550 3C118016 */  lui       $s1, %hi(gMusicSettings)
/* E0C54 8014A554 26319AF0 */  addiu     $s1, $s1, %lo(gMusicSettings)
/* E0C58 8014A558 AFB20020 */  sw        $s2, 0x20($sp)
/* E0C5C 8014A55C 0000902D */  daddu     $s2, $zero, $zero
/* E0C60 8014A560 AFB30024 */  sw        $s3, 0x24($sp)
/* E0C64 8014A564 24130002 */  addiu     $s3, $zero, 0x2
/* E0C68 8014A568 AFB5002C */  sw        $s5, 0x2C($sp)
/* E0C6C 8014A56C 2415FFFB */  addiu     $s5, $zero, -0x5
/* E0C70 8014A570 AFB40028 */  sw        $s4, 0x28($sp)
/* E0C74 8014A574 24140005 */  addiu     $s4, $zero, 0x5
/* E0C78 8014A578 AFB00018 */  sw        $s0, 0x18($sp)
/* E0C7C 8014A57C 26300002 */  addiu     $s0, $s1, 0x2
/* E0C80 8014A580 AFBF0030 */  sw        $ra, 0x30($sp)
.L8014A584:
/* E0C84 8014A584 86030000 */  lh        $v1, 0x0($s0)
/* E0C88 8014A588 2C620006 */  sltiu     $v0, $v1, 0x6
/* E0C8C 8014A58C 50400085 */  beql      $v0, $zero, .L8014A7A4
/* E0C90 8014A590 26520001 */   addiu    $s2, $s2, 0x1
/* E0C94 8014A594 00031080 */  sll       $v0, $v1, 2
/* E0C98 8014A598 3C018015 */  lui       $at, %hi(jtbl_80151290)
/* E0C9C 8014A59C 00220821 */  addu      $at, $at, $v0
/* E0CA0 8014A5A0 8C221290 */  lw        $v0, %lo(jtbl_80151290)($at)
/* E0CA4 8014A5A4 00400008 */  jr        $v0
/* E0CA8 8014A5A8 00000000 */   nop
glabel .L8014A5AC
/* E0CAC 8014A5AC 96230000 */  lhu       $v1, 0x0($s1)
/* E0CB0 8014A5B0 30620001 */  andi      $v0, $v1, 0x1
/* E0CB4 8014A5B4 1040001D */  beqz      $v0, .L8014A62C
/* E0CB8 8014A5B8 30620004 */   andi     $v0, $v1, 0x4
/* E0CBC 8014A5BC 8E050002 */  lw        $a1, 0x2($s0)
/* E0CC0 8014A5C0 28A200FA */  slti      $v0, $a1, 0xFA
/* E0CC4 8014A5C4 1040000B */  beqz      $v0, .L8014A5F4
/* E0CC8 8014A5C8 30620004 */   andi     $v0, $v1, 0x4
/* E0CCC 8014A5CC 14400005 */  bnez      $v0, .L8014A5E4
/* E0CD0 8014A5D0 00000000 */   nop
/* E0CD4 8014A5D4 0C015671 */  jal       au_song_stop
/* E0CD8 8014A5D8 8E040016 */   lw       $a0, 0x16($s0)
/* E0CDC 8014A5DC 08052987 */  j         .L8014A61C
/* E0CE0 8014A5E0 00000000 */   nop
.L8014A5E4:
/* E0CE4 8014A5E4 0C0156BC */  jal       func_80055AF0
/* E0CE8 8014A5E8 8E040016 */   lw       $a0, 0x16($s0)
/* E0CEC 8014A5EC 08052987 */  j         .L8014A61C
/* E0CF0 8014A5F0 00000000 */   nop
.L8014A5F4:
/* E0CF4 8014A5F4 14400006 */  bnez      $v0, .L8014A610
/* E0CF8 8014A5F8 00000000 */   nop
/* E0CFC 8014A5FC 8E040016 */  lw        $a0, 0x16($s0)
/* E0D00 8014A600 0C0156AF */  jal       snd_set_song_variation_fade_time
/* E0D04 8014A604 0000302D */   daddu    $a2, $zero, $zero
/* E0D08 8014A608 08052987 */  j         .L8014A61C
/* E0D0C 8014A60C 00000000 */   nop
.L8014A610:
/* E0D10 8014A610 8E040016 */  lw        $a0, 0x16($s0)
/* E0D14 8014A614 0C0156EE */  jal       func_80055BB8
/* E0D18 8014A618 240500FA */   addiu    $a1, $zero, 0xFA
.L8014A61C:
/* E0D1C 8014A61C 50400060 */  beql      $v0, $zero, .L8014A7A0
/* E0D20 8014A620 A6130000 */   sh       $s3, 0x0($s0)
/* E0D24 8014A624 080529E9 */  j         .L8014A7A4
/* E0D28 8014A628 26520001 */   addiu    $s2, $s2, 0x1
.L8014A62C:
/* E0D2C 8014A62C 10400002 */  beqz      $v0, .L8014A638
/* E0D30 8014A630 34620010 */   ori      $v0, $v1, 0x10
/* E0D34 8014A634 A6220000 */  sh        $v0, 0x0($s1)
.L8014A638:
/* E0D38 8014A638 96220000 */  lhu       $v0, 0x0($s1)
/* E0D3C 8014A63C 00551024 */  and       $v0, $v0, $s5
/* E0D40 8014A640 A6220000 */  sh        $v0, 0x0($s1)
glabel .L8014A644
/* E0D44 8014A644 080529E8 */  j         .L8014A7A0
/* E0D48 8014A648 A6140000 */   sh       $s4, 0x0($s0)
glabel .L8014A64C
/* E0D4C 8014A64C 96230000 */  lhu       $v1, 0x0($s1)
/* E0D50 8014A650 00751024 */  and       $v0, $v1, $s5
/* E0D54 8014A654 30630001 */  andi      $v1, $v1, 0x1
/* E0D58 8014A658 1060FFFA */  beqz      $v1, .L8014A644
/* E0D5C 8014A65C A6220000 */   sh       $v0, 0x0($s1)
/* E0D60 8014A660 8E040016 */  lw        $a0, 0x16($s0)
/* E0D64 8014A664 0C01567F */  jal       au_song_is_playing
/* E0D68 8014A668 00000000 */   nop
/* E0D6C 8014A66C 5440004D */  bnel      $v0, $zero, .L8014A7A4
/* E0D70 8014A670 26520001 */   addiu    $s2, $s2, 0x1
/* E0D74 8014A674 96220000 */  lhu       $v0, 0x0($s1)
/* E0D78 8014A678 3042FFFE */  andi      $v0, $v0, 0xFFFE
/* E0D7C 8014A67C A6220000 */  sh        $v0, 0x0($s1)
/* E0D80 8014A680 24020003 */  addiu     $v0, $zero, 0x3
/* E0D84 8014A684 080529E8 */  j         .L8014A7A0
/* E0D88 8014A688 A6020000 */   sh       $v0, 0x0($s0)
glabel .L8014A68C
/* E0D8C 8014A68C 24020004 */  addiu     $v0, $zero, 0x4
/* E0D90 8014A690 080529E8 */  j         .L8014A7A0
/* E0D94 8014A694 A6020000 */   sh       $v0, 0x0($s0)
glabel .L8014A698
/* E0D98 8014A698 96230000 */  lhu       $v1, 0x0($s1)
/* E0D9C 8014A69C 30620008 */  andi      $v0, $v1, 0x8
/* E0DA0 8014A6A0 14400029 */  bnez      $v0, .L8014A748
/* E0DA4 8014A6A4 30620010 */   andi     $v0, $v1, 0x10
/* E0DA8 8014A6A8 8E04000E */  lw        $a0, 0xE($s0)
/* E0DAC 8014A6AC 04810003 */  bgez      $a0, .L8014A6BC
/* E0DB0 8014A6B0 00000000 */   nop
/* E0DB4 8014A6B4 080529E8 */  j         .L8014A7A0
/* E0DB8 8014A6B8 A6000000 */   sh       $zero, 0x0($s0)
.L8014A6BC:
/* E0DBC 8014A6BC 0C015635 */  jal       au_song_load
/* E0DC0 8014A6C0 0240282D */   daddu    $a1, $s2, $zero
/* E0DC4 8014A6C4 3403FFFF */  ori       $v1, $zero, 0xFFFF
/* E0DC8 8014A6C8 0062182B */  sltu      $v1, $v1, $v0
/* E0DCC 8014A6CC 10600034 */  beqz      $v1, .L8014A7A0
/* E0DD0 8014A6D0 AE020016 */   sw       $v0, 0x16($s0)
/* E0DD4 8014A6D4 96220000 */  lhu       $v0, 0x0($s1)
/* E0DD8 8014A6D8 30420020 */  andi      $v0, $v0, 0x20
/* E0DDC 8014A6DC 1040000C */  beqz      $v0, .L8014A710
/* E0DE0 8014A6E0 00000000 */   nop
/* E0DE4 8014A6E4 8602000C */  lh        $v0, 0xC($s0)
/* E0DE8 8014A6E8 8607000A */  lh        $a3, 0xA($s0)
/* E0DEC 8014A6EC AFA20010 */  sw        $v0, 0x10($sp)
/* E0DF0 8014A6F0 8E040016 */  lw        $a0, 0x16($s0)
/* E0DF4 8014A6F4 8E050012 */  lw        $a1, 0x12($s0)
/* E0DF8 8014A6F8 0C015686 */  jal       snd_set_song_variation_fade
/* E0DFC 8014A6FC 8E060006 */   lw       $a2, 0x6($s0)
/* E0E00 8014A700 96220000 */  lhu       $v0, 0x0($s1)
/* E0E04 8014A704 3042FFDF */  andi      $v0, $v0, 0xFFDF
/* E0E08 8014A708 080529C8 */  j         .L8014A720
/* E0E0C 8014A70C A6220000 */   sh       $v0, 0x0($s1)
.L8014A710:
/* E0E10 8014A710 3C048016 */  lui       $a0, %hi(MusicDefaultVolume)
/* E0E14 8014A714 84849AE0 */  lh        $a0, %lo(MusicDefaultVolume)($a0)
/* E0E18 8014A718 0C052B21 */  jal       bgm_set_target_volume
/* E0E1C 8014A71C 00000000 */   nop
.L8014A720:
/* E0E20 8014A720 8E040016 */  lw        $a0, 0x16($s0)
/* E0E24 8014A724 0C01565C */  jal       au_song_start_variation
/* E0E28 8014A728 8E050012 */   lw       $a1, 0x12($s0)
/* E0E2C 8014A72C 5440001D */  bnel      $v0, $zero, .L8014A7A4
/* E0E30 8014A730 26520001 */   addiu    $s2, $s2, 0x1
/* E0E34 8014A734 96220000 */  lhu       $v0, 0x0($s1)
/* E0E38 8014A738 34420001 */  ori       $v0, $v0, 0x1
/* E0E3C 8014A73C A6220000 */  sh        $v0, 0x0($s1)
/* E0E40 8014A740 080529E8 */  j         .L8014A7A0
/* E0E44 8014A744 A6000000 */   sh       $zero, 0x0($s0)
.L8014A748:
/* E0E48 8014A748 10400005 */  beqz      $v0, .L8014A760
/* E0E4C 8014A74C 00000000 */   nop
/* E0E50 8014A750 A6000000 */  sh        $zero, 0x0($s0)
/* E0E54 8014A754 96220000 */  lhu       $v0, 0x0($s1)
/* E0E58 8014A758 080529E7 */  j         .L8014A79C
/* E0E5C 8014A75C 3042FFE7 */   andi     $v0, $v0, 0xFFE7
.L8014A760:
/* E0E60 8014A760 8E04002A */  lw        $a0, 0x2A($s0)
/* E0E64 8014A764 0C0156CA */  jal       func_80055B28
/* E0E68 8014A768 00000000 */   nop
/* E0E6C 8014A76C 5440000D */  bnel      $v0, $zero, .L8014A7A4
/* E0E70 8014A770 26520001 */   addiu    $s2, $s2, 0x1
/* E0E74 8014A774 8E020022 */  lw        $v0, 0x22($s0)
/* E0E78 8014A778 8E030026 */  lw        $v1, 0x26($s0)
/* E0E7C 8014A77C 8E04002A */  lw        $a0, 0x2A($s0)
/* E0E80 8014A780 A6000000 */  sh        $zero, 0x0($s0)
/* E0E84 8014A784 AE02000E */  sw        $v0, 0xE($s0)
/* E0E88 8014A788 AE030012 */  sw        $v1, 0x12($s0)
/* E0E8C 8014A78C AE040016 */  sw        $a0, 0x16($s0)
/* E0E90 8014A790 96220000 */  lhu       $v0, 0x0($s1)
/* E0E94 8014A794 34420001 */  ori       $v0, $v0, 0x1
/* E0E98 8014A798 3042FFF7 */  andi      $v0, $v0, 0xFFF7
.L8014A79C:
/* E0E9C 8014A79C A6220000 */  sh        $v0, 0x0($s1)
glabel .L8014A7A0
/* E0EA0 8014A7A0 26520001 */  addiu     $s2, $s2, 0x1
.L8014A7A4:
/* E0EA4 8014A7A4 26100030 */  addiu     $s0, $s0, 0x30
/* E0EA8 8014A7A8 2A420002 */  slti      $v0, $s2, 0x2
/* E0EAC 8014A7AC 1440FF75 */  bnez      $v0, .L8014A584
/* E0EB0 8014A7B0 26310030 */   addiu    $s1, $s1, 0x30
/* E0EB4 8014A7B4 0C052B25 */  jal       bgm_update_volume
/* E0EB8 8014A7B8 00000000 */   nop
/* E0EBC 8014A7BC 8FBF0030 */  lw        $ra, 0x30($sp)
/* E0EC0 8014A7C0 8FB5002C */  lw        $s5, 0x2C($sp)
/* E0EC4 8014A7C4 8FB40028 */  lw        $s4, 0x28($sp)
/* E0EC8 8014A7C8 8FB30024 */  lw        $s3, 0x24($sp)
/* E0ECC 8014A7CC 8FB20020 */  lw        $s2, 0x20($sp)
/* E0ED0 8014A7D0 8FB1001C */  lw        $s1, 0x1C($sp)
/* E0ED4 8014A7D4 8FB00018 */  lw        $s0, 0x18($sp)
/* E0ED8 8014A7D8 03E00008 */  jr        $ra
/* E0EDC 8014A7DC 27BD0038 */   addiu    $sp, $sp, 0x38

### DECOMPILED C INSTRUCTIONS:

void bgm_update_music_settings(void) {
    MusicSettings* music = gMusicSettings;
    s32 i = 0;
    s16 state2 = 2;
    s16 flag4 = MUSIC_SETTINGS_FLAG_4;
    s32 flags;

    for (i; i < 2; i++, music++) {
        switch (music->state) {
        case 0:
            break;
        case 1:
            if (music->flags & MUSIC_SETTINGS_FLAG_1) {
                if (music->fadeOutTime < 250) {
                    if (!(music->flags & MUSIC_SETTINGS_FLAG_4)) {
                        if (au_song_stop(music->songName) == AU_RESULT_OK) {
                            music->state = state2;
                        }
                    } else {
                        if (func_80055AF0(music->songName) == AU_RESULT_OK) {
                           music->state = state2;
                        }
                    }
                } else if (!(music->flags & MUSIC_SETTINGS_FLAG_4)) {
                    if (snd_set_song_variation_fade_time(music->songName, music->fadeOutTime, 0) == 0) {
                        music->state = state2;
                    }
                } else {
                    if (func_80055BB8(music->songName, 250) == AU_RESULT_OK) {
                        music->state = state2;
                    }
                }
            } else {
                if (music->flags & MUSIC_SETTINGS_FLAG_4) {
                    music->flags |= MUSIC_SETTINGS_FLAG_10;
                }
                music->flags &= ~flag4;
                music->state = 5;
            }
            break;
        case 2:
            flags = music->flags;
            music->flags &= ~flag4;
            if (flags & 1) {
                if (au_song_is_playing(music->songName) == AU_RESULT_OK) {
                    music->flags &= ~MUSIC_SETTINGS_FLAG_1;
                    music->state = 3;
                }
            } else {
                music->state = 5;
            }
            break;
        case 3:
            music->state = 4;
            break;
        case 4:
            music->state = 5;
            break;
        case 5:
            if (!(music->flags & MUSIC_SETTINGS_FLAG_8)) {
                if (music->songID < 0) {
                    music->state = 0;
                } else {
                    music->songName = au_song_load(music->songID, i);
                    if (music->songName > 0xFFFFU) {
                        if ((music->flags & MUSIC_SETTINGS_FLAG_20)) {
                            snd_set_song_variation_fade(music->songName, music->variation,
                                music->fadeInTime, music->fadeStartVolume, music->fadeEndVolume);
                            music->flags &= ~MUSIC_SETTINGS_FLAG_20;
                        } else {
                            bgm_set_target_volume(MusicDefaultVolume);
                        }
                        if (au_song_start_variation(music->songName, music->variation) == 0) {
                            music->flags |= MUSIC_SETTINGS_FLAG_1;
                            music->state = 0;
                        }
                    }
                }
            } else {
                if (music->flags & MUSIC_SETTINGS_FLAG_10) {
                    music->state = 0;
                    music->flags &= ~(MUSIC_SETTINGS_FLAG_10 | MUSIC_SETTINGS_FLAG_8);
                } else if (func_80055B28(music->savedSongName) == 0) {
                    music->songID = music->savedSongID;
                    music->variation = music->savedVariation;
                    music->songName = music->savedSongName;
                    music->state = 0;
                    music->flags |= MUSIC_SETTINGS_FLAG_1;
                    music->flags &= ~MUSIC_SETTINGS_FLAG_8;
                }
            }
            break;
        }
    }
    bgm_update_volume();
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel calculate_segment_intersection
/* D6DC 800322DC 27BDFFC0 */  addiu     $sp, $sp, -0x40
/* D6E0 800322E0 F7BC0030 */  sdc1      $f28, 0x30($sp)
/* D6E4 800322E4 AFA60048 */  sw        $a2, 0x48($sp)
/* D6E8 800322E8 C7BC0048 */  lwc1      $f28, 0x48($sp)
/* D6EC 800322EC F7B80020 */  sdc1      $f24, 0x20($sp)
/* D6F0 800322F0 C7B80050 */  lwc1      $f24, 0x50($sp)
/* D6F4 800322F4 F7B40010 */  sdc1      $f20, 0x10($sp)
/* D6F8 800322F8 46006506 */  mov.s     $f20, $f12
/* D6FC 800322FC F7B60018 */  sdc1      $f22, 0x18($sp)
/* D700 80032300 46007586 */  mov.s     $f22, $f14
/* D704 80032304 F7BA0028 */  sdc1      $f26, 0x28($sp)
/* D708 80032308 C7BA0054 */  lwc1      $f26, 0x54($sp)
/* D70C 8003230C 4614E481 */  sub.s     $f18, $f28, $f20
/* D710 80032310 C7A20058 */  lwc1      $f2, 0x58($sp)
/* D714 80032314 C7A0005C */  lwc1      $f0, 0x5C($sp)
/* D718 80032318 4616D181 */  sub.s     $f6, $f26, $f22
/* D71C 8003231C F7BE0038 */  sdc1      $f30, 0x38($sp)
/* D720 80032320 46160781 */  sub.s     $f30, $f0, $f22
/* D724 80032324 AFA7004C */  sw        $a3, 0x4C($sp)
/* D728 80032328 46181401 */  sub.s     $f16, $f2, $f24
/* D72C 8003232C C7BC004C */  lwc1      $f28, 0x4C($sp)
/* D730 80032330 4616E301 */  sub.s     $f12, $f28, $f22
/* D734 80032334 4614C701 */  sub.s     $f28, $f24, $f20
/* D738 80032338 461A0381 */  sub.s     $f14, $f0, $f26
/* D73C 8003233C E7BC0008 */  swc1      $f28, 0x8($sp)
/* D740 80032340 46141701 */  sub.s     $f28, $f2, $f20
/* D744 80032344 44802000 */  mtc1      $zero, $f4
/* D748 80032348 46009286 */  mov.s     $f10, $f18
/* D74C 8003234C 46049032 */  c.eq.s    $f18, $f4
/* D750 80032350 46006207 */  neg.s     $f8, $f12
/* D754 80032354 45000005 */  bc1f      .L8003236C
/* D758 80032358 E7BC0000 */   swc1     $f28, 0x0($sp)
/* D75C 8003235C 46046032 */  c.eq.s    $f12, $f4
/* D760 80032360 00000000 */  nop
/* D764 80032364 45010097 */  bc1t      .L800325C4
/* D768 80032368 0000102D */   daddu    $v0, $zero, $zero
.L8003236C:
/* D76C 8003236C 44800000 */  mtc1      $zero, $f0
/* D770 80032370 00000000 */  nop
/* D774 80032374 46008032 */  c.eq.s    $f16, $f0
/* D778 80032378 00000000 */  nop
/* D77C 8003237C 45000005 */  bc1f      .L80032394
/* D780 80032380 00000000 */   nop
/* D784 80032384 46007032 */  c.eq.s    $f14, $f0
/* D788 80032388 00000000 */  nop
/* D78C 8003238C 4501008D */  bc1t      .L800325C4
/* D790 80032390 0000102D */   daddu    $v0, $zero, $zero
.L80032394:
/* D794 80032394 46065002 */  mul.s     $f0, $f10, $f6
/* D798 80032398 00000000 */  nop
/* D79C 8003239C C7BC0008 */  lwc1      $f28, 0x8($sp)
/* D7A0 800323A0 461C4082 */  mul.s     $f2, $f8, $f28
/* D7A4 800323A4 00000000 */  nop
/* D7A8 800323A8 46001180 */  add.s     $f6, $f2, $f0
/* D7AC 800323AC 44800000 */  mtc1      $zero, $f0
/* D7B0 800323B0 00000000 */  nop
/* D7B4 800323B4 4600303C */  c.lt.s    $f6, $f0
/* D7B8 800323B8 3C01BF80 */  lui       $at, (0xBF800000 >> 16)
/* D7BC 800323BC 44812000 */  mtc1      $at, $f4
/* D7C0 800323C0 45010007 */  bc1t      .L800323E0
/* D7C4 800323C4 00000000 */   nop
/* D7C8 800323C8 4606003C */  c.lt.s    $f0, $f6
/* D7CC 800323CC 00000000 */  nop
/* D7D0 800323D0 45000003 */  bc1f      .L800323E0
/* D7D4 800323D4 46000106 */   mov.s    $f4, $f0
/* D7D8 800323D8 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* D7DC 800323DC 44812000 */  mtc1      $at, $f4
.L800323E0:
/* D7E0 800323E0 461E5002 */  mul.s     $f0, $f10, $f30
/* D7E4 800323E4 00000000 */  nop
/* D7E8 800323E8 C7BC0000 */  lwc1      $f28, 0x0($sp)
/* D7EC 800323EC 461C4082 */  mul.s     $f2, $f8, $f28
/* D7F0 800323F0 00000000 */  nop
/* D7F4 800323F4 46001080 */  add.s     $f2, $f2, $f0
/* D7F8 800323F8 44800000 */  mtc1      $zero, $f0
/* D7FC 800323FC 00000000 */  nop
/* D800 80032400 4600103C */  c.lt.s    $f2, $f0
/* D804 80032404 00000000 */  nop
/* D808 80032408 45000005 */  bc1f      .L80032420
/* D80C 8003240C 46002186 */   mov.s    $f6, $f4
/* D810 80032410 3C01BF80 */  lui       $at, (0xBF800000 >> 16)
/* D814 80032414 44810000 */  mtc1      $at, $f0
/* D818 80032418 0800C90F */  j         .L8003243C
/* D81C 8003241C 00000000 */   nop
.L80032420:
/* D820 80032420 4602003C */  c.lt.s    $f0, $f2
/* D824 80032424 00000000 */  nop
/* D828 80032428 45000004 */  bc1f      .L8003243C
/* D82C 8003242C 00000000 */   nop
/* D830 80032430 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* D834 80032434 44810000 */  mtc1      $at, $f0
/* D838 80032438 00000000 */  nop
.L8003243C:
/* D83C 8003243C 46003032 */  c.eq.s    $f6, $f0
/* D840 80032440 00000000 */  nop
/* D844 80032444 4501005F */  bc1t      .L800325C4
/* D848 80032448 0000102D */   daddu    $v0, $zero, $zero
/* D84C 8003244C 46009085 */  abs.s     $f2, $f18
/* D850 80032450 46008005 */  abs.s     $f0, $f16
/* D854 80032454 4602003C */  c.lt.s    $f0, $f2
/* D858 80032458 00000000 */  nop
/* D85C 8003245C 4500001E */  bc1f      .L800324D8
/* D860 80032460 00000000 */   nop
/* D864 80032464 460CA002 */  mul.s     $f0, $f20, $f12
/* D868 80032468 00000000 */  nop
/* D86C 8003246C 4612B182 */  mul.s     $f6, $f22, $f18
/* D870 80032470 00000000 */  nop
/* D874 80032474 461A9202 */  mul.s     $f8, $f18, $f26
/* D878 80032478 00000000 */  nop
/* D87C 8003247C 46186282 */  mul.s     $f10, $f12, $f24
/* D880 80032480 00000000 */  nop
/* D884 80032484 46106082 */  mul.s     $f2, $f12, $f16
/* D888 80032488 00000000 */  nop
/* D88C 8003248C 460E9102 */  mul.s     $f4, $f18, $f14
/* D890 80032490 00000000 */  nop
/* D894 80032494 46060001 */  sub.s     $f0, $f0, $f6
/* D898 80032498 46041081 */  sub.s     $f2, $f2, $f4
/* D89C 8003249C 46080000 */  add.s     $f0, $f0, $f8
/* D8A0 800324A0 460A0181 */  sub.s     $f6, $f0, $f10
/* D8A4 800324A4 46023183 */  div.s     $f6, $f6, $f2
/* D8A8 800324A8 46068002 */  mul.s     $f0, $f16, $f6
/* D8AC 800324AC 00000000 */  nop
/* D8B0 800324B0 4600C000 */  add.s     $f0, $f24, $f0
/* D8B4 800324B4 46140001 */  sub.s     $f0, $f0, $f20
/* D8B8 800324B8 46120183 */  div.s     $f6, $f0, $f18
/* D8BC 800324BC 46069002 */  mul.s     $f0, $f18, $f6
/* D8C0 800324C0 00000000 */  nop
/* D8C4 800324C4 46066082 */  mul.s     $f2, $f12, $f6
/* D8C8 800324C8 00000000 */  nop
/* D8CC 800324CC 4600A200 */  add.s     $f8, $f20, $f0
/* D8D0 800324D0 0800C952 */  j         .L80032548
/* D8D4 800324D4 4602B180 */   add.s    $f6, $f22, $f2
.L800324D8:
/* D8D8 800324D8 4610D002 */  mul.s     $f0, $f26, $f16
/* D8DC 800324DC 00000000 */  nop
/* D8E0 800324E0 460EA182 */  mul.s     $f6, $f20, $f14
/* D8E4 800324E4 00000000 */  nop
/* D8E8 800324E8 460ED202 */  mul.s     $f8, $f26, $f14
/* D8EC 800324EC 00000000 */  nop
/* D8F0 800324F0 4610B282 */  mul.s     $f10, $f22, $f16
/* D8F4 800324F4 00000000 */  nop
/* D8F8 800324F8 46106082 */  mul.s     $f2, $f12, $f16
/* D8FC 800324FC 00000000 */  nop
/* D900 80032500 460E9102 */  mul.s     $f4, $f18, $f14
/* D904 80032504 00000000 */  nop
/* D908 80032508 46060000 */  add.s     $f0, $f0, $f6
/* D90C 8003250C 46041081 */  sub.s     $f2, $f2, $f4
/* D910 80032510 46080001 */  sub.s     $f0, $f0, $f8
/* D914 80032514 460A0181 */  sub.s     $f6, $f0, $f10
/* D918 80032518 46023183 */  div.s     $f6, $f6, $f2
/* D91C 8003251C 46069002 */  mul.s     $f0, $f18, $f6
/* D920 80032520 00000000 */  nop
/* D924 80032524 4600A000 */  add.s     $f0, $f20, $f0
/* D928 80032528 46180001 */  sub.s     $f0, $f0, $f24
/* D92C 8003252C 46100183 */  div.s     $f6, $f0, $f16
/* D930 80032530 46068002 */  mul.s     $f0, $f16, $f6
/* D934 80032534 00000000 */  nop
/* D938 80032538 46067082 */  mul.s     $f2, $f14, $f6
/* D93C 8003253C 00000000 */  nop
/* D940 80032540 4600C200 */  add.s     $f8, $f24, $f0
/* D944 80032544 4602D180 */  add.s     $f6, $f26, $f2
.L80032548:
/* D948 80032548 46144101 */  sub.s     $f4, $f8, $f20
/* D94C 8003254C C7BC0048 */  lwc1      $f28, 0x48($sp)
/* D950 80032550 461C4001 */  sub.s     $f0, $f8, $f28
/* D954 80032554 46002102 */  mul.s     $f4, $f4, $f0
/* D958 80032558 00000000 */  nop
/* D95C 8003255C C7BC004C */  lwc1      $f28, 0x4C($sp)
/* D960 80032560 461C3081 */  sub.s     $f2, $f6, $f28
/* D964 80032564 46163001 */  sub.s     $f0, $f6, $f22
/* D968 80032568 46020002 */  mul.s     $f0, $f0, $f2
/* D96C 8003256C 00000000 */  nop
/* D970 80032570 46002100 */  add.s     $f4, $f4, $f0
/* D974 80032574 44800000 */  mtc1      $zero, $f0
/* D978 80032578 00000000 */  nop
/* D97C 8003257C 4604003C */  c.lt.s    $f0, $f4
/* D980 80032580 00000000 */  nop
/* D984 80032584 4501000F */  bc1t      .L800325C4
/* D988 80032588 0000102D */   daddu    $v0, $zero, $zero
/* D98C 8003258C 46184081 */  sub.s     $f2, $f8, $f24
/* D990 80032590 46021082 */  mul.s     $f2, $f2, $f2
/* D994 80032594 00000000 */  nop
/* D998 80032598 461A3001 */  sub.s     $f0, $f6, $f26
/* D99C 8003259C 8FA30060 */  lw        $v1, 0x60($sp)
/* D9A0 800325A0 46000002 */  mul.s     $f0, $f0, $f0
/* D9A4 800325A4 00000000 */  nop
/* D9A8 800325A8 E4680000 */  swc1      $f8, 0x0($v1)
/* D9AC 800325AC 8FA30064 */  lw        $v1, 0x64($sp)
/* D9B0 800325B0 E4660000 */  swc1      $f6, 0x0($v1)
/* D9B4 800325B4 46001080 */  add.s     $f2, $f2, $f0
/* D9B8 800325B8 8FA30068 */  lw        $v1, 0x68($sp)
/* D9BC 800325BC 24020001 */  addiu     $v0, $zero, 0x1
/* D9C0 800325C0 E4620000 */  swc1      $f2, 0x0($v1)
.L800325C4:
/* D9C4 800325C4 D7BE0038 */  ldc1      $f30, 0x38($sp)
/* D9C8 800325C8 D7BC0030 */  ldc1      $f28, 0x30($sp)
/* D9CC 800325CC D7BA0028 */  ldc1      $f26, 0x28($sp)
/* D9D0 800325D0 D7B80020 */  ldc1      $f24, 0x20($sp)
/* D9D4 800325D4 D7B60018 */  ldc1      $f22, 0x18($sp)
/* D9D8 800325D8 D7B40010 */  ldc1      $f20, 0x10($sp)
/* D9DC 800325DC 03E00008 */  jr        $ra
/* D9E0 800325E0 27BD0040 */   addiu    $sp, $sp, 0x40

### DECOMPILED C INSTRUCTIONS:

s32 calculate_segment_intersection(f32 A1x, f32 A1z, f32 A2x, f32 A2z, f32 B1x, f32 B1z, f32 B2x, f32 B2z, f32* interX, f32* interZ, f32* squared_dist) {
    f32 dx14;
    f32 dx13;
    f32 dz;
    f32 dz12;
    f32 dx34;
    f32 dx12;
    f32 dx;
    f32 alpha;
    f32 minus_dz12;
    f32 B2_side;
    f32 x;
    f32 B1_side;
    f32 z;
    f32 dx12_copy;
    f32 dz13;
    f32 dz14;
    f32 dz34;
    f32 B1_side_;

    dx12_copy = A2x - A1x;
    dx12 = dx12_copy;
    dz12 = A2z - A1z;
    dx13 = B1x - A1x;
    dz13 = B1z - A1z;
    dx14 = B2x - A1x;
    dz14 = B2z - A1z;
    minus_dz12 = -dz12;
    dx34 = B2x - B1x;
    dz34 = B2z - B1z;

    // if distance between points on the line is 0
    if (dx12_copy == 0.0f && dz12 == 0.0f) {
        return FALSE;
    }
    // if length of second segment is 0
    if (dx34 == 0.0f && dz34 == 0.0f) {
        return FALSE;
    }

    B1_side_ = minus_dz12 * dx13 + dx12_copy * dz13;
    if (B1_side_ < 0.0f) {
        B1_side = -1.0f;
    } else if (B1_side_ > 0.0f) {
        B1_side = 1.0f;
    } else {
        B1_side = 0.0f;
    }
    B1_side_ = B1_side;

    dx = minus_dz12 * dx14 + dx12_copy * dz14;
    if (dx < 0.0f) {
        B2_side = -1.0f;
    } else if (dx > 0.0f) {
        B2_side = 1.0f;
    } else {
        B2_side = 0.0f;
    }

    // B1 and B2 are on the same side relative to the line: no intersection
    if (B1_side_ == B2_side) {
        return FALSE;
    }

    if (fabsf(dx12) > fabsf(dx34)) {
        /*
        We represent intersection point P as P = B1 + alpha * (B2 - B1)
        and solve the equation (P - A1) x (A2 - A1) = 0, where 'x' is cross product, A1 and A2 are points on the line
        and B1 and B2 are the ends of the segment.
        So, (B1 - A1 + alpha * (B2 - B1)) x (A2 - A1) = 0,
        alpha = [-(B1 - A1) x (A2 - A1)] / [(B2 - B1) x (A2 - A1)]
        */
        // same as -(B1 - A1) x (A2 - A1)
        alpha = A1x * dz12 - A1z * dx12 + dx12 * B1z - dz12 * B1x;
        // divide by (B2 - B1) x (A2 - A1)
        alpha /= dz12 * dx34 - dx12 * dz34;
        /*
            Now we represent P as P = A1 + beta * (A2 - A1), and we are to find beta.
            B1 + alpha * (B2 - B1) = A1 + beta * (A2 - A1)
            beta * (A2 - A1) = B1 + alpha * (B2 - B1) - A1
            We use only 'x' part of this equation to find beta.

            Actually this step could be omitted and we calculate intersection directly as B1 + alpha * (B2 - B1).
            Don't know why it's done this way.
        */
        alpha = (B1x + dx34 * alpha - A1x) / dx12;
        x = A1x + dx12 * alpha;
        z = A1z + dz12 * alpha;
    } else {
        /*
        We represent intersection point P as P = A1 + alpha * (A2 - A1)
        and solve the equation (B2 - B1) x (P - B1) = 0
        */
        // same as (B2 - B1) x (B1 - A1)
        alpha = B1z * dx34 + A1x * dz34 - B1z * dz34 - A1z * dx34;
        // divide by (B2 - B1) x (A2 - A1)
        alpha /= dz12 * dx34 - dx12 * dz34;
        // Now we represent P as P = B1 + beta * (B2 - B1) and find beta
        alpha = (A1x + dx12 * alpha - B1x) / dx34;
        x = B1x + dx34 * alpha;
        z = B1z + dz34 * alpha;
    }
    // (P - A1) * (P - A2) > 0 when P is outside of segment A1-A2
    if ((x - A1x) * (x - A2x) + (z - A1z) * (z - A2z) > 0.0f) {
        return FALSE;
    }

    dx = x - B1x;
    dz = z - B1z;
    *interX = x;
    *interZ = z;
    // distance between P and B1
    *squared_dist = SQ(dx) + SQ(dz);
    return TRUE;
}