#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 atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ make_squarewave(short *, int, float, float, float);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memset(short *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ printf(char *, size_t);
int /*<<< orphan*/ write_wav(short *, size_t);
int main(int argc, char *argv[]) {
  FILE *trackfile = fopen(argv[1], "r");
  int note_length = 44100 / atoi(argv[2]);
  char *linebuf = NULL;
  size_t len = 0;
  len = getline(&linebuf, &len, trackfile) - 1;
  printf("%d notes in file\n", len);
  size_t pcmdata_len = len * note_length * sizeof(short);
  short *pcmdata = (short *)malloc(pcmdata_len);
  memset(pcmdata, 0, pcmdata_len);
  int notespacing = note_length / 2;
  int i;
  for (i = 0; i < len; i++) {
    char cur = linebuf[i];
    switch (cur) {
    case 'a':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        440.0f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 440.0f,
                        44100.0f, 0.5f);
      }
      break;
    case 'b':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        493.88f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 493.88f,
                        44100.0f, 0.5f);
      }
      break;
    case 'c':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        523.25f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 523.25f,
                        44100.0f, 0.5f);
      }
      break;
    case 'd':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        587.33f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 587.33f,
                        44100.0f, 0.5f);
      }
      break;
    case 'e':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        659.26f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 659.26f,
                        44100.0f, 0.5f);
      }
      break;
    case 'f':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        701.00f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 701.00f,
                        44100.0f, 0.5f);
      }
      break;
    case 'g':
      if (linebuf[i + 1] == ' ') {
        make_squarewave(pcmdata + (i * note_length), note_length - notespacing,
                        783.99f, 44100.0f, 0.5f);
      } else {
        make_squarewave(pcmdata + (i * note_length), note_length, 783.99f,
                        44100.0f, 0.5f);
      }
      break;
    case ' ':
      make_squarewave(pcmdata + (i * note_length) + note_length - notespacing,
                      notespacing, 0.0f, 44100.0f, 0.0f);
      break;
    default:
      break;
    }
  }
  write_wav(pcmdata, pcmdata_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf9f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    $0xac44,%eax
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <getline@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xf49(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rcx,%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movslq -0x48(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    16d8 <main+0x558>
mov    -0x28(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x49(%rbp)
movsbl -0x49(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x47,%eax
ja     16c0 <main+0x540>
mov    -0x58(%rbp),%rax
lea    0xda0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    12e3 <main+0x163>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0xd57(%rip),%xmm0
movss  0xd2f(%rip),%xmm1
movss  0xd2f(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    1317 <main+0x197>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0xd1e(%rip),%xmm0
movss  0xcf6(%rip),%xmm1
movss  0xcf6(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1372 <main+0x1f2>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0xcc4(%rip),%xmm0
movss  0xca0(%rip),%xmm1
movss  0xca0(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    13a6 <main+0x226>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0xc8b(%rip),%xmm0
movss  0xc67(%rip),%xmm1
movss  0xc67(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1401 <main+0x281>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0xc31(%rip),%xmm0
movss  0xc11(%rip),%xmm1
movss  0xc11(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    1435 <main+0x2b5>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0xbf8(%rip),%xmm0
movss  0xbd8(%rip),%xmm1
movss  0xbd8(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1490 <main+0x310>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0xb9e(%rip),%xmm0
movss  0xb82(%rip),%xmm1
movss  0xb82(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    14c4 <main+0x344>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0xb65(%rip),%xmm0
movss  0xb49(%rip),%xmm1
movss  0xb49(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    151f <main+0x39f>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0xb0b(%rip),%xmm0
movss  0xaf3(%rip),%xmm1
movss  0xaf3(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    1553 <main+0x3d3>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0xad2(%rip),%xmm0
movss  0xaba(%rip),%xmm1
movss  0xaba(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    15ae <main+0x42e>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0xa78(%rip),%xmm0
movss  0xa64(%rip),%xmm1
movss  0xa64(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    15e2 <main+0x462>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0xa3f(%rip),%xmm0
movss  0xa2b(%rip),%xmm1
movss  0xa2b(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    163d <main+0x4bd>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
sub    -0x44(%rbp),%esi
movss  0x9e1(%rip),%xmm0
movss  0x9d5(%rip),%xmm1
movss  0x9d5(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    1671 <main+0x4f1>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%esi
movss  0x9a8(%rip),%xmm0
movss  0x99c(%rip),%xmm1
movss  0x99c(%rip),%xmm2
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x1,%rax
add    %rax,%rdi
movslq -0x1c(%rbp),%rax
shl    $0x1,%rax
add    %rax,%rdi
movslq -0x44(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x44(%rbp),%esi
xorps  %xmm2,%xmm2
movss  0x94d(%rip),%xmm1
movaps %xmm2,%xmm0
call   1030 <make_squarewave@plt>
jmp    16c5 <main+0x545>
jmp    16c5 <main+0x545>
jmp    16ca <main+0x54a>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1247 <main+0xc7>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <write_wav@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xfa8(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    $0xac44,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%r13d
movq   $0x0,0x20(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %rbp,%rdx
call   10a0 <getline@plt>
add    $0xffffffff,%eax
movslq %eax,%rsi
mov    %rsi,0x8(%rsp)
lea    0xf55(%rip),%rdi
call   1040 <printf@plt>
movslq %r13d,%r15
mov    0x8(%rsp),%rbx
imul   %r15,%rbx
add    %rbx,%rbx
mov    %rbx,%rdi
call   1070 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbx,0x28(%rsp)
mov    %rbx,%rdx
call   1050 <memset@plt>
cmpq   $0x0,0x8(%rsp)
je     1422 <main+0x2a2>
mov    %r15d,%eax
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
mov    %r13d,%ebx
sub    %eax,%ebx
add    %r15,%r15
mov    %eax,0x14(%rsp)
cltq
add    %rax,%rax
mov    %r15,%rcx
sub    %rax,%rcx
mov    %rcx,0x30(%rsp)
xor    %r14d,%r14d
lea    0xdc3(%rip),%r12
mov    0x18(%rsp),%rbp
jmp    12a7 <main+0x127>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xdab(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movss  0xd78(%rip),%xmm1
movss  0xd78(%rip),%xmm2
call   1030 <make_squarewave@plt>
add    $0x1,%r14
add    %r15,%rbp
cmp    %r14,0x8(%rsp)
jbe    1422 <main+0x2a2>
mov    0x20(%rsp),%rax
movsbl (%rax,%r14,1),%ecx
add    $0xffffffe0,%ecx
cmp    $0x47,%ecx
ja     1295 <main+0x115>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    0x30(%rsp),%rax
lea    (%rax,%rbp,1),%rdi
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
mov    0x14(%rsp),%esi
movss  0xd23(%rip),%xmm1
jmp    1290 <main+0x110>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
je     1268 <main+0xe8>
mov    %rbp,%rdi
mov    %r13d,%esi
jmp    126d <main+0xed>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
jne    13b0 <main+0x230>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xd09(%rip),%xmm0
jmp    1280 <main+0x100>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
jne    13c3 <main+0x243>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xce5(%rip),%xmm0
jmp    1280 <main+0x100>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
jne    13d6 <main+0x256>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xcc1(%rip),%xmm0
jmp    1280 <main+0x100>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
jne    13e9 <main+0x269>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xc9d(%rip),%xmm0
jmp    1280 <main+0x100>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
jne    13fc <main+0x27c>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xc7d(%rip),%xmm0
jmp    1280 <main+0x100>
lea    0x1(%r14),%ecx
cmpb   $0x20,(%rax,%rcx,1)
jne    140f <main+0x28f>
mov    %rbp,%rdi
mov    %ebx,%esi
movss  0xc59(%rip),%xmm0
jmp    1280 <main+0x100>
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0xc5e(%rip),%xmm0
jmp    1280 <main+0x100>
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0xc47(%rip),%xmm0
jmp    1280 <main+0x100>
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0xc30(%rip),%xmm0
jmp    1280 <main+0x100>
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0xc19(%rip),%xmm0
jmp    1280 <main+0x100>
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0xc02(%rip),%xmm0
jmp    1280 <main+0x100>
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0xbe7(%rip),%xmm0
jmp    1280 <main+0x100>
mov    0x18(%rsp),%rdi
mov    0x28(%rsp),%rsi
call   1060 <write_wav@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"%d notes in file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i16*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = sdiv i32 44100, %22
store i32 %23, i32* %7
store i8* null, i8** %8
store i64 0, i64* %9
%24 = load i32*, i32** %6
%25 = call i32 @getline(i8** %8, i64* %9, i32* %24)
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
store i64 %27, i64* %9
%28 = load i64, i64* %9
%29 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %28)
%30 = load i64, i64* %9
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = mul i64 %30, %32
%34 = mul i64 %33, 2
store i64 %34, i64* %10
%35 = load i64, i64* %10
%36 = call i64 @malloc(i64 %35)
%37 = inttoptr i64 %36 to i16*
store i16* %37, i16** %11
%38 = load i16*, i16** %11
%39 = load i64, i64* %10
%40 = call i32 @memset(i16* %38, i32 0, i64 %39)
%41 = load i32, i32* %7
%42 = sdiv i32 %41, 2
store i32 %42, i32* %12
store i32 0, i32* %13
br label %43
43: ; preds = %284, %2
%44 = load i32, i32* %13
%45 = sext i32 %44 to i64
%46 = load i64, i64* %9
%47 = icmp ult i64 %45, %46
br i1 %47, label %48, label %287
48: ; preds = %43
%49 = load i8*, i8** %8
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
store i8 %53, i8* %14
%54 = load i8, i8* %14
%55 = sext i8 %54 to i32
switch i32 %55, label %282 [
i32 97, label %56
i32 98, label %86
i32 99, label %116
i32 100, label %146
i32 101, label %176
i32 102, label %206
i32 103, label %236
i32 32, label %266
]
56: ; preds = %48
%57 = load i8*, i8** %8
%58 = load i32, i32* %13
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %76
65: ; preds = %56
%66 = load i16*, i16** %11
%67 = load i32, i32* %13
%68 = load i32, i32* %7
%69 = mul nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i16, i16* %66, i64 %70
%72 = load i32, i32* %7
%73 = load i32, i32* %12
%74 = sub nsw i32 %72, %73
%75 = call i32 @make_squarewave(i16* %71, i32 %74, float 4.400000e+02, float 4.410000e+04, float 5.000000e-01)
br label %85
76: ; preds = %56
%77 = load i16*, i16** %11
%78 = load i32, i32* %13
%79 = load i32, i32* %7
%80 = mul nsw i32 %78, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i16, i16* %77, i64 %81
%83 = load i32, i32* %7
%84 = call i32 @make_squarewave(i16* %82, i32 %83, float 4.400000e+02, float 4.410000e+04, float 5.000000e-01)
br label %85
85: ; preds = %76, %65
br label %283
86: ; preds = %48
%87 = load i8*, i8** %8
%88 = load i32, i32* %13
%89 = add nsw i32 %88, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 32
br i1 %94, label %95, label %106
95: ; preds = %86
%96 = load i16*, i16** %11
%97 = load i32, i32* %13
%98 = load i32, i32* %7
%99 = mul nsw i32 %97, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i16, i16* %96, i64 %100
%102 = load i32, i32* %7
%103 = load i32, i32* %12
%104 = sub nsw i32 %102, %103
%105 = call i32 @make_squarewave(i16* %101, i32 %104, float 0x407EDE1480000000, float 4.410000e+04, float 5.000000e-01)
br label %115
106: ; preds = %86
%107 = load i16*, i16** %11
%108 = load i32, i32* %13
%109 = load i32, i32* %7
%110 = mul nsw i32 %108, %109
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i16, i16* %107, i64 %111
%113 = load i32, i32* %7
%114 = call i32 @make_squarewave(i16* %112, i32 %113, float 0x407EDE1480000000, float 4.410000e+04, float 5.000000e-01)
br label %115
115: ; preds = %106, %95
br label %283
116: ; preds = %48
%117 = load i8*, i8** %8
%118 = load i32, i32* %13
%119 = add nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %117, i64 %120
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = icmp eq i32 %123, 32
br i1 %124, label %125, label %136
125: ; preds = %116
%126 = load i16*, i16** %11
%127 = load i32, i32* %13
%128 = load i32, i32* %7
%129 = mul nsw i32 %127, %128
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i16, i16* %126, i64 %130
%132 = load i32, i32* %7
%133 = load i32, i32* %12
%134 = sub nsw i32 %132, %133
%135 = call i32 @make_squarewave(i16* %131, i32 %134, float 5.232500e+02, float 4.410000e+04, float 5.000000e-01)
br label %145
136: ; preds = %116
%137 = load i16*, i16** %11
%138 = load i32, i32* %13
%139 = load i32, i32* %7
%140 = mul nsw i32 %138, %139
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i16, i16* %137, i64 %141
%143 = load i32, i32* %7
%144 = call i32 @make_squarewave(i16* %142, i32 %143, float 5.232500e+02, float 4.410000e+04, float 5.000000e-01)
br label %145
145: ; preds = %136, %125
br label %283
146: ; preds = %48
%147 = load i8*, i8** %8
%148 = load i32, i32* %13
%149 = add nsw i32 %148, 1
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i8, i8* %147, i64 %150
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = icmp eq i32 %153, 32
br i1 %154, label %155, label %166
155: ; preds = %146
%156 = load i16*, i16** %11
%157 = load i32, i32* %13
%158 = load i32, i32* %7
%159 = mul nsw i32 %157, %158
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i16, i16* %156, i64 %160
%162 = load i32, i32* %7
%163 = load i32, i32* %12
%164 = sub nsw i32 %162, %163
%165 = call i32 @make_squarewave(i16* %161, i32 %164, float 0x40825AA3E0000000, float 4.410000e+04, float 5.000000e-01)
br label %175
166: ; preds = %146
%167 = load i16*, i16** %11
%168 = load i32, i32* %13
%169 = load i32, i32* %7
%170 = mul nsw i32 %168, %169
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i16, i16* %167, i64 %171
%173 = load i32, i32* %7
%174 = call i32 @make_squarewave(i16* %172, i32 %173, float 0x40825AA3E0000000, float 4.410000e+04, float 5.000000e-01)
br label %175
175: ; preds = %166, %155
br label %283
176: ; preds = %48
%177 = load i8*, i8** %8
%178 = load i32, i32* %13
%179 = add nsw i32 %178, 1
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8, i8* %177, i64 %180
%182 = load i8, i8* %181
%183 = sext i8 %182 to i32
%184 = icmp eq i32 %183, 32
br i1 %184, label %185, label %196
185: ; preds = %176
%186 = load i16*, i16** %11
%187 = load i32, i32* %13
%188 = load i32, i32* %7
%189 = mul nsw i32 %187, %188
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i16, i16* %186, i64 %190
%192 = load i32, i32* %7
%193 = load i32, i32* %12
%194 = sub nsw i32 %192, %193
%195 = call i32 @make_squarewave(i16* %191, i32 %194, float 0x40849A1480000000, float 4.410000e+04, float 5.000000e-01)
br label %205
196: ; preds = %176
%197 = load i16*, i16** %11
%198 = load i32, i32* %13
%199 = load i32, i32* %7
%200 = mul nsw i32 %198, %199
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds i16, i16* %197, i64 %201
%203 = load i32, i32* %7
%204 = call i32 @make_squarewave(i16* %202, i32 %203, float 0x40849A1480000000, float 4.410000e+04, float 5.000000e-01)
br label %205
205: ; preds = %196, %185
br label %283
206: ; preds = %48
%207 = load i8*, i8** %8
%208 = load i32, i32* %13
%209 = add nsw i32 %208, 1
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i8, i8* %207, i64 %210
%212 = load i8, i8* %211
%213 = sext i8 %212 to i32
%214 = icmp eq i32 %213, 32
br i1 %214, label %215, label %226
215: ; preds = %206
%216 = load i16*, i16** %11
%217 = load i32, i32* %13
%218 = load i32, i32* %7
%219 = mul nsw i32 %217, %218
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds i16, i16* %216, i64 %220
%222 = load i32, i32* %7
%223 = load i32, i32* %12
%224 = sub nsw i32 %222, %223
%225 = call i32 @make_squarewave(i16* %221, i32 %224, float 7.010000e+02, float 4.410000e+04, float 5.000000e-01)
br label %235
226: ; preds = %206
%227 = load i16*, i16** %11
%228 = load i32, i32* %13
%229 = load i32, i32* %7
%230 = mul nsw i32 %228, %229
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds i16, i16* %227, i64 %231
%233 = load i32, i32* %7
%234 = call i32 @make_squarewave(i16* %232, i32 %233, float 7.010000e+02, float 4.410000e+04, float 5.000000e-01)
br label %235
235: ; preds = %226, %215
br label %283
236: ; preds = %48
%237 = load i8*, i8** %8
%238 = load i32, i32* %13
%239 = add nsw i32 %238, 1
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds i8, i8* %237, i64 %240
%242 = load i8, i8* %241
%243 = sext i8 %242 to i32
%244 = icmp eq i32 %243, 32
br i1 %244, label %245, label %256
245: ; preds = %236
%246 = load i16*, i16** %11
%247 = load i32, i32* %13
%248 = load i32, i32* %7
%249 = mul nsw i32 %247, %248
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds i16, i16* %246, i64 %250
%252 = load i32, i32* %7
%253 = load i32, i32* %12
%254 = sub nsw i32 %252, %253
%255 = call i32 @make_squarewave(i16* %251, i32 %254, float 0x40887FEB80000000, float 4.410000e+04, float 5.000000e-01)
br label %265
256: ; preds = %236
%257 = load i16*, i16** %11
%258 = load i32, i32* %13
%259 = load i32, i32* %7
%260 = mul nsw i32 %258, %259
%261 = sext i32 %260 to i64
%262 = getelementptr inbounds i16, i16* %257, i64 %261
%263 = load i32, i32* %7
%264 = call i32 @make_squarewave(i16* %262, i32 %263, float 0x40887FEB80000000, float 4.410000e+04, float 5.000000e-01)
br label %265
265: ; preds = %256, %245
br label %283
266: ; preds = %48
%267 = load i16*, i16** %11
%268 = load i32, i32* %13
%269 = load i32, i32* %7
%270 = mul nsw i32 %268, %269
%271 = sext i32 %270 to i64
%272 = getelementptr inbounds i16, i16* %267, i64 %271
%273 = load i32, i32* %7
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds i16, i16* %272, i64 %274
%276 = load i32, i32* %12
%277 = sext i32 %276 to i64
%278 = sub i64 0, %277
%279 = getelementptr inbounds i16, i16* %275, i64 %278
%280 = load i32, i32* %12
%281 = call i32 @make_squarewave(i16* %279, i32 %280, float 0.000000e+00, float 4.410000e+04, float 0.000000e+00)
br label %283
282: ; preds = %48
br label %283
283: ; preds = %282, %266, %265, %235, %205, %175, %145, %115, %85
br label %284
284: ; preds = %283
%285 = load i32, i32* %13
%286 = add nsw i32 %285, 1
store i32 %286, i32* %13
br label %43
287: ; preds = %43
%288 = load i16*, i16** %11
%289 = load i64, i64* %10
%290 = call i32 @write_wav(i16* %288, i64 %289)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"%d notes in file\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = sdiv i32 44100, %10
%12 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%13 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%14 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
store i64 %16, i64* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %16)
%18 = load i64, i64* %4
%19 = sext i32 %11 to i64
%20 = shl nsw i64 %19, 1
%21 = mul i64 %20, %18
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i16*
%24 = call i32 @memset(i16* %23, i32 0, i64 %21)
%25 = sdiv i32 %11, 2
%26 = load i64, i64* %4
%27 = icmp eq i64 %26, 0
br i1 %27, label %132, label %28
28: ; preds = %2
%29 = sub nsw i32 0, %25
%30 = sext i32 %29 to i64
%31 = sub nsw i32 %11, %25
%32 = getelementptr inbounds i16, i16* %23, i64 %19
%33 = getelementptr inbounds i16, i16* %32, i64 %30
br label %34
34: ; preds = %28, %128
%35 = phi i64 [ 0, %28 ], [ %129, %128 ]
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 %35
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
switch i32 %39, label %128 [
i32 97, label %40
i32 98, label %52
i32 99, label %64
i32 100, label %76
i32 101, label %88
i32 102, label %100
i32 103, label %112
i32 32, label %124
]
40: ; preds = %34
%41 = add nuw i64 %35, 1
%42 = and i64 %41, 4294967295
%43 = getelementptr inbounds i8, i8* %36, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 32
%46 = mul nsw i64 %35, %19
%47 = getelementptr inbounds i16, i16* %23, i64 %46
br i1 %45, label %48, label %50
48: ; preds = %40
%49 = call i32 @make_squarewave(i16* %47, i32 %31, float 4.400000e+02, float 4.410000e+04, float 5.000000e-01)
br label %128
50: ; preds = %40
%51 = call i32 @make_squarewave(i16* %47, i32 %11, float 4.400000e+02, float 4.410000e+04, float 5.000000e-01)
br label %128
52: ; preds = %34
%53 = add nuw i64 %35, 1
%54 = and i64 %53, 4294967295
%55 = getelementptr inbounds i8, i8* %36, i64 %54
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 32
%58 = mul nsw i64 %35, %19
%59 = getelementptr inbounds i16, i16* %23, i64 %58
br i1 %57, label %60, label %62
60: ; preds = %52
%61 = call i32 @make_squarewave(i16* %59, i32 %31, float 0x407EDE1480000000, float 4.410000e+04, float 5.000000e-01)
br label %128
62: ; preds = %52
%63 = call i32 @make_squarewave(i16* %59, i32 %11, float 0x407EDE1480000000, float 4.410000e+04, float 5.000000e-01)
br label %128
64: ; preds = %34
%65 = add nuw i64 %35, 1
%66 = and i64 %65, 4294967295
%67 = getelementptr inbounds i8, i8* %36, i64 %66
%68 = load i8, i8* %67
%69 = icmp eq i8 %68, 32
%70 = mul nsw i64 %35, %19
%71 = getelementptr inbounds i16, i16* %23, i64 %70
br i1 %69, label %72, label %74
72: ; preds = %64
%73 = call i32 @make_squarewave(i16* %71, i32 %31, float 5.232500e+02, float 4.410000e+04, float 5.000000e-01)
br label %128
74: ; preds = %64
%75 = call i32 @make_squarewave(i16* %71, i32 %11, float 5.232500e+02, float 4.410000e+04, float 5.000000e-01)
br label %128
76: ; preds = %34
%77 = add nuw i64 %35, 1
%78 = and i64 %77, 4294967295
%79 = getelementptr inbounds i8, i8* %36, i64 %78
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 32
%82 = mul nsw i64 %35, %19
%83 = getelementptr inbounds i16, i16* %23, i64 %82
br i1 %81, label %84, label %86
84: ; preds = %76
%85 = call i32 @make_squarewave(i16* %83, i32 %31, float 0x40825AA3E0000000, float 4.410000e+04, float 5.000000e-01)
br label %128
86: ; preds = %76
%87 = call i32 @make_squarewave(i16* %83, i32 %11, float 0x40825AA3E0000000, float 4.410000e+04, float 5.000000e-01)
br label %128
88: ; preds = %34
%89 = add nuw i64 %35, 1
%90 = and i64 %89, 4294967295
%91 = getelementptr inbounds i8, i8* %36, i64 %90
%92 = load i8, i8* %91
%93 = icmp eq i8 %92, 32
%94 = mul nsw i64 %35, %19
%95 = getelementptr inbounds i16, i16* %23, i64 %94
br i1 %93, label %96, label %98
96: ; preds = %88
%97 = call i32 @make_squarewave(i16* %95, i32 %31, float 0x40849A1480000000, float 4.410000e+04, float 5.000000e-01)
br label %128
98: ; preds = %88
%99 = call i32 @make_squarewave(i16* %95, i32 %11, float 0x40849A1480000000, float 4.410000e+04, float 5.000000e-01)
br label %128
100: ; preds = %34
%101 = add nuw i64 %35, 1
%102 = and i64 %101, 4294967295
%103 = getelementptr inbounds i8, i8* %36, i64 %102
%104 = load i8, i8* %103
%105 = icmp eq i8 %104, 32
%106 = mul nsw i64 %35, %19
%107 = getelementptr inbounds i16, i16* %23, i64 %106
br i1 %105, label %108, label %110
108: ; preds = %100
%109 = call i32 @make_squarewave(i16* %107, i32 %31, float 7.010000e+02, float 4.410000e+04, float 5.000000e-01)
br label %128
110: ; preds = %100
%111 = call i32 @make_squarewave(i16* %107, i32 %11, float 7.010000e+02, float 4.410000e+04, float 5.000000e-01)
br label %128
112: ; preds = %34
%113 = add nuw i64 %35, 1
%114 = and i64 %113, 4294967295
%115 = getelementptr inbounds i8, i8* %36, i64 %114
%116 = load i8, i8* %115
%117 = icmp eq i8 %116, 32
%118 = mul nsw i64 %35, %19
%119 = getelementptr inbounds i16, i16* %23, i64 %118
br i1 %117, label %120, label %122
120: ; preds = %112
%121 = call i32 @make_squarewave(i16* %119, i32 %31, float 0x40887FEB80000000, float 4.410000e+04, float 5.000000e-01)
br label %128
122: ; preds = %112
%123 = call i32 @make_squarewave(i16* %119, i32 %11, float 0x40887FEB80000000, float 4.410000e+04, float 5.000000e-01)
br label %128
124: ; preds = %34
%125 = mul nsw i64 %35, %19
%126 = getelementptr inbounds i16, i16* %33, i64 %125
%127 = call i32 @make_squarewave(i16* %126, i32 %25, float 0.000000e+00, float 4.410000e+04, float 0.000000e+00)
br label %128
128: ; preds = %34, %120, %122, %108, %110, %96, %98, %84, %86, %72, %74, %60, %62, %48, %50, %124
%129 = add nuw i64 %35, 1
%130 = load i64, i64* %4
%131 = icmp ugt i64 %130, %129
br i1 %131, label %34, label %132
132: ; preds = %128, %2
%133 = call i32 @write_wav(i16* %23, i64 %21)
ret i32 0
}