#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*/ argv;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
float sin(float);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(unsigned char *, char *);
int /*<<< orphan*/ write_wav(unsigned char *, int, unsigned short *, int);
int main(int argc, char **argv) {
  if (argc != 5) {
    printf("usage: %s -i <input file> -o <output file>\n", argv[0]);
    return 0;
  }
  int message_len;
  unsigned char *message;
  unsigned char *output_file_name;
  for (int i = 0; i < argc; i++) {
    if (!strcmp(argv[i], "-i")) {
      FILE *fp = fopen(argv[i + 1], "r");
      if (fp == NULL) {
        printf("error opening input file\n");
        return 0;
      }
      long file_size;
      fseek(fp, 0, SEEK_END);
      file_size = ftell(fp);
      message_len = file_size;
      rewind(fp);
      message = malloc(file_size + 1);
      fread(message, 1, file_size, fp);
      fclose(fp);
      if (message_len > 2147483646) {
        printf("error maximum message length 2147483646 bytes\n");
        exit(0);
      }
    } else if (!strcmp(argv[i], "-o")) {
      output_file_name = malloc(sizeof(argv[i + 1]) + 1);
      strcpy(output_file_name, argv[i + 1]);
    }
  }
  int buffer_size = (44100) + 2;
  while (buffer_size / 8 < message_len) {
    buffer_size += (44100);
  }
  unsigned short buffer[buffer_size];
  int i;
  float t;
  float amplitude = 32000;
  float freq_Hz = 440;
  float change = freq_Hz * 2 * 3.14159265359 / (44100);
  float phase = 0;
  buffer[0] = message_len >> 16;
  buffer[1] = (message_len << 16) >> 16;
  for (i = 2; i < buffer_size; i++) {
    phase += change;
    buffer[i] = (int)(amplitude * sin(phase));
    if (message_len > i - 2) {
      unsigned char c = message[i - 2];
      unsigned short b = buffer[i];
      for (int k = 0; k < 8; k++) {
        short mask = 1 << k;
        short masked_c = c & mask;
        short bit = masked_c >> k;
        if (bit) {
          b |= mask;
        } else {
          b &= ~mask;
        }
      }
      buffer[i] = b;
    }
  }
  write_wav(output_file_name, buffer_size, buffer, (44100));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1214 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1594 <main+0x3c4>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1379 <main+0x1a9>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe0e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1318 <main+0x148>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdeb(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    128e <main+0xbe>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1594 <main+0x3c4>
mov    -0x38(%rbp),%rdi
mov    0x2d4f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x7ffffffe,-0x14(%rbp)
jle    1313 <main+0x143>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
jmp    1366 <main+0x196>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd6b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1361 <main+0x191>
mov    $0x9,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    1366 <main+0x196>
jmp    136b <main+0x19b>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    121b <main+0x4b>
movl   $0xac46,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    -0x14(%rbp),%eax
jge    13a4 <main+0x1d4>
mov    -0x44(%rbp),%eax
add    $0xac44,%eax
mov    %eax,-0x44(%rbp)
jmp    1380 <main+0x1b0>
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x50(%rbp)
lea    0xf(%rcx,%rcx,1),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x88(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x58(%rbp)
movss  0xc43(%rip),%xmm0
movss  %xmm0,-0x64(%rbp)
movss  0xc32(%rip),%xmm0
movss  %xmm0,-0x68(%rbp)
movss  0xc21(%rip),%xmm0
mulss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc08(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xbf4(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x6c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x70(%rbp)
mov    -0x14(%rbp),%ecx
sar    $0x10,%ecx
mov    %cx,(%rax)
mov    -0x14(%rbp),%ecx
shl    $0x10,%ecx
sar    $0x10,%ecx
mov    %cx,0x2(%rax)
movl   $0x2,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    156e <main+0x39e>
movss  -0x6c(%rbp),%xmm0
addss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x70(%rbp)
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
movss  -0x70(%rbp),%xmm0
call   10a0 <sin@plt>
mov    -0x88(%rbp),%rax
movaps %xmm0,%xmm1
movss  -0x8c(%rbp),%xmm0
ff
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
mov    %cx,%dx
movslq -0x5c(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x14(%rbp),%eax
mov    -0x5c(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jle    155b <main+0x38b>
mov    -0x88(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x5c(%rbp),%edx
sub    $0x2,%edx
movslq %edx,%rdx
mov    (%rcx,%rdx,1),%cl
mov    %cl,-0x71(%rbp)
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,2),%ax
mov    %ax,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x8,-0x78(%rbp)
jge    1548 <main+0x378>
mov    -0x78(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %ax,-0x7a(%rbp)
movzbl -0x71(%rbp),%eax
movswl -0x7a(%rbp),%ecx
and    %ecx,%eax
mov    %ax,-0x7c(%rbp)
movswl -0x7c(%rbp),%eax
mov    -0x78(%rbp),%ecx
sar    %cl,%eax
mov    %ax,-0x7e(%rbp)
cmpw   $0x0,-0x7e(%rbp)
je     1524 <main+0x354>
movswl -0x7a(%rbp),%ecx
movzwl -0x74(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x74(%rbp)
jmp    1535 <main+0x365>
movswl -0x7a(%rbp),%ecx
xor    $0xffffffff,%ecx
movzwl -0x74(%rbp),%eax
and    %ecx,%eax
mov    %ax,-0x74(%rbp)
jmp    153a <main+0x36a>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    14d3 <main+0x303>
mov    -0x88(%rbp),%rax
mov    -0x74(%rbp),%dx
movslq -0x5c(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
jmp    1560 <main+0x390>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    143e <main+0x26e>
mov    -0x88(%rbp),%rdx
mov    -0x28(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    $0xac44,%ecx
call   10b0 <write_wav@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
cmp    $0x5,%edi
jne    130b <main+0x12b>
xor    %r12d,%r12d
jmp    121e <main+0x3e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
cmp    $0x5,%r12
je     1322 <main+0x142>
mov    0x0(%r13,%r12,8),%rbx
mov    %rbx,%rdi
lea    0xe07(%rip),%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1280 <main+0xa0>
mov    %rbx,%rdi
lea    0xdf9(%rip),%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
jne    1210 <main+0x30>
mov    $0x9,%edi
call   10d0 <malloc@plt>
mov    %rax,%r15
mov    0x8(%r13,%r12,8),%rsi
add    $0x1,%r12
mov    %rax,%rdi
call   1030 <strcpy@plt>
cmp    $0x5,%r12
jne    121e <main+0x3e>
jmp    1322 <main+0x142>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%r13,%r12,8),%rdi
lea    0xdab(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1424 <main+0x244>
mov    %rax,%rbx
mov    0x2d44(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    %rbx,%rdi
call   10a0 <ftell@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1080 <rewind@plt>
lea    0x1(%r14),%edi
call   10d0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fread@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
cmp    $0x7fffffff,%r14d
jne    1210 <main+0x30>
lea    0xd3d(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    0x0(%r13),%rsi
lea    0xcf2(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1430 <main+0x250>
mov    %r15,-0x40(%rbp)
mov    $0x2,%r15d
nopl   0x0(%rax)
add    $0xac44,%r15
mov    %r15d,%eax
shr    $0x3,%eax
cmp    %r14d,%eax
jl     1330 <main+0x150>
mov    %rsp,-0x38(%rbp)
mov    %rsp,%rax
lea    (%r15,%r15,1),%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rax,%r12
sub    %rcx,%r12
mov    %r12,%rsp
neg    %rcx
movslq %r14d,%r13
ror    $0x10,%r14d
mov    %r14d,(%rax,%rcx,1)
lea    -0x2(%r15),%r14
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    138f <main+0x1af>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
movss  -0x2c(%rbp),%xmm0
je     140a <main+0x22a>
addss  0xc69(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
call   10b0 <sin@plt>
mulss  0xc5b(%rip),%xmm0
cvttss2si %xmm0,%ecx
mov    %cx,0x4(%r12,%rbx,2)
cmp    %r13,%rbx
jge    1380 <main+0x1a0>
mov    -0x48(%rbp),%rax
movzbl (%rax,%rbx,1),%edx
mov    %edx,%eax
and    $0x1,%eax
and    $0xffffff00,%ecx
or     %eax,%ecx
mov    %edx,%eax
and    $0x2,%eax
or     %ecx,%eax
mov    %edx,%ecx
and    $0x4,%ecx
or     %eax,%ecx
mov    %edx,%edi
and    $0x10,%edi
mov    %edx,%esi
and    $0x20,%esi
mov    %edx,%r8d
and    $0x40,%r8d
mov    %edx,%eax
and    $0x8,%eax
or     %ecx,%eax
or     %edi,%eax
or     %esi,%eax
and    $0xffffff80,%edx
or     %r8d,%edx
or     %eax,%edx
mov    %dx,0x4(%r12,%rbx,2)
jmp    1380 <main+0x1a0>
mov    -0x40(%rbp),%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    $0xac44,%ecx
call   10c0 <write_wav@plt>
mov    -0x38(%rbp),%rsp
jmp    1430 <main+0x250>
lea    0xc3f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"usage: %s -i <input file> -o <output file>\0A\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"error opening input file\0A\00"
@SEEK_END = global i32 0
@.str.4 = [47 x i8] c"error maximum message length 2147483646 bytes\0A\00"
@.str.5 = [3 x i8] c"-o\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca i8
%22 = alloca i16
%23 = alloca i32
%24 = alloca i16
%25 = alloca i16
%26 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 5
br i1 %28, label %29, label %34
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %32)
store i32 0, i32* %3
br label %222
34: ; preds = %2
store i32 0, i32* %9
br label %35
35: ; preds = %105, %34
%36 = load i32, i32* %9
%37 = load i32, i32* %4
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %108
39: ; preds = %35
%40 = load i8**, i8*** %5
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %85, label %47
47: ; preds = %39
%48 = load i8**, i8*** %5
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %48, i64 %51
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %54, i32** %10
%55 = load i32*, i32** %10
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %59
57: ; preds = %47
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %222
59: ; preds = %47
%60 = load i32*, i32** %10
%61 = load i32, i32* @SEEK_END
%62 = call i32 @fseek(i32* %60, i32 0, i32 %61)
%63 = load i32*, i32** %10
%64 = call i64 @ftell(i32* %63)
store i64 %64, i64* %11
%65 = load i64, i64* %11
%66 = trunc i64 %65 to i32
store i32 %66, i32* %6
%67 = load i32*, i32** %10
%68 = call i32 @rewind(i32* %67)
%69 = load i64, i64* %11
%70 = add nsw i64 %69, 1
%71 = trunc i64 %70 to i32
%72 = call i8* @malloc(i32 %71)
store i8* %72, i8** %7
%73 = load i8*, i8** %7
%74 = load i64, i64* %11
%75 = load i32*, i32** %10
%76 = call i32 @fread(i8* %73, i32 1, i64 %74, i32* %75)
%77 = load i32*, i32** %10
%78 = call i32 @fclose(i32* %77)
%79 = load i32, i32* %6
%80 = icmp sgt i32 %79, 2147483646
br i1 %80, label %81, label %84
81: ; preds = %59
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%83 = call i32 @exit(i32 0)
unreachable
84: ; preds = %59
br label %104
85: ; preds = %39
%86 = load i8**, i8*** %5
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8*, i8** %86, i64 %88
%90 = load i8*, i8** %89
%91 = call i32 @strcmp(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%92 = icmp ne i32 %91, 0
br i1 %92, label %103, label %93
93: ; preds = %85
%94 = call i8* @malloc(i32 9)
store i8* %94, i8** %8
%95 = load i8*, i8** %8
%96 = load i8**, i8*** %5
%97 = load i32, i32* %9
%98 = add nsw i32 %97, 1
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8*, i8** %96, i64 %99
%101 = load i8*, i8** %100
%102 = call i32 @strcpy(i8* %95, i8* %101)
br label %103
103: ; preds = %93, %85
br label %104
104: ; preds = %103, %84
br label %105
105: ; preds = %104
%106 = load i32, i32* %9
%107 = add nsw i32 %106, 1
store i32 %107, i32* %9
br label %35
108: ; preds = %35
store i32 44102, i32* %12
br label %109
109: ; preds = %114, %108
%110 = load i32, i32* %12
%111 = sdiv i32 %110, 8
%112 = load i32, i32* %6
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %117
114: ; preds = %109
%115 = load i32, i32* %12
%116 = add nsw i32 %115, 44100
store i32 %116, i32* %12
br label %109
117: ; preds = %109
%118 = load i32, i32* %12
%119 = zext i32 %118 to i64
%120 = call i8* @llvm.stacksave()
store i8* %120, i8** %13
%121 = alloca i16, i64 %119
store i64 %119, i64* %14
store float 3.200000e+04, float* %17
store float 4.400000e+02, float* %18
%122 = load float, float* %18
%123 = fmul float %122, 2.000000e+00
%124 = fpext float %123 to double
%125 = fmul double %124, 0x400921FB54442EEA
%126 = fdiv double %125, 4.410000e+04
%127 = fptrunc double %126 to float
store float %127, float* %19
store float 0.000000e+00, float* %20
%128 = load i32, i32* %6
%129 = ashr i32 %128, 16
%130 = trunc i32 %129 to i16
%131 = getelementptr inbounds i16, i16* %121, i64 0
store i16 %130, i16* %131
%132 = load i32, i32* %6
%133 = shl i32 %132, 16
%134 = ashr i32 %133, 16
%135 = trunc i32 %134 to i16
%136 = getelementptr inbounds i16, i16* %121, i64 1
store i16 %135, i16* %136
store i32 2, i32* %15
br label %137
137: ; preds = %214, %117
%138 = load i32, i32* %15
%139 = load i32, i32* %12
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %217
141: ; preds = %137
%142 = load float, float* %19
%143 = load float, float* %20
%144 = fadd float %143, %142
store float %144, float* %20
%145 = load float, float* %17
%146 = load float, float* %20
%147 = call float @sin(float %146)
%148 = fmul float %145, %147
%149 = fptosi float %148 to i32
%150 = trunc i32 %149 to i16
%151 = load i32, i32* %15
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i16, i16* %121, i64 %152
store i16 %150, i16* %153
%154 = load i32, i32* %6
%155 = load i32, i32* %15
%156 = sub nsw i32 %155, 2
%157 = icmp sgt i32 %154, %156
br i1 %157, label %158, label %213
158: ; preds = %141
%159 = load i8*, i8** %7
%160 = load i32, i32* %15
%161 = sub nsw i32 %160, 2
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %159, i64 %162
%164 = load i8, i8* %163
store i8 %164, i8* %21
%165 = load i32, i32* %15
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i16, i16* %121, i64 %166
%168 = load i16, i16* %167
store i16 %168, i16* %22
store i32 0, i32* %23
br label %169
169: ; preds = %205, %158
%170 = load i32, i32* %23
%171 = icmp slt i32 %170, 8
br i1 %171, label %172, label %208
172: ; preds = %169
%173 = load i32, i32* %23
%174 = shl i32 1, %173
%175 = trunc i32 %174 to i16
store i16 %175, i16* %24
%176 = load i8, i8* %21
%177 = zext i8 %176 to i32
%178 = load i16, i16* %24
%179 = sext i16 %178 to i32
%180 = and i32 %177, %179
%181 = trunc i32 %180 to i16
store i16 %181, i16* %25
%182 = load i16, i16* %25
%183 = sext i16 %182 to i32
%184 = load i32, i32* %23
%185 = ashr i32 %183, %184
%186 = trunc i32 %185 to i16
store i16 %186, i16* %26
%187 = load i16, i16* %26
%188 = icmp ne i16 %187, 0
br i1 %188, label %189, label %196
189: ; preds = %172
%190 = load i16, i16* %24
%191 = sext i16 %190 to i32
%192 = load i16, i16* %22
%193 = zext i16 %192 to i32
%194 = or i32 %193, %191
%195 = trunc i32 %194 to i16
store i16 %195, i16* %22
br label %204
196: ; preds = %172
%197 = load i16, i16* %24
%198 = sext i16 %197 to i32
%199 = xor i32 %198, -1
%200 = load i16, i16* %22
%201 = zext i16 %200 to i32
%202 = and i32 %201, %199
%203 = trunc i32 %202 to i16
store i16 %203, i16* %22
br label %204
204: ; preds = %196, %189
br label %205
205: ; preds = %204
%206 = load i32, i32* %23
%207 = add nsw i32 %206, 1
store i32 %207, i32* %23
br label %169
208: ; preds = %169
%209 = load i16, i16* %22
%210 = load i32, i32* %15
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds i16, i16* %121, i64 %211
store i16 %209, i16* %212
br label %213
213: ; preds = %208, %141
br label %214
214: ; preds = %213
%215 = load i32, i32* %15
%216 = add nsw i32 %215, 1
store i32 %216, i32* %15
br label %137
217: ; preds = %137
%218 = load i8*, i8** %8
%219 = load i32, i32* %12
%220 = call i32 @write_wav(i8* %218, i32 %219, i16* %121, i32 44100)
store i32 0, i32* %3
%221 = load i8*, i8** %13
br label %222
222: ; preds = %217, %57, %29
%223 = load i32, i32* %3
ret i32 %223
}

LLVM IR (-O2):
@.str = [44 x i8] c"usage: %s -i <input file> -o <output file>\0A\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.5 = [3 x i8] c"-o\00"
@str = [46 x i8] c"error maximum message length 2147483646 bytes\00"
@str.6 = [25 x i8] c"error opening input file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %113
7: ; preds = %2, %49
%8 = phi i64 [ %50, %49 ], [ 0, %2 ]
%9 = phi i32 [ %53, %49 ], [ undef, %2 ]
%10 = phi i8* [ %52, %49 ], [ undef, %2 ]
%11 = phi i8* [ %51, %49 ], [ undef, %2 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %8
%13 = load i8*, i8** %12
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %38
16: ; preds = %7
%17 = add nuw nsw i64 %8, 1
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %113
24: ; preds = %16
%25 = load i32, i32* @SEEK_END
%26 = tail call i32 @fseek(i32* %20, i32 0, i32 %25)
%27 = tail call i64 @ftell(i32* %20)
%28 = trunc i64 %27 to i32
%29 = tail call i32 @rewind(i32* %20)
%30 = add i32 %28, 1
%31 = tail call i8* @malloc(i32 %30)
%32 = tail call i32 @fread(i8* %31, i32 1, i64 %27, i32* %20)
%33 = tail call i32 @fclose(i32* %20)
%34 = icmp eq i32 %28, 2147483647
br i1 %34, label %35, label %49
35: ; preds = %24
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%37 = tail call i32 @exit(i32 0)
unreachable
38: ; preds = %7
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = add nuw nsw i64 %8, 1
br label %49
43: ; preds = %38
%44 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%45 = add nuw nsw i64 %8, 1
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = tail call i32 @strcpy(i8* %44, i8* %47)
br label %49
49: ; preds = %41, %24, %43
%50 = phi i64 [ %42, %41 ], [ %17, %24 ], [ %45, %43 ]
%51 = phi i8* [ %11, %41 ], [ %11, %24 ], [ %44, %43 ]
%52 = phi i8* [ %10, %41 ], [ %31, %24 ], [ %10, %43 ]
%53 = phi i32 [ %9, %41 ], [ %28, %24 ], [ %9, %43 ]
%54 = icmp eq i64 %50, 5
br i1 %54, label %55, label %7
55: ; preds = %49, %55
%56 = phi i32 [ %59, %55 ], [ 44102, %49 ]
%57 = lshr i32 %56, 3
%58 = icmp slt i32 %57, %53
%59 = add nuw nsw i32 %56, 44100
br i1 %58, label %55, label %60
60: ; preds = %55
%61 = zext i32 %56 to i64
%62 = tail call i8* @llvm.stacksave()
%63 = alloca i16, i64 %61
%64 = lshr i32 %53, 16
%65 = trunc i32 %64 to i16
store i16 %65, i16* %63
%66 = trunc i32 %53 to i16
%67 = getelementptr inbounds i16, i16* %63, i64 1
store i16 %66, i16* %67
%68 = sext i32 %53 to i64
br label %69
69: ; preds = %60, %108
%70 = phi i64 [ 2, %60 ], [ %109, %108 ]
%71 = phi float [ 0.000000e+00, %60 ], [ %72, %108 ]
%72 = fadd float %71, 0x3FB00C6940000000
%73 = tail call float @sin(float %72)
%74 = fmul float %73, 3.200000e+04
%75 = fptosi float %74 to i32
%76 = trunc i32 %75 to i16
%77 = getelementptr inbounds i16, i16* %63, i64 %70
store i16 %76, i16* %77
%78 = add nsw i64 %70, -2
%79 = icmp slt i64 %78, %68
br i1 %79, label %80, label %108
80: ; preds = %69
%81 = getelementptr inbounds i8, i8* %52, i64 %78
%82 = load i8, i8* %81
%83 = and i8 %82, 1
%84 = and i16 %76, -256
%85 = zext i8 %83 to i16
%86 = or i16 %84, %85
%87 = and i8 %82, 2
%88 = zext i8 %87 to i16
%89 = or i16 %86, %88
%90 = and i8 %82, 4
%91 = zext i8 %90 to i16
%92 = or i16 %89, %91
%93 = and i8 %82, 16
%94 = zext i8 %93 to i16
%95 = and i8 %82, 32
%96 = zext i8 %95 to i16
%97 = and i8 %82, 64
%98 = zext i8 %97 to i16
%99 = and i8 %82, 8
%100 = zext i8 %99 to i16
%101 = or i16 %92, %100
%102 = or i16 %101, %94
%103 = or i16 %102, %96
%104 = or i16 %103, %98
%105 = and i8 %82, -128
%106 = zext i8 %105 to i16
%107 = or i16 %104, %106
store i16 %107, i16* %77
br label %108
108: ; preds = %69, %80
%109 = add nuw nsw i64 %70, 1
%110 = icmp eq i64 %109, %61
br i1 %110, label %111, label %69
111: ; preds = %108
%112 = call i32 @write_wav(i8* %51, i32 %56, i16* %63, i32 44100)
br label %113
113: ; preds = %22, %111, %4
ret i32 0
}