.include "macros.inc"

.section .text, "ax"

.global cos
cos:
/* 803943F0 00391350  94 21 FF E0 */	stwu r1, -0x20(r1)
/* 803943F4 00391354  7C 08 02 A6 */	mflr r0
/* 803943F8 00391358  3C 60 3F E9 */	lis r3, 0x3FE921FB@ha
/* 803943FC 0039135C  D8 21 00 08 */	stfd f1, 8(r1)
/* 80394400 00391360  90 01 00 24 */	stw r0, 0x24(r1)
/* 80394404 00391364  38 03 21 FB */	addi r0, r3, 0x3FE921FB@l
/* 80394408 00391368  80 61 00 08 */	lwz r3, 8(r1)
/* 8039440C 0039136C  54 63 00 7E */	clrlwi r3, r3, 1
/* 80394410 00391370  7C 03 00 00 */	cmpw r3, r0
/* 80394414 00391374  41 81 00 10 */	bgt lbl_80394424
/* 80394418 00391378  C8 42 D4 98 */	lfd f2, lbl_805AF1B8@sda21(r2)
/* 8039441C 0039137C  4B FF EB B1 */	bl __kernel_cos
/* 80394420 00391380  48 00 00 94 */	b lbl_803944B4
lbl_80394424:
/* 80394424 00391384  3C 00 7F F0 */	lis r0, 0x7ff0
/* 80394428 00391388  7C 03 00 00 */	cmpw r3, r0
/* 8039442C 0039138C  41 80 00 0C */	blt lbl_80394438
/* 80394430 00391390  FC 21 08 28 */	fsub f1, f1, f1
/* 80394434 00391394  48 00 00 80 */	b lbl_803944B4
lbl_80394438:
/* 80394438 00391398  38 61 00 10 */	addi r3, r1, 0x10
/* 8039443C 0039139C  4B FF E7 F1 */	bl __ieee754_rem_pio2
/* 80394440 003913A0  54 60 07 BE */	clrlwi r0, r3, 0x1e
/* 80394444 003913A4  2C 00 00 01 */	cmpwi r0, 1
/* 80394448 003913A8  41 82 00 30 */	beq lbl_80394478
/* 8039444C 003913AC  40 80 00 10 */	bge lbl_8039445C
/* 80394450 003913B0  2C 00 00 00 */	cmpwi r0, 0
/* 80394454 003913B4  40 80 00 14 */	bge lbl_80394468
/* 80394458 003913B8  48 00 00 4C */	b lbl_803944A4
lbl_8039445C:
/* 8039445C 003913BC  2C 00 00 03 */	cmpwi r0, 3
/* 80394460 003913C0  40 80 00 44 */	bge lbl_803944A4
/* 80394464 003913C4  48 00 00 2C */	b lbl_80394490
lbl_80394468:
/* 80394468 003913C8  C8 21 00 10 */	lfd f1, 0x10(r1)
/* 8039446C 003913CC  C8 41 00 18 */	lfd f2, 0x18(r1)
/* 80394470 003913D0  4B FF EB 5D */	bl __kernel_cos
/* 80394474 003913D4  48 00 00 40 */	b lbl_803944B4
lbl_80394478:
/* 80394478 003913D8  C8 21 00 10 */	lfd f1, 0x10(r1)
/* 8039447C 003913DC  38 60 00 01 */	li r3, 1
/* 80394480 003913E0  C8 41 00 18 */	lfd f2, 0x18(r1)
/* 80394484 003913E4  4B FF FA 91 */	bl __kernel_sin
/* 80394488 003913E8  FC 20 08 50 */	fneg f1, f1
/* 8039448C 003913EC  48 00 00 28 */	b lbl_803944B4
lbl_80394490:
/* 80394490 003913F0  C8 21 00 10 */	lfd f1, 0x10(r1)
/* 80394494 003913F4  C8 41 00 18 */	lfd f2, 0x18(r1)
/* 80394498 003913F8  4B FF EB 35 */	bl __kernel_cos
/* 8039449C 003913FC  FC 20 08 50 */	fneg f1, f1
/* 803944A0 00391400  48 00 00 14 */	b lbl_803944B4
lbl_803944A4:
/* 803944A4 00391404  C8 21 00 10 */	lfd f1, 0x10(r1)
/* 803944A8 00391408  38 60 00 01 */	li r3, 1
/* 803944AC 0039140C  C8 41 00 18 */	lfd f2, 0x18(r1)
/* 803944B0 00391410  4B FF FA 65 */	bl __kernel_sin
lbl_803944B4:
/* 803944B4 00391414  80 01 00 24 */	lwz r0, 0x24(r1)
/* 803944B8 00391418  7C 08 03 A6 */	mtlr r0
/* 803944BC 0039141C  38 21 00 20 */	addi r1, r1, 0x20
/* 803944C0 00391420  4E 80 00 20 */	blr

.section .sdata2, "a"
.global lbl_805AF1B8
lbl_805AF1B8:
	# ROM: 0x3FBA58
	.4byte 0
	.4byte 0