	.include "asm/macros.inc"
	.include "global.inc"

	.text

	arm_func_start _drdiv
_drdiv: ; 0x020EC070
	eor r1, r1, r3
	eor r3, r1, r3
	eor r1, r1, r3
	eor r0, r0, r2
	eor r2, r0, r2
	eor r0, r0, r2

	arm_func_start _ddiv
_ddiv: ; 0x020EC088
	stmdb sp!, {r4-r6,lr}
	ldr lr, _020EC5C8 ; =0x00000FFE
	eor r4, r1, r3
	ands r12, lr, r1, lsr #0x13
	cmpne r12, lr
	beq _020EC434
	bic r1, r1, lr, lsl #0x14
	orr r1, r1, #0x100000
	add r12, r12, r4, lsr #0x1f
_020EC0AC:
	ands r4, lr, r3, lsr #0x13
	cmpne r4, lr
	beq _020EC4CC
	bic r3, r3, lr, lsl #0x14
	orr r3, r3, #0x100000
_020EC0C0:
	sub r12, r12, r4
	cmp r1, r3
	cmpeq r0, r2
	bhs _020EC0DC
	adds r0, r0, r0
	adc r1, r1, r1
	sub r12, r12, #0x2
_020EC0DC:
	sub r4, pc, #0x24 ; _020EC1C0 - #0x100
	ldrb lr, [r4, r3, lsr #0xc]
	rsbs r2, r2, #0x0
	rsc r3, r3, #0x0
	mov r4, #0x20000000
	mla r5, lr, r3, r4
	mov r6, r3, lsl #0xa
	mov r5, r5, lsr #0x7
	mul lr, r5, lr
	orr r6, r6, r2, lsr #0x16
	mov lr, lr, lsr #0xd
	mul r5, lr, r6
	mov r6, r1, lsl #0xa
	orr r6, r6, r0, lsr #0x16
	mov r5, r5, lsr #0x10
	mul r5, lr, r5
	mov lr, lr, lsl #0xe
	add lr, lr, r5, lsr #0x10
	umull r5, r6, lr, r6
	umull r4, r5, r6, r2
	mla r5, r3, r6, r5
	mov r4, r4, lsr #0x1a
	orr r4, r4, r5, lsl #0x6
	add r4, r4, r0, lsl #0x2
	umull lr, r5, r4, lr
	mov r4, #0x0
	adds r5, r5, r6, lsl #0x18
	adc r4, r4, r6, lsr #0x8
	cmp r12, #0x800
	bge _020EC2C0
	add r12, r12, #0x7f0
	adds r12, r12, #0xc
	bmi _020EC2D8
	orr r1, r4, r12, lsl #0x1f
	bic r12, r12, #0x1
	add r1, r1, r12, lsl #0x13
	tst lr, #0x80000000
	bne _020EC1B0
	rsbs r2, r2, #0x0
	mov r4, r4, lsl #0x1
	add r4, r4, r5, lsr #0x1f
	mul lr, r2, r4
	mov r6, #0x0
	mov r4, r5, lsl #0x1
	orr r4, r4, #0x1
	umlal r6, lr, r4, r2
	rsc r3, r3, #0x0
	mla lr, r4, r3, lr
	cmp lr, r0, lsl #0x15
	bmi _020EC1B0
	mov r0, r5
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC1B0:
	adds r0, r5, #0x1
	adc r1, r1, #0x0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC1C0: ; not code
	.byte 0xFF, 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1
	.byte 0xF0, 0xF0, 0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xEA, 0xE9, 0xE8, 0xE7, 0xE6, 0xE6, 0xE5, 0xE4
	.byte 0xE3, 0xE2, 0xE2, 0xE1, 0xE0, 0xDF, 0xDF, 0xDE, 0xDD, 0xDC, 0xDC, 0xDB, 0xDA, 0xD9, 0xD9, 0xD8
	.byte 0xD7, 0xD7, 0xD6, 0xD5, 0xD4, 0xD4, 0xD3, 0xD2, 0xD2, 0xD1, 0xD0, 0xD0, 0xCF, 0xCE, 0xCE, 0xCD
	.byte 0xCC, 0xCC, 0xCB, 0xCB, 0xCA, 0xC9, 0xC9, 0xC8, 0xC8, 0xC7, 0xC6, 0xC6, 0xC5, 0xC5, 0xC4, 0xC3
	.byte 0xC3, 0xC2, 0xC2, 0xC1, 0xC0, 0xC0, 0xBF, 0xBF, 0xBE, 0xBE, 0xBD, 0xBD, 0xBC, 0xBC, 0xBB, 0xBA
	.byte 0xBA, 0xB9, 0xB9, 0xB8, 0xB8, 0xB7, 0xB7, 0xB6, 0xB6, 0xB5, 0xB5, 0xB4, 0xB4, 0xB3, 0xB3, 0xB2
	.byte 0xB2, 0xB1, 0xB1, 0xB0, 0xB0, 0xAF, 0xAF, 0xAF, 0xAE, 0xAE, 0xAD, 0xAD, 0xAC, 0xAC, 0xAB, 0xAB
	.byte 0xAA, 0xAA, 0xAA, 0xA9, 0xA9, 0xA8, 0xA8, 0xA7, 0xA7, 0xA7, 0xA6, 0xA6, 0xA5, 0xA5, 0xA4, 0xA4
	.byte 0xA4, 0xA3, 0xA3, 0xA2, 0xA2, 0xA2, 0xA1, 0xA1, 0xA0, 0xA0, 0xA0, 0x9F, 0x9F, 0x9E, 0x9E, 0x9E
	.byte 0x9D, 0x9D, 0x9D, 0x9C, 0x9C, 0x9B, 0x9B, 0x9B, 0x9A, 0x9A, 0x9A, 0x99, 0x99, 0x99, 0x98, 0x98
	.byte 0x98, 0x97, 0x97, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x93, 0x93, 0x93, 0x92
	.byte 0x92, 0x92, 0x91, 0x91, 0x91, 0x91, 0x90, 0x90, 0x90, 0x8F, 0x8F, 0x8F, 0x8E, 0x8E, 0x8E, 0x8D
	.byte 0x8D, 0x8D, 0x8C, 0x8C, 0x8C, 0x8C, 0x8B, 0x8B, 0x8B, 0x8A, 0x8A, 0x8A, 0x8A, 0x89, 0x89, 0x89
	.byte 0x88, 0x88, 0x88, 0x88, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, 0x86, 0x85, 0x85, 0x85, 0x85, 0x84
	.byte 0x84, 0x84, 0x83, 0x83, 0x83, 0x83, 0x82, 0x82, 0x82, 0x82, 0x81, 0x81, 0x81, 0x81, 0x80, 0x80
_020EC2C0:
	movs r1, r12, lsl #0x1f
	orr r1, r1, #0x7f000000
	orr r1, r1, #0xf00000
	mov r0, #0x0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC2D8:
	mvn r6, r12, asr #0x1
	cmp r6, #0x34
	bgt _020EC424
	beq _020EC400
	cmp r6, #0x14
	bge _020EC320
	rsb r6, r6, #0x13
	mov lr, r0, lsl r6
	rsb r6, r6, #0x14
	mov r0, r5, lsr r6
	rsb r6, r6, #0x20
	orr r0, r0, r4, lsl r6
	rsb r6, r6, #0x20
	mov r4, r4, lsr r6
	orr r1, r4, r12, lsl #0x1f
	mov r12, lr
	mov lr, #0x0
	b _020EC350
_020EC320:
	rsb r6, r6, #0x33
	mov lr, r1, lsl r6
	mov r1, r12, lsl #0x1f
	rsb r6, r6, #0x20
	orr r12, lr, r0, lsr r6
	rsb r6, r6, #0x20
	mov lr, r0, lsl r6
	mov r5, r5, lsr #0x15
	orr r5, r5, r4, lsl #0xb
	rsb r6, r6, #0x1f
	mov r0, r5, lsr r6
	mov r4, #0x0
_020EC350:
	rsbs r2, r2, #0x0
	mul r4, r2, r4
	mov r5, #0x0
	umlal r5, r4, r2, r0
	rsc r3, r3, #0x0
	mla r4, r0, r3, r4
	cmp r4, r12
	cmpeq r5, lr
	ldmeqia sp!, {r4-r6,lr}
	bxeq lr
	adds r5, r5, r2
	adc r4, r4, r3
	cmp r4, r12
	bmi _020EC3F4
	bne _020EC398
	cmp r5, lr
	beq _020EC3E4
	blo _020EC3F4
_020EC398:
	subs r5, r5, r2
	sbc r4, r4, r3
_020EC3A0:
	adds r5, r5, r5
	adc r4, r4, r4
	adds r5, r5, r2
	adc r4, r4, r3
	adds lr, lr, lr
	adc r12, r12, r12
	cmp r4, r12
	bmi _020EC3E4
	ldmneia sp!, {r4-r6,lr}
	bxne lr
	cmp r5, lr
	blo _020EC3E4
	ldmneia sp!, {r4-r6,lr}
	bxne lr
	tst r0, #0x1
	ldmeqia sp!, {r4-r6,lr}
	bxeq lr
_020EC3E4:
	adds r0, r0, #0x1
	adc r1, r1, #0x0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC3F4:
	adds r0, r0, #0x1
	adc r1, r1, #0x0
	b _020EC3A0
_020EC400:
	rsbs r2, r2, #0x0
	rsc r3, r3, #0x0
	cmp r1, r3
	cmpeq r0, r2
	mov r1, r12, lsl #0x1f
	mov r0, #0x0
	movne r0, #0x1
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC424:
	mov r1, r12, lsl #0x1f
	mov r0, #0x0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC434:
	orrs r5, r0, r1, lsl #0x1
	beq _020EC558
	cmp r12, lr
	beq _020EC49C
	movs r1, r1, lsl #0xc
	beq _020EC478
	clz r5, r1
	movs r1, r1, lsl r5
	sub r12, r12, r5
	add r5, r12, #0x1f
	mov r1, r1, lsr #0xb
	orr r1, r1, r0, lsr r5
	rsb r5, r5, #0x20
	mov r0, r0, lsl r5
	mov r12, r12, lsl #0x1
	orr r12, r12, r4, lsr #0x1f
	b _020EC0AC
_020EC478:
	mvn r12, #0x13
	clz r5, r0
	movs r0, r0, lsl r5
	sub r12, r12, r5
	mov r1, r0, lsr #0xb
	mov r0, r0, lsl #0x15
	mov r12, r12, lsl #0x1
	orr r12, r12, r4, lsr #0x1f
	b _020EC0AC
_020EC49C:
	orrs r5, r0, r1, lsl #0xc
	bne _020EC580
	bic r5, r3, #0x80000000
	cmp r5, lr, lsl #0x13
	bhs _020EC4C0
	and r5, r3, #0x80000000
	eor r1, r5, r1
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC4C0:
	orrs r5, r2, r3, lsl #0xc
	bne _020EC5A0
	b _020EC5B8
_020EC4CC:
	orrs r5, r2, r3, lsl #0x1
	beq _020EC544
	cmp r4, lr
	beq _020EC52C
	movs r3, r3, lsl #0xc
	beq _020EC50C
	clz r5, r3
	movs r3, r3, lsl r5
	sub r4, r4, r5
	add r5, r4, #0x1f
	mov r3, r3, lsr #0xb
	orr r3, r3, r2, lsr r5
	rsb r5, r5, #0x20
	mov r2, r2, lsl r5
	mov r4, r4, lsl #0x1
	b _020EC0C0
_020EC50C:
	mvn r4, #0x13
	clz r5, r2
	movs r2, r2, lsl r5
	sub r4, r4, r5
	mov r3, r2, lsr #0xb
	mov r2, r2, lsl #0x15
	mov r4, r4, lsl #0x1
	b _020EC0C0
_020EC52C:
	orrs r5, r2, r3, lsl #0xc
	bne _020EC5A0
	mov r1, r12, lsl #0x1f
	mov r0, #0x0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC544:
	mov r1, r12, lsl #0x1f
	orr r1, r1, lr, lsl #0x13
	mov r0, #0x0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC558:
	orrs r5, r2, r3, lsl #0x1
	beq _020EC5B8
	bic r5, r3, #0x80000000
	cmp r5, lr, lsl #0x13
	cmpeq r2, #0x0
	bhi _020EC5A0
	eor r1, r1, r3
	and r1, r1, #0x80000000
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC580:
	tst r1, #0x80000
	beq _020EC5B8
	bic r5, r3, #0x80000000
	cmp r5, lr, lsl #0x13
	cmpeq r2, #0x0
	bhi _020EC5A0
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC5A0:
	tst r3, #0x80000
	beq _020EC5B8
	mov r1, r3
	mov r0, r2
	ldmia sp!, {r4-r6,lr}
	bx lr
_020EC5B8:
	orr r1, r1, #0x7f000000
	orr r1, r1, #0xf80000
	ldmia sp!, {r4-r6,lr}
	bx lr
	.balign 4
_020EC5C8: .word 0x00000FFE
