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

/* Variables and functions */
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int read_int16(int /*<<< orphan*/ *);
int read_int32(int /*<<< orphan*/ *);
int /*<<< orphan*/ write_int16(int /*<<< orphan*/ *, int);
uint32_t add_file(FILE *out, FILE *in) {
  char chunk_name[5];
  int chunk_size;
  char format[5];
  int n;
  int extra_len = 0;
  int16_t sample;
  int amp_min = 32768;
  int amp_max = -32768;
  int sample_min = 4096;
  int sample_max = 0;
  chunk_name[4] = 0;
  format[4] = 0;
  printf("---------------------------------\n");
  for (n = 0; n < 4; n++) {
    chunk_name[n] = getc(in);
  }
  chunk_size = read_int32(in);
  for (n = 0; n < 4; n++) {
    format[n] = getc(in);
  }
  printf("%s\n%d\n%s\n\n", chunk_name, chunk_size, format);
  for (n = 0; n < 4; n++) {
    chunk_name[n] = getc(in);
  }
  chunk_size = read_int32(in);
  printf("%s\n%d\n\n", chunk_name, chunk_size);
  printf("   Audio Format: %d\n", read_int16(in));
  printf("   Num channels: %d\n", read_int16(in));
  printf("    Sample Rate: %d\n", read_int32(in));
  printf("      Byte Rate: %d\n", read_int32(in));
  printf("    Block Align: %d\n", read_int16(in));
  printf("Bits Per Sample: %d\n", read_int16(in));
  for (n = 0; n < 4; n++) {
    chunk_name[n] = getc(in);
  }
  chunk_size = read_int32(in);
  printf("%s\n%d\n\n", chunk_name, chunk_size);
  for (n = 0; n < chunk_size; n = n + 2) {
    sample = read_int16(in);
    int s32 = sample;
    if (s32 < amp_min) {
      amp_min = s32;
    }
    if (s32 > amp_max) {
      amp_max = s32;
    }
    s32 += 32768;
    uint32_t us32 = s32;
    us32 = us32 >> 4;
    if (us32 < sample_min) {
      sample_min = us32;
    }
    if (us32 > sample_max) {
      sample_max = us32;
    }
    us32 = us32 | 0x3000;
    write_int16(out, us32);
    write_int16(out, us32);
  }
  write_int16(out, 0x3800);
  write_int16(out, 0x0000);
  printf("amp_min=%d\n", amp_min);
  printf("amp_max=%d\n", amp_max);
  printf("sample_min=%d\n", sample_min);
  printf("sample_max=%d\n", sample_max);
  return chunk_size + extra_len;
}


