// File: /workspace/github_c_makefile_star2_O0/baines[P]MiniGBS/audio.c
// Function: audio_get_vol
void audio_get_vol(uint8_t vol[static 8]){
	for(int i = 0; i < 4; ++i){
		vol[i*2+0] = chans[i].volume * chans[i].on_left;
		vol[i*2+1] = chans[i].volume * chans[i].on_right;
	}

	int ch3_hi = 0, ch3_lo = 0xf;
	for(uint8_t* p = mem + 0xFF30; p < mem + 0xFF40; ++p){
		uint8_t a = *p >> 4, b = *p & 0xF;
		ch3_lo = MIN(ch3_lo, MIN(a, b));
		ch3_hi = MAX(ch3_hi, MAX(a, b));
	}

	float ch3_v = (ch3_hi - ch3_lo) / 15.0f;

	if(vol[4]) vol[4] = 5*(4-vol[4]) * ch3_v;
	if(vol[5]) vol[5] = 5*(4-vol[5]) * ch3_v;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x4, -0xc(%rbp)
jge 0xc5d5
movslq -0xc(%rbp), %rcx
leaq 0xa53c(%rip), %rax      # 0x16a80
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movslq -0xc(%rbp), %rdx
leaq 0xa527(%rip), %rcx      # 0x16a80
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movb 0x2(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
imull %ecx, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq -0xc(%rbp), %rcx
leaq 0xa4f5(%rip), %rax      # 0x16a80
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movslq -0xc(%rbp), %rdx
leaq 0xa4e0(%rip), %rcx      # 0x16a80
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movb 0x3(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
imull %ecx, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xc52f
movl $0x0, -0x10(%rbp)
movl $0xf, -0x14(%rbp)
leaq 0xa326(%rip), %rax      # 0x16910
movq (%rax), %rax
addq $0xff30, %rax           # imm = 0xFF30
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
leaq 0xa30e(%rip), %rcx      # 0x16910
movq (%rcx), %rcx
addq $0xff40, %rcx           # imm = 0xFF40
cmpq %rcx, %rax
jae 0xc6f8
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
sarl $0x4, %eax
movb %al, -0x21(%rbp)
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
andl $0xf, %eax
movb %al, -0x22(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
movb -0x21(%rbp), %al
movb %al, -0x2d(%rbp)
movb -0x22(%rbp), %al
movb %al, -0x2e(%rbp)
movzbl -0x2d(%rbp), %eax
movzbl -0x2e(%rbp), %ecx
cmpl %ecx, %eax
jg 0xc656
movzbl -0x2d(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0xc65d
movzbl -0x2e(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0xc679
movl -0x28(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0xc67f
movl -0x2c(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x3c(%rbp)
movb -0x21(%rbp), %al
movb %al, -0x41(%rbp)
movb -0x22(%rbp), %al
movb %al, -0x42(%rbp)
movzbl -0x41(%rbp), %eax
movzbl -0x42(%rbp), %ecx
cmpl %ecx, %eax
jle 0xc6b2
movzbl -0x41(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0xc6b9
movzbl -0x42(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0xc6d5
movl -0x3c(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0xc6db
movl -0x40(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xc5f7
movl -0x10(%rbp), %eax
subl -0x14(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x5182(%rip), %xmm1     # 0x1188c
divss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0xc74b
movq -0x8(%rbp), %rax
movzbl 0x4(%rax), %eax
movl $0x4, %ecx
subl %eax, %ecx
movl %ecx, %eax
leal (%rax,%rax,4), %eax
cvtsi2ss %eax, %xmm0
movss -0x50(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x8(%rbp), %rax
cmpb $0x0, 0x5(%rax)
je 0xc783
movq -0x8(%rbp), %rax
movzbl 0x5(%rax), %eax
movl $0x4, %ecx
subl %eax, %ecx
movl %ecx, %eax
leal (%rax,%rax,4), %eax
cvtsi2ss %eax, %xmm0
movss -0x50(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x5(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)