// File: /workspace/github_c_makefile_star2_O2/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
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movl %edx, 0x8(%rsp)
leaq 0x113a26(%rip), %r15    # 0x13b510
leaq 0x430f(%rip), %r12      # 0x2be00
leaq 0x43f8(%rip), %rbp      # 0x2bef0
cmpl 0x8(%rsp), %eax
je 0x27dd4
movl %eax, 0xc(%rsp)
movq %rsi, 0x10(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
cmpq $0x8, %r14
je 0x27dbf
imulq $0x38, %r14, %rax
leaq (%r15,%rax), %r13
movl 0x20(%rax,%r15), %ecx
leal -0x1(%rcx), %edx
movl %edx, 0x20(%rax,%r15)
testl %ecx, %ecx
jg 0x27ca1
jmp 0x27c27
movq %r13, %rdi
callq 0x27e54
movl %eax, 0x30(%r13)
jmp 0x27c27
movq %r13, %rdi
callq 0x27e54
movl %eax, 0x2c(%r13)
jmp 0x27c27
movq %r13, %rdi
callq 0x27e54
movl %eax, 0x28(%r13)
jmp 0x27c27
leaq 0x2(%rax), %rcx
movq %rcx, 0x8(%r13)
movzbl 0x1(%rax), %eax
leal -0x4e(%rax), %ecx
cmpl $0x26, %ecx
ja 0x27bde
movabsq $0x100000001, %rdx      # imm = 0x100000001
btq %rcx, %rdx
jb 0x27bf7
movabsq $0x2000000020, %rdx     # imm = 0x2000000020
btq %rcx, %rdx
jb 0x27c01
movabsq $0x4000000040, %rdx     # imm = 0x4000000040
btq %rcx, %rdx
jae 0x27bde
movl $0x5, 0x1c(%r13)
jmp 0x27c27
testl %ecx, %ecx
jne 0x27c27
cmpl $0x0, 0x10(%r13)
je 0x27c0b
movq (%r13), %rax
movq %rax, 0x8(%r13)
jmp 0x27c27
decl 0x2c(%r13)
jmp 0x27c27
incl 0x2c(%r13)
jmp 0x27c27
cmpl $0x35, %eax
je 0x27c1f
cmpl $0x32, %eax
je 0x27c15
cmpl $0x31, %eax
jne 0x27c27
movl $0x1, 0x1c(%r13)
jmp 0x27c27
movl $0x6, 0x1c(%r13)
jmp 0x27c27
movl $0x4, 0x1c(%r13)
jmp 0x27c27
movq %r13, %rdi
callq 0x27835
jmp 0x27c27
movl $0x2, 0x1c(%r13)
jmp 0x27c27
movl $0x3, 0x1c(%r13)
cmpq $0x0, 0x8(%r13)
je 0x27ca1
movq %r13, %rdi
callq 0x27e31
movq 0x8(%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r13)
movzbl (%rax), %ecx
leal -0x3c(%rcx), %edx
cmpl $0x3b, %edx
ja 0x27bbd
movslq (%r12,%rdx,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movq %r13, %rdi
callq 0x27e94
movl 0x20(%r13), %eax
movl %eax, 0x24(%r13)
jmp 0x27ca1
movq %r13, %rdi
pushq $0x6
jmp 0x27c9b
movq %r13, %rdi
pushq $0x4
jmp 0x27c9b
movq %r13, %rdi
pushq $0x8
jmp 0x27c9b
movq %r13, %rdi
pushq $0xd
jmp 0x27c9b
movq %r13, %rdi
pushq $0xb
jmp 0x27c9b
movq %r13, %rdi
pushq $0xf
jmp 0x27c9b
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0x27f42
movl 0x20(%r13), %ecx
xorl %eax, %eax
cmpl 0x24(%r13), %ecx
jle 0x27cb1
movl 0x1c(%r13), %eax
movss 0x4753(%rip), %xmm0     # 0x2c40c
divss 0x113e0f(%rip), %xmm0   # 0x13bad0
mulss 0x18(%r13), %xmm0
addss 0x14(%r13), %xmm0
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x14(%r13)
decl %eax
cmpl $0x5, %eax
ja 0x27db7
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movss 0x473d(%rip), %xmm1     # 0x2c438
jmp 0x27d3f
movss 0x470f(%rip), %xmm1     # 0x2c414
ucomiss %xmm0, %xmm1
jbe 0x27d6a
mulss 0x470e(%rip), %xmm0     # 0x2c420
jmp 0x27da9
movss 0x4715(%rip), %xmm1     # 0x2c434
jmp 0x27d3f
addss %xmm0, %xmm0
addss 0x46f7(%rip), %xmm0     # 0x2c424
mulss 0x46eb(%rip), %xmm0     # 0x2c420
jmp 0x27db1
movss 0x46d5(%rip), %xmm1     # 0x2c414
ucomiss %xmm0, %xmm1
setae %al
shlb $0x3, %al
addb %bl, %al
addb $-0x4, %al
movl %eax, %ebx
jmp 0x27db7
mulss 0x46b8(%rip), %xmm0     # 0x2c410
cvttss2si %xmm0, %eax
cltq
leaq 0x11396b(%rip), %rcx    # 0x13b6d0
addb (%rax,%rcx), %bl
jmp 0x27db7
movss 0x46a6(%rip), %xmm1     # 0x2c418
ucomiss %xmm0, %xmm1
jbe 0x27d91
addss 0x46a9(%rip), %xmm0     # 0x2c428
mulss 0x46a5(%rip), %xmm0     # 0x2c42c
addss 0x467d(%rip), %xmm0     # 0x2c40c
jmp 0x27da9
addss 0x4683(%rip), %xmm0     # 0x2c41c
mulss 0x467f(%rip), %xmm0     # 0x2c420
addss 0x467b(%rip), %xmm0     # 0x2c424
mulss 0x467f(%rip), %xmm0     # 0x2c430
cvttss2si %xmm0, %eax
addb %al, %bl
incq %r14
jmp 0x27b10
movq 0x10(%rsp), %rsi
movb %bl, (%rsi)
incq %rsi
movl 0xc(%rsp), %eax
incl %eax
jmp 0x27af8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq