#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(unsigned short, int /*<<< orphan*/ *);
void Write_WAVE(FILE *fptr, double *samples, long nsamples, int nfreq, int bits,
                double amp) {
  unsigned short v;
  int i;
  unsigned long totalsize, bytespersec;
  double themin, themax, scale, themid;
  fprintf(fptr, "RIFF");
  totalsize = (bits / 8) * nsamples + 36;
  fputc((totalsize & 0x000000ff), fptr);
  fputc((totalsize & 0x0000ff00) >> 8, fptr);
  fputc((totalsize & 0x00ff0000) >> 16, fptr);
  fputc((totalsize & 0xff000000) >> 24, fptr);
  fprintf(fptr, "WAVE");
  fprintf(fptr, "fmt ");
  fputc(16, fptr);
  fputc(0, fptr);
  fputc(0, fptr);
  fputc(0, fptr);
  fputc(1, fptr);
  fputc(0, fptr);
  fputc(1, fptr);
  fputc(0, fptr);
  fputc((nfreq & 0x000000ff), fptr);
  fputc((nfreq & 0x0000ff00) >> 8, fptr);
  fputc((nfreq & 0x00ff0000) >> 16, fptr);
  fputc((nfreq & 0xff000000) >> 24, fptr);
  bytespersec = (bits / 8) * nfreq;
  fputc((bytespersec & 0x000000ff), fptr);
  fputc((bytespersec & 0x0000ff00) >> 8, fptr);
  fputc((bytespersec & 0x00ff0000) >> 16, fptr);
  fputc((bytespersec & 0xff000000) >> 24, fptr);
  fputc((bits / 8), fptr);
  fputc(0, fptr);
  fputc(bits, fptr);
  fputc(0, fptr);
  fprintf(fptr, "data");
  totalsize = (bits / 8) * nsamples;
  fputc((totalsize & 0x000000ff), fptr);
  fputc((totalsize & 0x0000ff00) >> 8, fptr);
  fputc((totalsize & 0x00ff0000) >> 16, fptr);
  fputc((totalsize & 0xff000000) >> 24, fptr);
  themin = samples[0];
  themax = themin;
  for (i = 1; i < nsamples; i++) {
    if (samples[i] > themax)
      themax = samples[i];
    if (samples[i] < themin)
      themin = samples[i];
  }
  if (themin >= themax) {
    themin -= 1;
    themax += 1;
  }
  themid = (themin + themax) / 2;
  themin -= themid;
  themax -= themid;
  if ((((themin) < 0) ? -(themin) : (themin)) >
      (((themax) < 0) ? -(themax) : (themax)))
    themax = (((themin) < 0) ? -(themin) : (themin));
  scale = amp * ((bits == 16) ? 32760 : 124) / (themax);
  for (i = 0; i < nsamples; i++) {
    if (bits == 16) {
      v = (unsigned short)(scale * (samples[i] - themid));
      fputc((v & 0x00ff), fptr);
      fputc((v & 0xff00) >> 8, fptr);
    } else {
      v = (unsigned char)(scale * (samples[i] - themid));
      fputc(v + 0x80, fptr);
    }
  }
}


