// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x52656
movb $0x0, -0x21(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x8, -0x3c(%rbp)
jge 0x52634
movslq -0x3c(%rbp), %rcx
leaq 0x112182(%rip), %rax    # 0x164520
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movl 0x20(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x20(%rcx)
cmpl $0x0, %eax
jge 0x523c4
movq -0x30(%rbp), %rdi
callq 0x528b0
movq -0x30(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jle 0x523e0
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x40(%rbp)
jmp 0x523e7
movl $0x0, -0x40(%rbp)
movss 0x1126f1(%rip), %xmm1   # 0x164ae0
movss 0x52d9(%rip), %xmm0     # 0x576d0
divss %xmm1, %xmm0
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm1
movss 0x18(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x14(%rax)
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm0
movaps %xmm0, %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x14(%rax)
movl -0x40(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x5, %eax
ja 0x52624
movq -0x48(%rbp), %rax
leaq 0x52af(%rip), %rcx      # 0x57700
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm1
movss 0x5285(%rip), %xmm0     # 0x576f0
movl $0xfffffffc, %ecx       # imm = 0xFFFFFFFC
movl $0x4, %eax
ucomiss %xmm1, %xmm0
cmovael %eax, %ecx
movsbl -0x21(%rbp), %eax
addl %ecx, %eax
movb %al, -0x21(%rbp)
jmp 0x52624
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm1
movss 0x523e(%rip), %xmm0     # 0x576d8
movl $0xfffffffc, %ecx       # imm = 0xFFFFFFFC
movl $0x4, %eax
ucomiss %xmm1, %xmm0
cmovael %eax, %ecx
movsbl -0x21(%rbp), %eax
addl %ecx, %eax
movb %al, -0x21(%rbp)
jmp 0x52624
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm1
movss 0x5223(%rip), %xmm0     # 0x576ec
movl $0xfffffffc, %ecx       # imm = 0xFFFFFFFC
movl $0x4, %eax
ucomiss %xmm1, %xmm0
cmovael %eax, %ecx
movsbl -0x21(%rbp), %eax
addl %ecx, %eax
movb %al, -0x21(%rbp)
jmp 0x52624
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm0
addss %xmm0, %xmm0
movss 0x51e8(%rip), %xmm1     # 0x576e4
addss %xmm1, %xmm0
movss 0x51d8(%rip), %xmm1     # 0x576e0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movsbl %al, %ecx
movsbl -0x21(%rbp), %eax
addl %ecx, %eax
movb %al, -0x21(%rbp)
jmp 0x52624
movq -0x30(%rbp), %rax
movss 0x51ab(%rip), %xmm0     # 0x576d8
ucomiss 0x14(%rax), %xmm0
jbe 0x5254e
movq -0x30(%rbp), %rax
movss 0x51a1(%rip), %xmm0     # 0x576e0
mulss 0x14(%rax), %xmm0
movss %xmm0, -0x34(%rbp)
jmp 0x525d5
movq -0x30(%rbp), %rax
movss 0x5182(%rip), %xmm0     # 0x576dc
ucomiss 0x14(%rax), %xmm0
jbe 0x525a1
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm0
movss 0x5167(%rip), %xmm1     # 0x576d8
subss %xmm1, %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss 0x5156(%rip), %xmm1     # 0x576e0
mulss %xmm1, %xmm0
movss 0x513a(%rip), %xmm1     # 0x576d0
addss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
jmp 0x525d3
movq -0x30(%rbp), %rax
movss 0x14(%rax), %xmm0
movss 0x512a(%rip), %xmm1     # 0x576dc
subss %xmm1, %xmm0
movss 0x5122(%rip), %xmm1     # 0x576e0
mulss %xmm1, %xmm0
movss 0x511a(%rip), %xmm1     # 0x576e4
addss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
jmp 0x525d5
movss -0x34(%rbp), %xmm0
movss 0x5106(%rip), %xmm1     # 0x576e8
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movsbl %al, %ecx
movsbl -0x21(%rbp), %eax
addl %ecx, %eax
movb %al, -0x21(%rbp)
jmp 0x52624
movq -0x30(%rbp), %rax
movss 0x50d0(%rip), %xmm0     # 0x576d4
mulss 0x14(%rax), %xmm0
cvttss2si %xmm0, %eax
movslq %eax, %rcx
leaq 0x1120c9(%rip), %rax    # 0x1646e0
movsbl (%rax,%rcx), %ecx
movsbl -0x21(%rbp), %eax
addl %ecx, %eax
movb %al, -0x21(%rbp)
jmp 0x52626
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x52389
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x52372
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)