x86 assembly (clang, -O0):
<add_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x8000,-0x34(%rbp)
movl   $0xffff8000,-0x38(%rbp)
movl   $0x1000,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x1d(%rbp)
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    11cb <add_file+0x7b>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x15(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a0 <add_file+0x50>
mov    -0x10(%rbp),%rdi
call   1040 <read_int32@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1209 <add_file+0xb9>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x21(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11de <add_file+0x8e>
lea    -0x15(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x21(%rbp),%rcx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1254 <add_file+0x104>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x15(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1229 <add_file+0xd9>
mov    -0x10(%rbp),%rdi
call   1040 <read_int32@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x15(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <read_int16@plt>
mov    %eax,%esi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <read_int16@plt>
mov    %eax,%esi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <read_int32@plt>
mov    %eax,%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <read_int32@plt>
mov    %eax,%esi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <read_int16@plt>
mov    %eax,%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <read_int16@plt>
mov    %eax,%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    133d <add_file+0x1ed>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x15(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1312 <add_file+0x1c2>
mov    -0x10(%rbp),%rdi
call   1040 <read_int32@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x15(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1416 <add_file+0x2c6>
mov    -0x10(%rbp),%rdi
call   1060 <read_int16@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1395 <add_file+0x245>
mov    -0x44(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x38(%rbp),%eax
jle    13a7 <add_file+0x257>
mov    -0x44(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x44(%rbp),%eax
add    $0x8000,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    13d3 <add_file+0x283>
mov    -0x48(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x40(%rbp),%eax
jle    13e5 <add_file+0x295>
mov    -0x48(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x48(%rbp),%eax
or     $0x3000,%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1050 <write_int16@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1050 <write_int16@plt>
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    1365 <add_file+0x215>
mov    -0x8(%rbp),%rdi
mov    $0x3800,%esi
call   1050 <write_int16@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <write_int16@plt>
mov    -0x34(%rbp),%esi
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xc71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xc6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbp
mov    %rdi,%r12
movb   $0x0,0x7(%rsp)
movb   $0x0,0x13(%rsp)
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x3(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x4(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x5(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x6(%rsp)
mov    %rbp,%rdi
call   1050 <read_int32@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0xf(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x10(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x11(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x12(%rsp)
lea    0xe05(%rip),%rdi
lea    0x3(%rsp),%r14
lea    0xf(%rsp),%rcx
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x3(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x4(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x5(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x6(%rsp)
mov    %rbp,%rdi
call   1050 <read_int32@plt>
lea    0xdbb(%rip),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1070 <read_int16@plt>
lea    0xda5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1070 <read_int16@plt>
lea    0xda2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1050 <read_int32@plt>
lea    0xd9f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1050 <read_int32@plt>
lea    0xd9c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1070 <read_int16@plt>
lea    0xd99(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1070 <read_int16@plt>
lea    0xd96(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x3(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x4(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x5(%rsp)
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    %al,0x6(%rsp)
mov    %rbp,%rdi
call   1050 <read_int32@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
test   %ebx,%ebx
mov    %ebx,0x14(%rsp)
mov    %r12,0x18(%rsp)
jle    13d1 <add_file+0x271>
mov    %rbp,0x20(%rsp)
mov    $0x8000,%r14d
mov    $0xffff8000,%ebp
movl   $0x1000,0x8(%rsp)
xor    %ebx,%ebx
xor    %r13d,%r13d
mov    0x18(%rsp),%r15
nopl   (%rax)
mov    0x20(%rsp),%rdi
call   1070 <read_int16@plt>
cmp    %r14d,%eax
cmovl  %eax,%r14d
cmp    %ebp,%eax
cmovg  %eax,%ebp
lea    0x8000(%rax),%r12d
sar    $0x4,%r12d
mov    0x8(%rsp),%eax
cmp    %eax,%r12d
cmovl  %r12d,%eax
mov    %eax,0x8(%rsp)
cmp    %ebx,%r12d
cmovg  %r12d,%ebx
or     $0x3000,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
call   1060 <write_int16@plt>
mov    %r15,%rdi
mov    %r12d,%esi
call   1060 <write_int16@plt>
add    $0x2,%r13d
cmp    0x14(%rsp),%r13d
jl     1370 <add_file+0x210>
jmp    13e6 <add_file+0x286>
movl   $0x1000,0x8(%rsp)
mov    $0xffff8000,%ebp
mov    $0x8000,%r14d
xor    %ebx,%ebx
mov    0x18(%rsp),%r15
mov    %r15,%rdi
mov    $0x3800,%esi
call   1060 <write_int16@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <write_int16@plt>
lea    0xc88(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc83(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc7f(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc7c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"---------------------------------\0A\00"
@.str.1 = [11 x i8] c"%s\0A%d\0A%s\0A\0A\00"
@.str.2 = [8 x i8] c"%s\0A%d\0A\0A\00"
@.str.3 = [21 x i8] c" Audio Format: %d\0A\00"
@.str.4 = [21 x i8] c" Num channels: %d\0A\00"
@.str.5 = [21 x i8] c" Sample Rate: %d\0A\00"
@.str.6 = [21 x i8] c" Byte Rate: %d\0A\00"
@.str.7 = [21 x i8] c" Block Align: %d\0A\00"
@.str.8 = [21 x i8] c"Bits Per Sample: %d\0A\00"
@.str.9 = [12 x i8] c"amp_min=%d\0A\00"
@.str.10 = [12 x i8] c"amp_max=%d\0A\00"
@.str.11 = [15 x i8] c"sample_min=%d\0A\00"
@.str.12 = [15 x i8] c"sample_max=%d\0A\00"
define i32 @add_file(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [5 x i8]
%6 = alloca i32
%7 = alloca [5 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %9
store i32 32768, i32* %11
store i32 -32768, i32* %12
store i32 4096, i32* %13
store i32 0, i32* %14
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 4
store i8 0, i8* %17
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 4
store i8 0, i8* %18
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %20
20: ; preds = %29, %2
%21 = load i32, i32* %8
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32*, i32** %4
%25 = call signext i8 @getc(i32* %24)
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 %27
store i8 %25, i8* %28
br label %29
29: ; preds = %23
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %20
32: ; preds = %20
%33 = load i32*, i32** %4
%34 = call i32 @read_int32(i32* %33)
store i32 %34, i32* %6
store i32 0, i32* %8
br label %35
35: ; preds = %44, %32
%36 = load i32, i32* %8
%37 = icmp slt i32 %36, 4
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = load i32*, i32** %4
%40 = call signext i8 @getc(i32* %39)
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %38
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %35
47: ; preds = %35
%48 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%49 = load i32, i32* %6
%50 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %48, i32 %49, i8* %50)
store i32 0, i32* %8
br label %52
52: ; preds = %61, %47
%53 = load i32, i32* %8
%54 = icmp slt i32 %53, 4
br i1 %54, label %55, label %64
55: ; preds = %52
%56 = load i32*, i32** %4
%57 = call signext i8 @getc(i32* %56)
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 %59
store i8 %57, i8* %60
br label %61
61: ; preds = %55
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %52
64: ; preds = %52
%65 = load i32*, i32** %4
%66 = call i32 @read_int32(i32* %65)
store i32 %66, i32* %6
%67 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%68 = load i32, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %67, i32 %68)
%70 = load i32*, i32** %4
%71 = call i32 @read_int16(i32* %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %71)
%73 = load i32*, i32** %4
%74 = call i32 @read_int16(i32* %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %74)
%76 = load i32*, i32** %4
%77 = call i32 @read_int32(i32* %76)
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %77)
%79 = load i32*, i32** %4
%80 = call i32 @read_int32(i32* %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %80)
%82 = load i32*, i32** %4
%83 = call i32 @read_int16(i32* %82)
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %83)
%85 = load i32*, i32** %4
%86 = call i32 @read_int16(i32* %85)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %86)
store i32 0, i32* %8
br label %88
88: ; preds = %97, %64
%89 = load i32, i32* %8
%90 = icmp slt i32 %89, 4
br i1 %90, label %91, label %100
91: ; preds = %88
%92 = load i32*, i32** %4
%93 = call signext i8 @getc(i32* %92)
%94 = load i32, i32* %8
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 %95
store i8 %93, i8* %96
br label %97
97: ; preds = %91
%98 = load i32, i32* %8
%99 = add nsw i32 %98, 1
store i32 %99, i32* %8
br label %88
100: ; preds = %88
%101 = load i32*, i32** %4
%102 = call i32 @read_int32(i32* %101)
store i32 %102, i32* %6
%103 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%104 = load i32, i32* %6
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %103, i32 %104)
store i32 0, i32* %8
br label %106
106: ; preds = %151, %100
%107 = load i32, i32* %8
%108 = load i32, i32* %6
%109 = icmp slt i32 %107, %108
br i1 %109, label %110, label %154
110: ; preds = %106
%111 = load i32*, i32** %4
%112 = call i32 @read_int16(i32* %111)
store i32 %112, i32* %10
%113 = load i32, i32* %10
store i32 %113, i32* %15
%114 = load i32, i32* %15
%115 = load i32, i32* %11
%116 = icmp slt i32 %114, %115
br i1 %116, label %117, label %119
117: ; preds = %110
%118 = load i32, i32* %15
store i32 %118, i32* %11
br label %119
119: ; preds = %117, %110
%120 = load i32, i32* %15
%121 = load i32, i32* %12
%122 = icmp sgt i32 %120, %121
br i1 %122, label %123, label %125
123: ; preds = %119
%124 = load i32, i32* %15
store i32 %124, i32* %12
br label %125
125: ; preds = %123, %119
%126 = load i32, i32* %15
%127 = add nsw i32 %126, 32768
store i32 %127, i32* %15
%128 = load i32, i32* %15
store i32 %128, i32* %16
%129 = load i32, i32* %16
%130 = ashr i32 %129, 4
store i32 %130, i32* %16
%131 = load i32, i32* %16
%132 = load i32, i32* %13
%133 = icmp slt i32 %131, %132
br i1 %133, label %134, label %136
134: ; preds = %125
%135 = load i32, i32* %16
store i32 %135, i32* %13
br label %136
136: ; preds = %134, %125
%137 = load i32, i32* %16
%138 = load i32, i32* %14
%139 = icmp sgt i32 %137, %138
br i1 %139, label %140, label %142
140: ; preds = %136
%141 = load i32, i32* %16
store i32 %141, i32* %14
br label %142
142: ; preds = %140, %136
%143 = load i32, i32* %16
%144 = or i32 %143, 12288
store i32 %144, i32* %16
%145 = load i32*, i32** %3
%146 = load i32, i32* %16
%147 = call i32 @write_int16(i32* %145, i32 %146)
%148 = load i32*, i32** %3
%149 = load i32, i32* %16
%150 = call i32 @write_int16(i32* %148, i32 %149)
br label %151
151: ; preds = %142
%152 = load i32, i32* %8
%153 = add nsw i32 %152, 2
store i32 %153, i32* %8
br label %106
154: ; preds = %106
%155 = load i32*, i32** %3
%156 = call i32 @write_int16(i32* %155, i32 14336)
%157 = load i32*, i32** %3
%158 = call i32 @write_int16(i32* %157, i32 0)
%159 = load i32, i32* %11
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %159)
%161 = load i32, i32* %12
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %161)
%163 = load i32, i32* %13
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %163)
%165 = load i32, i32* %14
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i32 %165)
%167 = load i32, i32* %6
%168 = load i32, i32* %9
%169 = add nsw i32 %167, %168
ret i32 %169
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"%s\0A%d\0A%s\0A\0A\00"
@.str.2 = [8 x i8] c"%s\0A%d\0A\0A\00"
@.str.3 = [21 x i8] c" Audio Format: %d\0A\00"
@.str.4 = [21 x i8] c" Num channels: %d\0A\00"
@.str.5 = [21 x i8] c" Sample Rate: %d\0A\00"
@.str.6 = [21 x i8] c" Byte Rate: %d\0A\00"
@.str.7 = [21 x i8] c" Block Align: %d\0A\00"
@.str.8 = [21 x i8] c"Bits Per Sample: %d\0A\00"
@.str.9 = [12 x i8] c"amp_min=%d\0A\00"
@.str.10 = [12 x i8] c"amp_max=%d\0A\00"
@.str.11 = [15 x i8] c"sample_min=%d\0A\00"
@.str.12 = [15 x i8] c"sample_max=%d\0A\00"
@str = [34 x i8] c"---------------------------------\00"
define i32 @add_file(i32* %0, i32* %1) {
%3 = alloca [5 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
store i8 0, i8* %7
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 4
store i8 0, i8* %8
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%10 = tail call signext i8 @getc(i32* %1)
store i8 %10, i8* %5
%11 = tail call signext i8 @getc(i32* %1)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 1
store i8 %11, i8* %12
%13 = tail call signext i8 @getc(i32* %1)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
store i8 %13, i8* %14
%15 = tail call signext i8 @getc(i32* %1)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 3
store i8 %15, i8* %16
%17 = tail call i32 @read_int32(i32* %1)
%18 = tail call signext i8 @getc(i32* %1)
store i8 %18, i8* %6
%19 = tail call signext i8 @getc(i32* %1)
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 1
store i8 %19, i8* %20
%21 = tail call signext i8 @getc(i32* %1)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 2
store i8 %21, i8* %22
%23 = tail call signext i8 @getc(i32* %1)
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 3
store i8 %23, i8* %24
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %17, i8* %6)
%26 = call signext i8 @getc(i32* %1)
store i8 %26, i8* %5
%27 = call signext i8 @getc(i32* %1)
store i8 %27, i8* %12
%28 = call signext i8 @getc(i32* %1)
store i8 %28, i8* %14
%29 = call signext i8 @getc(i32* %1)
store i8 %29, i8* %16
%30 = call i32 @read_int32(i32* %1)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %30)
%32 = call i32 @read_int16(i32* %1)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = call i32 @read_int16(i32* %1)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = call i32 @read_int32(i32* %1)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = call i32 @read_int32(i32* %1)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%40 = call i32 @read_int16(i32* %1)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %40)
%42 = call i32 @read_int16(i32* %1)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %42)
%44 = call signext i8 @getc(i32* %1)
store i8 %44, i8* %5
%45 = call signext i8 @getc(i32* %1)
store i8 %45, i8* %12
%46 = call signext i8 @getc(i32* %1)
store i8 %46, i8* %14
%47 = call signext i8 @getc(i32* %1)
store i8 %47, i8* %16
%48 = call i32 @read_int32(i32* %1)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %48)
%50 = icmp sgt i32 %48, 0
br i1 %50, label %51, label %73
51: ; preds = %2, %51
%52 = phi i32 [ %67, %51 ], [ 0, %2 ]
%53 = phi i32 [ %65, %51 ], [ 4096, %2 ]
%54 = phi i32 [ %61, %51 ], [ -32768, %2 ]
%55 = phi i32 [ %59, %51 ], [ 32768, %2 ]
%56 = phi i32 [ %71, %51 ], [ 0, %2 ]
%57 = call i32 @read_int16(i32* %1)
%58 = icmp slt i32 %57, %55
%59 = select i1 %58, i32 %57, i32 %55
%60 = icmp sgt i32 %57, %54
%61 = select i1 %60, i32 %57, i32 %54
%62 = add nsw i32 %57, 32768
%63 = ashr i32 %62, 4
%64 = icmp slt i32 %63, %53
%65 = select i1 %64, i32 %63, i32 %53
%66 = icmp sgt i32 %63, %52
%67 = select i1 %66, i32 %63, i32 %52
%68 = or i32 %63, 12288
%69 = call i32 @write_int16(i32* %0, i32 %68)
%70 = call i32 @write_int16(i32* %0, i32 %68)
%71 = add nuw nsw i32 %56, 2
%72 = icmp slt i32 %71, %48
br i1 %72, label %51, label %73
73: ; preds = %51, %2
%74 = phi i32 [ 32768, %2 ], [ %59, %51 ]
%75 = phi i32 [ -32768, %2 ], [ %61, %51 ]
%76 = phi i32 [ 4096, %2 ], [ %65, %51 ]
%77 = phi i32 [ 0, %2 ], [ %67, %51 ]
%78 = call i32 @write_int16(i32* %0, i32 14336)
%79 = call i32 @write_int16(i32* %0, i32 0)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %74)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %75)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %76)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i32 %77)
ret i32 %48
}