x86 assembly (clang, -O0):
<Write_WAVE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
imul   -0x18(%rbp),%rax
add    $0x24,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
and    $0xff,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x38(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x38(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
movabs $0xff000000,%rax
and    -0x38(%rbp),%rax
shr    $0x18,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x10,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
and    $0xff0000,%eax
sar    $0x10,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
imul   -0x1c(%rbp),%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
and    $0xff,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x40(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x40(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
movabs $0xff000000,%rax
and    -0x40(%rbp),%rax
shr    $0x18,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rdi
lea    0xcac(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
imul   -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
and    $0xff,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x38(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x38(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
movabs $0xff000000,%rax
and    -0x38(%rbp),%rax
shr    $0x18,%rax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    148d <Write_WAVE+0x36d>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    144c <Write_WAVE+0x32c>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    147a <Write_WAVE+0x35a>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    147f <Write_WAVE+0x35f>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1414 <Write_WAVE+0x2f4>
movsd  -0x48(%rbp),%xmm0
ucomisd -0x50(%rbp),%xmm0
jb     14c5 <Write_WAVE+0x3a5>
movsd  -0x48(%rbp),%xmm0
movsd  0xb56(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xb45(%rip),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  0xb31(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    153a <Write_WAVE+0x41a>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1544 <Write_WAVE+0x424>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1582 <Write_WAVE+0x462>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    158c <Write_WAVE+0x46c>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    15e8 <Write_WAVE+0x4c8>
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    15d4 <Write_WAVE+0x4b4>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    15de <Write_WAVE+0x4be>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%edx
mov    $0x7c,%eax
mov    $0x7ff8,%ecx
cmp    $0x10,%edx
cmove  %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    16dc <Write_WAVE+0x5bc>
cmpl   $0x10,-0x20(%rbp)
jne    168a <Write_WAVE+0x56a>
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x60(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x2a(%rbp)
movzwl -0x2a(%rbp),%eax
and    $0xff,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
movzwl -0x2a(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
jmp    16c9 <Write_WAVE+0x5a9>
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x60(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%eax
mov    %ax,-0x2a(%rbp)
movzwl -0x2a(%rbp),%eax
add    $0x80,%eax
mov    -0x8(%rbp),%rsi
movzwl %ax,%edi
call   1030 <fputc@plt>
jmp    16ce <Write_WAVE+0x5ae>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1619 <Write_WAVE+0x4f9>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Write_WAVE>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x20(%rsp)
mov    %r8d,%r15d
mov    %ecx,0x10(%rsp)
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r13
lea    0xee5(%rip),%rdi
mov    $0x1,%ebx
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1040 <fwrite@plt>
lea    0x7(%r15),%ecx
test   %r15d,%r15d
cmovns %r15d,%ecx
sar    $0x3,%ecx
mov    %ecx,0xc(%rsp)
mov    %r14d,%eax
imul   %ecx,%eax
mov    %rax,(%rsp)
lea    0x24(%rax),%ebp
movzbl %bpl,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
movzbl %ah,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
shr    $0x18,%ebp
mov    %ebp,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
lea    0xe77(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1040 <fwrite@plt>
lea    0xe63(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1040 <fwrite@plt>
mov    $0x10,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    $0x1,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    $0x1,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
movzbl 0x10(%rsp),%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    0x10(%rsp),%eax
movzbl %ah,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    0x10(%rsp),%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    0x10(%rsp),%eax
shr    $0x18,%eax
mov    %eax,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    0x10(%rsp),%ebp
imul   0xc(%rsp),%ebp
movzbl %bpl,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
movzbl %ah,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
shr    $0x18,%ebp
mov    %ebp,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
movzwl 0xc(%rsp),%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
movzwl %r15w,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
lea    0xd4b(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1040 <fwrite@plt>
movzbl (%rsp),%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    (%rsp),%rax
movzbl %ah,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    (%rsp),%rax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    (%rsp),%rdi
shr    $0x18,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
movsd  (%r12),%xmm0
cmp    $0x2,%r14
jl     1367 <Write_WAVE+0x247>
lea    -0x1(%r14),%rcx
lea    -0x2(%r14),%rdx
mov    %ecx,%eax
and    $0x3,%eax
cmp    $0x3,%rdx
jae    1374 <Write_WAVE+0x254>
movapd %xmm0,%xmm2
jmp    13d9 <Write_WAVE+0x2b9>
movapd %xmm0,%xmm3
movapd %xmm0,%xmm1
jmp    1412 <Write_WAVE+0x2f2>
and    $0xfffffffffffffffc,%rcx
xor    %ebx,%ebx
movapd %xmm0,%xmm2
xchg   %ax,%ax
movsd  0x8(%r12,%rbx,8),%xmm1
movsd  0x10(%r12,%rbx,8),%xmm3
movapd %xmm1,%xmm4
maxsd  %xmm0,%xmm4
minsd  %xmm2,%xmm1
movapd %xmm3,%xmm0
maxsd  %xmm4,%xmm0
minsd  %xmm1,%xmm3
movsd  0x18(%r12,%rbx,8),%xmm1
movapd %xmm1,%xmm4
maxsd  %xmm0,%xmm4
minsd  %xmm3,%xmm1
movsd  0x20(%r12,%rbx,8),%xmm2
movapd %xmm2,%xmm0
maxsd  %xmm4,%xmm0
minsd  %xmm1,%xmm2
add    $0x4,%rbx
cmp    %rbx,%rcx
jne    1380 <Write_WAVE+0x260>
add    $0x1,%rbx
movapd %xmm2,%xmm3
movapd %xmm0,%xmm1
test   %rax,%rax
je     1412 <Write_WAVE+0x2f2>
lea    (%r12,%rbx,8),%rcx
xor    %edx,%edx
nopl   0x0(%rax)
movsd  (%rcx,%rdx,8),%xmm3
movapd %xmm3,%xmm1
maxsd  %xmm0,%xmm1
minsd  %xmm2,%xmm3
add    $0x1,%rdx
movapd %xmm1,%xmm0
movapd %xmm3,%xmm2
cmp    %rdx,%rax
jne    13f0 <Write_WAVE+0x2d0>
ucomisd %xmm1,%xmm3
movapd %xmm1,%xmm0
jb     1428 <Write_WAVE+0x308>
movsd  0xbe4(%rip),%xmm0
addsd  %xmm1,%xmm0
cmp    $0x10,%r15d
mov    $0x7ff8,%ecx
mov    $0x7c,%eax
cmove  %ecx,%eax
test   %r14,%r14
jle    1539 <Write_WAVE+0x419>
movsd  0xbb6(%rip),%xmm2
addsd  %xmm3,%xmm2
cmpnlesd %xmm3,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm2,%xmm1
orpd   %xmm3,%xmm1
movapd %xmm1,%xmm2
addsd  %xmm0,%xmm2
mulsd  0xba1(%rip),%xmm2
subsd  %xmm2,%xmm1
movapd %xmm2,0x10(%rsp)
subsd  %xmm2,%xmm0
movapd 0xb9b(%rip),%xmm2
movapd %xmm1,%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
movapd %xmm1,%xmm5
cmpltsd %xmm4,%xmm5
andpd  %xmm5,%xmm3
andnpd %xmm1,%xmm5
orpd   %xmm3,%xmm5
xorpd  %xmm0,%xmm2
movapd %xmm0,%xmm1
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
cmpltsd %xmm5,%xmm1
movapd %xmm1,%xmm2
andpd  %xmm5,%xmm2
andnpd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
orpd   %xmm2,%xmm1
mulsd  0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
jmp    150a <Write_WAVE+0x3ea>
xchg   %ax,%ax
movzbl %al,%eax
sub    $0xffffff80,%eax
movzwl %ax,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1539 <Write_WAVE+0x419>
movsd  (%r12,%rbx,8),%xmm0
subsd  0x10(%rsp),%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x10,%r15d
jne    14f0 <Write_WAVE+0x3d0>
movzbl %al,%edi
mov    %eax,%ebp
mov    %r13,%rsi
call   1030 <fputc@plt>
mov    %ebp,%eax
movzbl %ah,%eax
jmp    14f6 <Write_WAVE+0x3d6>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"RIFF\00"
@.str.1 = [5 x i8] c"WAVE\00"
@.str.2 = [5 x i8] c"fmt \00"
@.str.3 = [5 x i8] c"data\00"
define void @Write_WAVE(i32* %0, double* %1, i64 %2, i32 %3, i32 %4, double %5) {
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i16
%14 = alloca i32
%15 = alloca i64
%16 = alloca i64
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store i32* %0, i32** %7
store double* %1, double** %8
store i64 %2, i64* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double %5, double* %12
%21 = load i32*, i32** %7
%22 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* %11
%24 = sdiv i32 %23, 8
%25 = sext i32 %24 to i64
%26 = load i64, i64* %9
%27 = mul nsw i64 %25, %26
%28 = add nsw i64 %27, 36
store i64 %28, i64* %15
%29 = load i64, i64* %15
%30 = and i64 %29, 255
%31 = trunc i64 %30 to i16
%32 = load i32*, i32** %7
%33 = call i32 @fputc(i16 zeroext %31, i32* %32)
%34 = load i64, i64* %15
%35 = and i64 %34, 65280
%36 = lshr i64 %35, 8
%37 = trunc i64 %36 to i16
%38 = load i32*, i32** %7
%39 = call i32 @fputc(i16 zeroext %37, i32* %38)
%40 = load i64, i64* %15
%41 = and i64 %40, 16711680
%42 = lshr i64 %41, 16
%43 = trunc i64 %42 to i16
%44 = load i32*, i32** %7
%45 = call i32 @fputc(i16 zeroext %43, i32* %44)
%46 = load i64, i64* %15
%47 = and i64 %46, 4278190080
%48 = lshr i64 %47, 24
%49 = trunc i64 %48 to i16
%50 = load i32*, i32** %7
%51 = call i32 @fputc(i16 zeroext %49, i32* %50)
%52 = load i32*, i32** %7
%53 = call i32 @fprintf(i32* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%54 = load i32*, i32** %7
%55 = call i32 @fprintf(i32* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%56 = load i32*, i32** %7
%57 = call i32 @fputc(i16 zeroext 16, i32* %56)
%58 = load i32*, i32** %7
%59 = call i32 @fputc(i16 zeroext 0, i32* %58)
%60 = load i32*, i32** %7
%61 = call i32 @fputc(i16 zeroext 0, i32* %60)
%62 = load i32*, i32** %7
%63 = call i32 @fputc(i16 zeroext 0, i32* %62)
%64 = load i32*, i32** %7
%65 = call i32 @fputc(i16 zeroext 1, i32* %64)
%66 = load i32*, i32** %7
%67 = call i32 @fputc(i16 zeroext 0, i32* %66)
%68 = load i32*, i32** %7
%69 = call i32 @fputc(i16 zeroext 1, i32* %68)
%70 = load i32*, i32** %7
%71 = call i32 @fputc(i16 zeroext 0, i32* %70)
%72 = load i32, i32* %10
%73 = and i32 %72, 255
%74 = trunc i32 %73 to i16
%75 = load i32*, i32** %7
%76 = call i32 @fputc(i16 zeroext %74, i32* %75)
%77 = load i32, i32* %10
%78 = and i32 %77, 65280
%79 = ashr i32 %78, 8
%80 = trunc i32 %79 to i16
%81 = load i32*, i32** %7
%82 = call i32 @fputc(i16 zeroext %80, i32* %81)
%83 = load i32, i32* %10
%84 = and i32 %83, 16711680
%85 = ashr i32 %84, 16
%86 = trunc i32 %85 to i16
%87 = load i32*, i32** %7
%88 = call i32 @fputc(i16 zeroext %86, i32* %87)
%89 = load i32, i32* %10
%90 = and i32 %89, -16777216
%91 = lshr i32 %90, 24
%92 = trunc i32 %91 to i16
%93 = load i32*, i32** %7
%94 = call i32 @fputc(i16 zeroext %92, i32* %93)
%95 = load i32, i32* %11
%96 = sdiv i32 %95, 8
%97 = load i32, i32* %10
%98 = mul nsw i32 %96, %97
%99 = sext i32 %98 to i64
store i64 %99, i64* %16
%100 = load i64, i64* %16
%101 = and i64 %100, 255
%102 = trunc i64 %101 to i16
%103 = load i32*, i32** %7
%104 = call i32 @fputc(i16 zeroext %102, i32* %103)
%105 = load i64, i64* %16
%106 = and i64 %105, 65280
%107 = lshr i64 %106, 8
%108 = trunc i64 %107 to i16
%109 = load i32*, i32** %7
%110 = call i32 @fputc(i16 zeroext %108, i32* %109)
%111 = load i64, i64* %16
%112 = and i64 %111, 16711680
%113 = lshr i64 %112, 16
%114 = trunc i64 %113 to i16
%115 = load i32*, i32** %7
%116 = call i32 @fputc(i16 zeroext %114, i32* %115)
%117 = load i64, i64* %16
%118 = and i64 %117, 4278190080
%119 = lshr i64 %118, 24
%120 = trunc i64 %119 to i16
%121 = load i32*, i32** %7
%122 = call i32 @fputc(i16 zeroext %120, i32* %121)
%123 = load i32, i32* %11
%124 = sdiv i32 %123, 8
%125 = trunc i32 %124 to i16
%126 = load i32*, i32** %7
%127 = call i32 @fputc(i16 zeroext %125, i32* %126)
%128 = load i32*, i32** %7
%129 = call i32 @fputc(i16 zeroext 0, i32* %128)
%130 = load i32, i32* %11
%131 = trunc i32 %130 to i16
%132 = load i32*, i32** %7
%133 = call i32 @fputc(i16 zeroext %131, i32* %132)
%134 = load i32*, i32** %7
%135 = call i32 @fputc(i16 zeroext 0, i32* %134)
%136 = load i32*, i32** %7
%137 = call i32 @fprintf(i32* %136, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%138 = load i32, i32* %11
%139 = sdiv i32 %138, 8
%140 = sext i32 %139 to i64
%141 = load i64, i64* %9
%142 = mul nsw i64 %140, %141
store i64 %142, i64* %15
%143 = load i64, i64* %15
%144 = and i64 %143, 255
%145 = trunc i64 %144 to i16
%146 = load i32*, i32** %7
%147 = call i32 @fputc(i16 zeroext %145, i32* %146)
%148 = load i64, i64* %15
%149 = and i64 %148, 65280
%150 = lshr i64 %149, 8
%151 = trunc i64 %150 to i16
%152 = load i32*, i32** %7
%153 = call i32 @fputc(i16 zeroext %151, i32* %152)
%154 = load i64, i64* %15
%155 = and i64 %154, 16711680
%156 = lshr i64 %155, 16
%157 = trunc i64 %156 to i16
%158 = load i32*, i32** %7
%159 = call i32 @fputc(i16 zeroext %157, i32* %158)
%160 = load i64, i64* %15
%161 = and i64 %160, 4278190080
%162 = lshr i64 %161, 24
%163 = trunc i64 %162 to i16
%164 = load i32*, i32** %7
%165 = call i32 @fputc(i16 zeroext %163, i32* %164)
%166 = load double*, double** %8
%167 = getelementptr inbounds double, double* %166, i64 0
%168 = load double, double* %167
store double %168, double* %17
%169 = load double, double* %17
store double %169, double* %18
store i32 1, i32* %14
br label %170
170: ; preds = %204, %6
%171 = load i32, i32* %14
%172 = sext i32 %171 to i64
%173 = load i64, i64* %9
%174 = icmp slt i64 %172, %173
br i1 %174, label %175, label %207
175: ; preds = %170
%176 = load double*, double** %8
%177 = load i32, i32* %14
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = load double, double* %18
%182 = fcmp ogt double %180, %181
br i1 %182, label %183, label %189
183: ; preds = %175
%184 = load double*, double** %8
%185 = load i32, i32* %14
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds double, double* %184, i64 %186
%188 = load double, double* %187
store double %188, double* %18
br label %189
189: ; preds = %183, %175
%190 = load double*, double** %8
%191 = load i32, i32* %14
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds double, double* %190, i64 %192
%194 = load double, double* %193
%195 = load double, double* %17
%196 = fcmp olt double %194, %195
br i1 %196, label %197, label %203
197: ; preds = %189
%198 = load double*, double** %8
%199 = load i32, i32* %14
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds double, double* %198, i64 %200
%202 = load double, double* %201
store double %202, double* %17
br label %203
203: ; preds = %197, %189
br label %204
204: ; preds = %203
%205 = load i32, i32* %14
%206 = add nsw i32 %205, 1
store i32 %206, i32* %14
br label %170
207: ; preds = %170
%208 = load double, double* %17
%209 = load double, double* %18
%210 = fcmp oge double %208, %209
br i1 %210, label %211, label %216
211: ; preds = %207
%212 = load double, double* %17
%213 = fsub double %212, 1.000000e+00
store double %213, double* %17
%214 = load double, double* %18
%215 = fadd double %214, 1.000000e+00
store double %215, double* %18
br label %216
216: ; preds = %211, %207
%217 = load double, double* %17
%218 = load double, double* %18
%219 = fadd double %217, %218
%220 = fdiv double %219, 2.000000e+00
store double %220, double* %20
%221 = load double, double* %20
%222 = load double, double* %17
%223 = fsub double %222, %221
store double %223, double* %17
%224 = load double, double* %20
%225 = load double, double* %18
%226 = fsub double %225, %224
store double %226, double* %18
%227 = load double, double* %17
%228 = fcmp olt double %227, 0.000000e+00
br i1 %228, label %229, label %232
229: ; preds = %216
%230 = load double, double* %17
%231 = fneg double %230
br label %234
232: ; preds = %216
%233 = load double, double* %17
br label %234
234: ; preds = %232, %229
%235 = phi double [ %231, %229 ], [ %233, %232 ]
%236 = load double, double* %18
%237 = fcmp olt double %236, 0.000000e+00
br i1 %237, label %238, label %241
238: ; preds = %234
%239 = load double, double* %18
%240 = fneg double %239
br label %243
241: ; preds = %234
%242 = load double, double* %18
br label %243
243: ; preds = %241, %238
%244 = phi double [ %240, %238 ], [ %242, %241 ]
%245 = fcmp ogt double %235, %244
br i1 %245, label %246, label %256
246: ; preds = %243
%247 = load double, double* %17
%248 = fcmp olt double %247, 0.000000e+00
br i1 %248, label %249, label %252
249: ; preds = %246
%250 = load double, double* %17
%251 = fneg double %250
br label %254
252: ; preds = %246
%253 = load double, double* %17
br label %254
254: ; preds = %252, %249
%255 = phi double [ %251, %249 ], [ %253, %252 ]
store double %255, double* %18
br label %256
256: ; preds = %254, %243
%257 = load double, double* %12
%258 = load i32, i32* %11
%259 = icmp eq i32 %258, 16
%260 = zext i1 %259 to i64
%261 = select i1 %259, i32 32760, i32 124
%262 = sitofp i32 %261 to double
%263 = fmul double %257, %262
%264 = load double, double* %18
%265 = fdiv double %263, %264
store double %265, double* %19
store i32 0, i32* %14
br label %266
266: ; preds = %317, %256
%267 = load i32, i32* %14
%268 = sext i32 %267 to i64
%269 = load i64, i64* %9
%270 = icmp slt i64 %268, %269
br i1 %270, label %271, label %320
271: ; preds = %266
%272 = load i32, i32* %11
%273 = icmp eq i32 %272, 16
br i1 %273, label %274, label %298
274: ; preds = %271
%275 = load double, double* %19
%276 = load double*, double** %8
%277 = load i32, i32* %14
%278 = sext i32 %277 to i64
%279 = getelementptr inbounds double, double* %276, i64 %278
%280 = load double, double* %279
%281 = load double, double* %20
%282 = fsub double %280, %281
%283 = fmul double %275, %282
%284 = fptoui double %283 to i16
store i16 %284, i16* %13
%285 = load i16, i16* %13
%286 = zext i16 %285 to i32
%287 = and i32 %286, 255
%288 = trunc i32 %287 to i16
%289 = load i32*, i32** %7
%290 = call i32 @fputc(i16 zeroext %288, i32* %289)
%291 = load i16, i16* %13
%292 = zext i16 %291 to i32
%293 = and i32 %292, 65280
%294 = ashr i32 %293, 8
%295 = trunc i32 %294 to i16
%296 = load i32*, i32** %7
%297 = call i32 @fputc(i16 zeroext %295, i32* %296)
br label %316
298: ; preds = %271
%299 = load double, double* %19
%300 = load double*, double** %8
%301 = load i32, i32* %14
%302 = sext i32 %301 to i64
%303 = getelementptr inbounds double, double* %300, i64 %302
%304 = load double, double* %303
%305 = load double, double* %20
%306 = fsub double %304, %305
%307 = fmul double %299, %306
%308 = fptoui double %307 to i8
%309 = zext i8 %308 to i16
store i16 %309, i16* %13
%310 = load i16, i16* %13
%311 = zext i16 %310 to i32
%312 = add nsw i32 %311, 128
%313 = trunc i32 %312 to i16
%314 = load i32*, i32** %7
%315 = call i32 @fputc(i16 zeroext %313, i32* %314)
br label %316
316: ; preds = %298, %274
br label %317
317: ; preds = %316
%318 = load i32, i32* %14
%319 = add nsw i32 %318, 1
store i32 %319, i32* %14
br label %266
320: ; preds = %266
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"RIFF\00"
@.str.1 = [5 x i8] c"WAVE\00"
@.str.2 = [5 x i8] c"fmt \00"
@.str.3 = [5 x i8] c"data\00"
define void @Write_WAVE(i32* %0, double* nocapture %1, i64 %2, i32 %3, i32 %4, double %5) {
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 4, i64 1, i32* %0)
%8 = sdiv i32 %4, 8
%9 = zext i32 %8 to i64
%10 = mul i64 %9, %2
%11 = add i64 %10, 36
%12 = trunc i64 %11 to i16
%13 = and i16 %12, 255
%14 = tail call i32 @fputc(i16 zeroext %13, i32* %0)
%15 = lshr i16 %12, 8
%16 = tail call i32 @fputc(i16 zeroext %15, i32* %0)
%17 = lshr i64 %11, 16
%18 = trunc i64 %17 to i16
%19 = and i16 %18, 255
%20 = tail call i32 @fputc(i16 zeroext %19, i32* %0)
%21 = lshr i64 %11, 24
%22 = trunc i64 %21 to i16
%23 = and i16 %22, 255
%24 = tail call i32 @fputc(i16 zeroext %23, i32* %0)
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 4, i64 1, i32* %0)
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 4, i64 1, i32* %0)
%27 = tail call i32 @fputc(i16 zeroext 16, i32* %0)
%28 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%29 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%30 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%31 = tail call i32 @fputc(i16 zeroext 1, i32* %0)
%32 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%33 = tail call i32 @fputc(i16 zeroext 1, i32* %0)
%34 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%35 = trunc i32 %3 to i16
%36 = and i16 %35, 255
%37 = tail call i32 @fputc(i16 zeroext %36, i32* %0)
%38 = lshr i16 %35, 8
%39 = tail call i32 @fputc(i16 zeroext %38, i32* %0)
%40 = lshr i32 %3, 16
%41 = trunc i32 %40 to i16
%42 = and i16 %41, 255
%43 = tail call i32 @fputc(i16 zeroext %42, i32* %0)
%44 = lshr i32 %3, 24
%45 = trunc i32 %44 to i16
%46 = tail call i32 @fputc(i16 zeroext %45, i32* %0)
%47 = mul nsw i32 %8, %3
%48 = trunc i32 %47 to i16
%49 = and i16 %48, 255
%50 = tail call i32 @fputc(i16 zeroext %49, i32* %0)
%51 = lshr i16 %48, 8
%52 = tail call i32 @fputc(i16 zeroext %51, i32* %0)
%53 = lshr i32 %47, 16
%54 = trunc i32 %53 to i16
%55 = and i16 %54, 255
%56 = tail call i32 @fputc(i16 zeroext %55, i32* %0)
%57 = lshr i32 %47, 24
%58 = trunc i32 %57 to i16
%59 = tail call i32 @fputc(i16 zeroext %58, i32* %0)
%60 = trunc i32 %8 to i16
%61 = tail call i32 @fputc(i16 zeroext %60, i32* %0)
%62 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%63 = trunc i32 %4 to i16
%64 = tail call i32 @fputc(i16 zeroext %63, i32* %0)
%65 = tail call i32 @fputc(i16 zeroext 0, i32* %0)
%66 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4, i64 1, i32* %0)
%67 = trunc i64 %10 to i16
%68 = and i16 %67, 255
%69 = tail call i32 @fputc(i16 zeroext %68, i32* %0)
%70 = lshr i16 %67, 8
%71 = tail call i32 @fputc(i16 zeroext %70, i32* %0)
%72 = lshr i64 %10, 16
%73 = trunc i64 %72 to i16
%74 = and i16 %73, 255
%75 = tail call i32 @fputc(i16 zeroext %74, i32* %0)
%76 = lshr i64 %10, 24
%77 = trunc i64 %76 to i16
%78 = and i16 %77, 255
%79 = tail call i32 @fputc(i16 zeroext %78, i32* %0)
%80 = load double, double* %1
%81 = icmp sgt i64 %2, 1
br i1 %81, label %82, label %145
82: ; preds = %6
%83 = add i64 %2, -1
%84 = add i64 %2, -2
%85 = and i64 %83, 3
%86 = icmp ult i64 %84, 3
br i1 %86, label %124, label %87
87: ; preds = %82
%88 = and i64 %83, -4
br label %89
89: ; preds = %89, %87
%90 = phi i64 [ 1, %87 ], [ %121, %89 ]
%91 = phi double [ %80, %87 ], [ %118, %89 ]
%92 = phi double [ %80, %87 ], [ %120, %89 ]
%93 = phi i64 [ 0, %87 ], [ %122, %89 ]
%94 = getelementptr inbounds double, double* %1, i64 %90
%95 = load double, double* %94
%96 = fcmp ogt double %95, %91
%97 = select i1 %96, double %95, double %91
%98 = fcmp olt double %95, %92
%99 = select i1 %98, double %95, double %92
%100 = add nuw nsw i64 %90, 1
%101 = getelementptr inbounds double, double* %1, i64 %100
%102 = load double, double* %101
%103 = fcmp ogt double %102, %97
%104 = select i1 %103, double %102, double %97
%105 = fcmp olt double %102, %99
%106 = select i1 %105, double %102, double %99
%107 = add nuw nsw i64 %90, 2
%108 = getelementptr inbounds double, double* %1, i64 %107
%109 = load double, double* %108
%110 = fcmp ogt double %109, %104
%111 = select i1 %110, double %109, double %104
%112 = fcmp olt double %109, %106
%113 = select i1 %112, double %109, double %106
%114 = add nuw nsw i64 %90, 3
%115 = getelementptr inbounds double, double* %1, i64 %114
%116 = load double, double* %115
%117 = fcmp ogt double %116, %111
%118 = select i1 %117, double %116, double %111
%119 = fcmp olt double %116, %113
%120 = select i1 %119, double %116, double %113
%121 = add nuw nsw i64 %90, 4
%122 = add i64 %93, 4
%123 = icmp eq i64 %122, %88
br i1 %123, label %124, label %89
124: ; preds = %89, %82
%125 = phi double [ undef, %82 ], [ %118, %89 ]
%126 = phi double [ undef, %82 ], [ %120, %89 ]
%127 = phi i64 [ 1, %82 ], [ %121, %89 ]
%128 = phi double [ %80, %82 ], [ %118, %89 ]
%129 = phi double [ %80, %82 ], [ %120, %89 ]
%130 = icmp eq i64 %85, 0
br i1 %130, label %145, label %131
131: ; preds = %124, %131
%132 = phi i64 [ %142, %131 ], [ %127, %124 ]
%133 = phi double [ %139, %131 ], [ %128, %124 ]
%134 = phi double [ %141, %131 ], [ %129, %124 ]
%135 = phi i64 [ %143, %131 ], [ 0, %124 ]
%136 = getelementptr inbounds double, double* %1, i64 %132
%137 = load double, double* %136
%138 = fcmp ogt double %137, %133
%139 = select i1 %138, double %137, double %133
%140 = fcmp olt double %137, %134
%141 = select i1 %140, double %137, double %134
%142 = add nuw nsw i64 %132, 1
%143 = add i64 %135, 1
%144 = icmp eq i64 %143, %85
br i1 %144, label %145, label %131
145: ; preds = %124, %131, %6
%146 = phi double [ %80, %6 ], [ %126, %124 ], [ %141, %131 ]
%147 = phi double [ %80, %6 ], [ %125, %124 ], [ %139, %131 ]
%148 = fcmp ult double %146, %147
%149 = fadd double %146, -1.000000e+00
%150 = fadd double %147, 1.000000e+00
%151 = select i1 %148, double %146, double %149
%152 = select i1 %148, double %147, double %150
%153 = fadd double %151, %152
%154 = fmul double %153, 5.000000e-01
%155 = fsub double %151, %154
%156 = fsub double %152, %154
%157 = fcmp olt double %155, 0.000000e+00
%158 = fneg double %155
%159 = select i1 %157, double %158, double %155
%160 = fcmp olt double %156, 0.000000e+00
%161 = fneg double %156
%162 = select i1 %160, double %161, double %156
%163 = fcmp ogt double %159, %162
%164 = select i1 %163, double %159, double %156
%165 = icmp eq i32 %4, 16
%166 = select i1 %165, i32 32760, i32 124
%167 = sitofp i32 %166 to double
%168 = fmul double %167, %5
%169 = fdiv double %168, %164
%170 = icmp sgt i64 %2, 0
br i1 %170, label %171, label %191
171: ; preds = %145, %186
%172 = phi i64 [ %189, %186 ], [ 0, %145 ]
%173 = getelementptr inbounds double, double* %1, i64 %172
%174 = load double, double* %173
%175 = fsub double %174, %154
%176 = fmul double %169, %175
br i1 %165, label %177, label %182
177: ; preds = %171
%178 = fptoui double %176 to i16
%179 = and i16 %178, 255
%180 = tail call i32 @fputc(i16 zeroext %179, i32* %0)
%181 = lshr i16 %178, 8
br label %186
182: ; preds = %171
%183 = fptoui double %176 to i8
%184 = zext i8 %183 to i16
%185 = add nuw nsw i16 %184, 128
br label %186
186: ; preds = %177, %182
%187 = phi i16 [ %181, %177 ], [ %185, %182 ]
%188 = tail call i32 @fputc(i16 zeroext %187, i32* %0)
%189 = add nuw nsw i64 %172, 1
%190 = icmp eq i64 %189, %2
br i1 %190, label %191, label %171
191: ; preds = %186, %145
ret void
}