// File: /workspace/github_c_makefile_star2_O3/kieselsteini[P]PiXL-old/pixl.c
// Function: px_audio_mixer_callback
static void px_audio_mixer_callback(void *userdata, Uint8 *stream, int len) {
  Sint8 *out, value;
  AudioChannel *channel;
  float v;
  int i, j, waveform;

  (void)userdata;
  for (i = 0, out = (Sint8*)stream; i < len; ++i) {
    value = 0;
    for (j = 0; j < PX_AUDIO_CHANNELS; ++j) {
      channel = &channels[j];
      if (--channel->duration < 0) mml_parse_next(channel);
      if (channel->duration > channel->silence) waveform = channel->waveform;
      else waveform = PX_WAVEFORM_SILENCE;
      channel->t += 1.0f / mixing_frequency * channel->frequency;
      channel->t -= (int)channel->t;
      switch (waveform) {
      case PX_WAVEFORM_PULSE_12: value += channel->t <= 0.125f ? 4 : -4; break;
      case PX_WAVEFORM_PULSE_25: value += channel->t <= 0.25f ? 4 : -4; break;
      case PX_WAVEFORM_PULSE_50: value += channel->t <= 0.5f ? 4 : -4; break;
      case PX_WAVEFORM_SAWTOOTH: value += (Sint8)((-1.0f + channel->t * 2.0f) * 4.0f); break;
      case PX_WAVEFORM_TRIANLGE:
        if (channel->t < 0.25f) v = channel->t * 4.0f;
        else if (channel->t < 0.75f) v = 1.0f - ((channel->t - 0.25f) * 4.0f);
        else v = -1.0f + ((channel->t) - 0.75f) * 4.0f;
        value += (Sint8)(v * 8.0f);
        break;
      case PX_WAVEFORM_NOISE: value += audio_noise[(int)(channel->t * (float)PX_AUDIO_NOISE)]; break;
      }
    }
    *out++ = value;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, 0x8(%rsp)
testl %edx, %edx
jle 0x30dec
xorl %eax, %eax
leaq 0x111a76(%rip), %r12    # 0x142510
leaq 0x430f(%rip), %r13      # 0x34db0
leaq 0x43f8(%rip), %rbx      # 0x34ea0
movl %eax, 0xc(%rsp)
movq %rsi, 0x10(%rsp)
xorl %ebp, %ebp
xorl %r14d, %r14d
imulq $0x38, %rbp, %rax
leaq (%r12,%rax), %r15
movl 0x20(%rax,%r12), %ecx
leal -0x1(%rcx), %edx
movl %edx, 0x20(%rax,%r12)
testl %ecx, %ecx
jle 0x30b61
movl 0x20(%r15), %eax
cmpl 0x24(%r15), %eax
jle 0x30b2f
movl 0x1c(%r15), %eax
movss 0x48b7(%rip), %xmm0     # 0x353a0
divss 0x111fdf(%rip), %xmm0   # 0x142ad0
mulss 0x18(%r15), %xmm0
addss 0x14(%r15), %xmm0
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x14(%r15)
decl %eax
cmpl $0x5, %eax
ja 0x30d74
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
movss 0x48a2(%rip), %xmm1     # 0x353cc
jmp 0x30ce3
movss 0x4869(%rip), %xmm0     # 0x353a0
divss 0x111f91(%rip), %xmm0   # 0x142ad0
mulss 0x18(%r15), %xmm0
addss 0x14(%r15), %xmm0
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x14(%r15)
jmp 0x30d74
cmpq $0x0, 0x8(%r15)
je 0x30ad3
movq %r15, %rdi
callq 0x30e50
movq 0x8(%r15), %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r15)
movzbl (%rcx), %edx
leal -0x3c(%rdx), %esi
cmpl $0x3b, %esi
ja 0x30c23
movslq (%r13,%rsi,4), %rdx
addq %r13, %rdx
jmpq *%rdx
movq %r15, %rdi
callq 0x30e78
movl %eax, 0x30(%r15)
jmp 0x30c78
movq %r15, %rdi
callq 0x30e78
movl %eax, 0x28(%r15)
jmp 0x30c78
movq %r15, %rdi
callq 0x30e78
movl %eax, 0x2c(%r15)
jmp 0x30c78
leaq 0x2(%rcx), %rax
movq %rax, 0x8(%r15)
movzbl 0x1(%rcx), %ecx
cmpl $0x4d, %ecx
jle 0x30c43
addl $-0x4e, %ecx
cmpl $0x26, %ecx
ja 0x30c7c
movabsq $0x100000001, %rdx      # imm = 0x100000001
btq %rcx, %rdx
jb 0x30c66
movabsq $0x2000000020, %rdx     # imm = 0x2000000020
btq %rcx, %rdx
jb 0x30c5c
movabsq $0x4000000040, %rdx     # imm = 0x4000000040
btq %rcx, %rdx
jae 0x30c7c
movl $0x5, 0x1c(%r15)
jmp 0x30c78
testl %edx, %edx
jne 0x30c7c
cmpl $0x0, 0x10(%r15)
je 0x30c70
movq (%r15), %rax
movq %rax, 0x8(%r15)
jmp 0x30c7c
incl 0x2c(%r15)
jmp 0x30c78
decl 0x2c(%r15)
jmp 0x30c78
cmpl $0x31, %ecx
je 0x30c8a
cmpl $0x32, %ecx
je 0x30c94
cmpl $0x35, %ecx
jne 0x30c7c
movl $0x3, 0x1c(%r15)
jmp 0x30c7c
movl $0x4, 0x1c(%r15)
jmp 0x30c78
movl $0x6, 0x1c(%r15)
jmp 0x30c78
movq %r15, %rdi
callq 0x3084c
movq 0x8(%r15), %rax
testq %rax, %rax
jne 0x30b6c
jmp 0x30ad3
movl $0x1, 0x1c(%r15)
jmp 0x30c7c
movl $0x2, 0x1c(%r15)
jmp 0x30c7c
movss 0x4702(%rip), %xmm1     # 0x353a8
ucomiss %xmm0, %xmm1
jbe 0x30d11
mulss 0x4701(%rip), %xmm0     # 0x353b4
jmp 0x30d65
movss 0x4708(%rip), %xmm1     # 0x353c8
jmp 0x30ce3
addss %xmm0, %xmm0
addss 0x46ea(%rip), %xmm0     # 0x353b8
mulss 0x46de(%rip), %xmm0     # 0x353b4
jmp 0x30d6d
movss 0x46c5(%rip), %xmm1     # 0x353a8
ucomiss %xmm0, %xmm1
setae %al
shlb $0x3, %al
addb %r14b, %al
addb $-0x4, %al
movl %eax, %r14d
jmp 0x30d74
mulss 0x46a6(%rip), %xmm0     # 0x353a4
cvttss2si %xmm0, %eax
cltq
leaq 0x1119c5(%rip), %rcx    # 0x1426d0
addb (%rax,%rcx), %r14b
jmp 0x30d74
movss 0x4693(%rip), %xmm1     # 0x353ac
ucomiss %xmm0, %xmm1
jbe 0x30d4d
addss 0x4696(%rip), %xmm0     # 0x353bc
mulss 0x4692(%rip), %xmm0     # 0x353c0
addss 0x466a(%rip), %xmm0     # 0x353a0
jmp 0x30d65
movq %r15, %rdi
callq 0x30ec8
movl 0x20(%r15), %eax
movl %eax, 0x24(%r15)
jmp 0x30ad3
addss 0x465b(%rip), %xmm0     # 0x353b0
mulss 0x4657(%rip), %xmm0     # 0x353b4
addss 0x4653(%rip), %xmm0     # 0x353b8
mulss 0x4657(%rip), %xmm0     # 0x353c4
cvttss2si %xmm0, %eax
addb %al, %r14b
incq %rbp
cmpq $0x8, %rbp
jne 0x30ab6
jmp 0x30dd1
movq %r15, %rdi
movl $0x8, %esi
jmp 0x30dc7
movq %r15, %rdi
movl $0xd, %esi
jmp 0x30dc7
movq %r15, %rdi
movl $0x9, %esi
jmp 0x30dc7
movq %r15, %rdi
movl $0x4, %esi
jmp 0x30dc7
movq %r15, %rdi
movl $0x6, %esi
jmp 0x30dc7
movq %r15, %rdi
movl $0xb, %esi
jmp 0x30dc7
movq %r15, %rdi
movl $0xf, %esi
callq 0x30f86
jmp 0x30ad3
movq 0x10(%rsp), %rsi
movb %r14b, (%rsi)
incq %rsi
movl 0xc(%rsp), %eax
incl %eax
cmpl 0x8(%rsp), %eax
jne 0x30aa8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq