#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 */
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ fbuf;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
scalar_t__ EAGAIN;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
scalar_t__ dup2(int, int);
scalar_t__ errno;
int /*<<< orphan*/ execlp(char *, char *, char *, char const *, char const *,
                          char *, char *, char *, char *, char *, char *,
                          char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memmove(float *, float *, unsigned int);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ process_buffer(float *, unsigned int);
int read(int, short *, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
scalar_t__ stat(char const *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
void input_file(unsigned int sample_rate, unsigned int overlap,
                const char *fname, const char *type) {
  struct stat statbuf;
  int pipedes[2];
  int pid = 0, soxstat;
  int fd;
  int i;
  short buffer[8192];
  float fbuf[16384];
  unsigned int fbuf_cnt = 0;
  short *sp;
  if (!type || !strcmp(type, "raw")) {
    if ((fd = open(fname, O_RDONLY)) < 0) {
      perror("open");
      exit(10);
    }
  } else {
    if (stat(fname, &statbuf)) {
      perror("stat");
      exit(10);
    }
    if (pipe(pipedes)) {
      perror("pipe");
      exit(10);
    }
    if (!(pid = fork())) {
      char srate[8];
      sprintf(srate, "%d", sample_rate);
      close(pipedes[0]);
      close(1);
      if (dup2(pipedes[1], 1) < 0)
        perror("dup2");
      close(pipedes[1]);
      execlp("sox", "sox", "-t", type, fname, "-t", "raw", "-s", "-w", "-r",
             srate, "-", NULL);
      perror("execlp");
      exit(10);
    }
    if (pid < 0) {
      perror("fork");
      exit(10);
    }
    close(pipedes[1]);
    fd = pipedes[0];
  }
  for (;;) {
    i = read(fd, sp = buffer, sizeof(buffer));
    if (i < 0 && errno != EAGAIN) {
      perror("read");
      exit(4);
    }
    if (!i)
      break;
    if (i > 0) {
      for (; i >= sizeof(buffer[0]); i -= sizeof(buffer[0]), sp++)
        fbuf[fbuf_cnt++] = (*sp) * (1.0 / 32768.0);
      if (i)
        fprintf(stderr, "warning: noninteger number of samples read\n");
      if (fbuf_cnt > overlap) {
        process_buffer(fbuf, fbuf_cnt - overlap);
        memmove(fbuf, fbuf + fbuf_cnt - overlap, overlap * sizeof(fbuf[0]));
        fbuf_cnt = overlap;
      }
    }
  }
  close(fd);
  waitpid(pid, &soxstat, 0);
}


x86 assembly (clang, -O0):
<input_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x14088,%rsp
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x14054(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1253 <input_file+0x53>
mov    -0x30(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    128c <input_file+0x8c>
mov    -0x28(%rbp),%rdi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jge    1287 <input_file+0x87>
lea    0xd94(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xa,%edi
call   1100 <exit@plt>
jmp    13ff <input_file+0x1ff>
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
je     12b9 <input_file+0xb9>
lea    0xd67(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xa,%edi
call   1100 <exit@plt>
lea    -0x40(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
je     12e2 <input_file+0xe2>
lea    0xd43(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xa,%edi
call   1100 <exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jne    13d1 <input_file+0x1d1>
lea    -0x14068(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd15(%rip),%rsi
call   10f0 <sprintf@plt>
mov    -0x40(%rbp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
cmp    $0x0,%rax
jge    1340 <input_file+0x140>
lea    0xce3(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x3c(%rbp),%edi
call   1040 <close@plt>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    -0x14068(%rbp),%r10
lea    0xcc5(%rip),%rsi
lea    0xcc2(%rip),%r9
lea    0xc9c(%rip),%r15
lea    0xcb7(%rip),%r14
lea    0xcb3(%rip),%rbx
lea    0xcaf(%rip),%r11
lea    0xcab(%rip),%rax
xor    %edx,%edx
mov    %rsi,%rdi
mov    %r9,%rdx
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
movq   $0x0,0x30(%rsp)
call   1110 <execlp@plt>
lea    0xc73(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xa,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x44(%rbp)
jge    13f1 <input_file+0x1f1>
lea    0xc5a(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xa,%edi
call   1100 <exit@plt>
mov    -0x3c(%rbp),%edi
call   1040 <close@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1404 <input_file+0x204>
mov    -0x4c(%rbp),%edi
lea    -0x4050(%rbp),%rsi
mov    %rsi,-0x14060(%rbp)
mov    $0x4000,%edx
call   1060 <read@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    145c <input_file+0x25c>
mov    0x2b9d(%rip),%rax
mov    (%rax),%rax
mov    0x2b83(%rip),%rcx
cmp    (%rcx),%rax
je     145c <input_file+0x25c>
lea    0xbf4(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x4,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x50(%rbp)
jne    146b <input_file+0x26b>
jmp    1574 <input_file+0x374>
cmpl   $0x0,-0x50(%rbp)
jle    156f <input_file+0x36f>
jmp    147a <input_file+0x27a>
movslq -0x50(%rbp),%rax
cmp    $0x2,%rax
jb     14e4 <input_file+0x2e4>
mov    -0x14060(%rbp),%rax
movswl (%rax),%eax
cvtsi2sd %eax,%xmm0
movsd  0xb62(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x14054(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14054(%rbp)
mov    %eax,%eax
movss  %xmm0,-0x14050(%rbp,%rax,4)
fe ff
movslq -0x50(%rbp),%rax
sub    $0x2,%rax
mov    %eax,-0x50(%rbp)
mov    -0x14060(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x14060(%rbp)
jmp    147a <input_file+0x27a>
cmpl   $0x0,-0x50(%rbp)
je     1503 <input_file+0x303>
mov    0x2ae3(%rip),%rax
mov    (%rax),%edi
lea    0xb48(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x14054(%rbp),%eax
cmp    -0x20(%rbp),%eax
jbe    156a <input_file+0x36a>
lea    -0x14050(%rbp),%rdi
mov    -0x14054(%rbp),%esi
sub    -0x20(%rbp),%esi
call   10a0 <process_buffer@plt>
lea    -0x14050(%rbp),%rdi
lea    -0x14050(%rbp),%rsi
mov    -0x14054(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edx
call   10b0 <memmove@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14054(%rbp)
jmp    156f <input_file+0x36f>
jmp    1404 <input_file+0x204>
mov    -0x4c(%rbp),%edi
call   1040 <close@plt>
mov    -0x44(%rbp),%edi
lea    -0x48(%rbp),%rsi
xor    %edx,%edx
call   10c0 <waitpid@plt>
add    $0x14088,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x14038,%rsp
mov    %rdx,%rbp
mov    %esi,%r13d
test   %rcx,%rcx
je     1289 <input_file+0x89>
mov    %rcx,%rbx
mov    %edi,%r12d
lea    0xdef(%rip),%r14
mov    %rcx,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1289 <input_file+0x89>
lea    0x28(%rsp),%rsi
mov    %rbp,%rdi
call   1090 <stat@plt>
test   %rax,%rax
jne    155d <input_file+0x35d>
lea    0xc(%rsp),%rdi
call   1050 <pipe@plt>
test   %rax,%rax
jne    1569 <input_file+0x369>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     1575 <input_file+0x375>
js     1623 <input_file+0x423>
mov    %eax,0x8(%rsp)
mov    0x10(%rsp),%edi
call   1040 <close@plt>
mov    0xc(%rsp),%ebp
jmp    12ac <input_file+0xac>
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10d0 <open@plt>
test   %eax,%eax
js     1551 <input_file+0x351>
mov    %eax,%ebp
movl   $0x0,0x8(%rsp)
mov    %r13d,%eax
neg    %rax
mov    %rax,0x20(%rsp)
lea    0x0(,%r13,4),%eax
mov    %eax,0x14(%rsp)
xor    %r12d,%r12d
lea    0x30(%rsp),%rbx
mov    0x2cfe(%rip),%r15
mov    0x2ce7(%rip),%r14
mov    %r13,0x18(%rsp)
jmp    12ec <input_file+0xec>
mov    (%r15),%rax
cmp    (%r14),%rax
jne    153b <input_file+0x33b>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x4000,%edx
call   1060 <read@plt>
test   %eax,%eax
js     12e0 <input_file+0xe0>
cmp    $0x1,%eax
je     14b2 <input_file+0x2b2>
test   %eax,%eax
je     1512 <input_file+0x312>
xor    %r10d,%r10d
cmp    $0x2,%eax
setne  %r10b
not    %r10d
add    %eax,%r10d
cmp    $0x6,%r10d
movsd  0xce4(%rip),%xmm2
jae    1336 <input_file+0x136>
mov    %rbx,%rcx
jmp    1480 <input_file+0x280>
xor    %ecx,%ecx
cmp    $0x2,%eax
setne  %cl
not    %ecx
add    %eax,%ecx
shr    %ecx
add    %r12d,%ecx
movapd 0xcb1(%rip),%xmm3
jae    1359 <input_file+0x159>
mov    %rbx,%rcx
jmp    1480 <input_file+0x280>
shr    %r10d
add    $0x1,%r10d
mov    %r10d,%r8d
and    $0xfffffffc,%r8d
lea    -0x4(%r8),%rcx
mov    %rcx,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rcx,%rcx
je     1419 <input_file+0x219>
mov    %r9,%rsi
and    $0xfffffffffffffffe,%rsi
lea    0x4(%r12),%r11d
mov    %r12d,%ecx
xor    %edi,%edi
movq   0x30(%rsp,%rdi,2),%xmm0
punpcklwd %xmm0,%xmm0
psrad  $0x10,%xmm0
cvtdq2pd %xmm0,%xmm1
pshufd $0xee,%xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
lea    (%rcx,%rdi,1),%edx
mulpd  %xmm3,%xmm1
cvtpd2ps %xmm1,%xmm1
mulpd  %xmm3,%xmm0
cvtpd2ps %xmm0,%xmm0
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x4030(%rsp,%rdx,4)
lea    (%r11,%rdi,1),%edx
movq   0x38(%rsp,%rdi,2),%xmm0
punpcklwd %xmm0,%xmm0
psrad  $0x10,%xmm0
cvtdq2pd %xmm0,%xmm1
pshufd $0xee,%xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
mulpd  %xmm3,%xmm1
cvtpd2ps %xmm1,%xmm1
cvtpd2ps %xmm0,%xmm0
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x4030(%rsp,%rdx,4)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rsi
jne    1390 <input_file+0x190>
jmp    141b <input_file+0x21b>
xor    %edi,%edi
lea    (%r8,%r8,1),%ecx
test   $0x1,%r9b
je     1462 <input_file+0x262>
movq   0x30(%rsp,%rdi,2),%xmm0
punpcklwd %xmm0,%xmm0
psrad  $0x10,%xmm0
cvtdq2pd %xmm0,%xmm1
lea    (%r12,%rdi,1),%edx
pshufd $0xee,%xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
mulpd  %xmm3,%xmm1
cvtpd2ps %xmm1,%xmm1
cvtpd2ps %xmm0,%xmm0
unpcklpd %xmm0,%xmm1
movupd %xmm1,0x4030(%rsp,%rdx,4)
add    %r8d,%r12d
sub    %ecx,%eax
cmp    %r10,%r8
je     14ae <input_file+0x2ae>
lea    (%rsp,%r8,2),%rcx
add    $0x30,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movswl (%rcx),%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    %r12d,%edx
add    $0x1,%r12d
movss  %xmm0,0x4030(%rsp,%rdx,4)
add    $0xfffffffe,%eax
add    $0x2,%rcx
cmp    $0x1,%eax
ja     1480 <input_file+0x280>
test   %eax,%eax
je     14c7 <input_file+0x2c7>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
lea    0xb94(%rip),%rsi
call   1080 <fprintf@plt>
mov    %r12d,%esi
sub    %r13d,%esi
jbe    12ec <input_file+0xec>
lea    0x4030(%rsp),%r13
mov    %r13,%rdi
call   10a0 <process_buffer@plt>
mov    %r12d,%eax
lea    (%rsp,%rax,4),%rax
add    $0x4030,%rax
mov    0x20(%rsp),%rcx
lea    (%rax,%rcx,4),%rsi
mov    %r13,%rdi
mov    0x18(%rsp),%r13
mov    0x14(%rsp),%edx
call   10b0 <memmove@plt>
mov    %r13d,%r12d
jmp    12ec <input_file+0xec>
mov    %ebp,%edi
call   1040 <close@plt>
lea    0x2c(%rsp),%rsi
mov    0x8(%rsp),%edi
xor    %edx,%edx
call   10c0 <waitpid@plt>
add    $0x14038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb0f(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x4,%edi
call   1100 <exit@plt>
lea    0xac4(%rip),%rdi
jmp    162a <input_file+0x42a>
lea    0xabd(%rip),%rdi
jmp    162a <input_file+0x42a>
lea    0xab6(%rip),%rdi
jmp    162a <input_file+0x42a>
lea    0xaaf(%rip),%rsi
lea    0x4030(%rsp),%r15
mov    %r15,%rdi
mov    %r12d,%edx
call   10f0 <sprintf@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    0x10(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
test   %rax,%rax
jns    15c1 <input_file+0x3c1>
lea    0xa72(%rip),%rdi
call   10e0 <perror@plt>
mov    0x10(%rsp),%edi
call   1040 <close@plt>
sub    $0x8,%rsp
lea    0xa6e(%rip),%rax
lea    0xa64(%rip),%r10
lea    0xa5a(%rip),%r11
lea    0xa50(%rip),%r12
lea    0xa42(%rip),%rdi
lea    0xa3f(%rip),%rdx
mov    %rdi,%rsi
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %rdx,%r9
push   $0x0
push   %rax
push   %r15
push   %r10
push   %r11
push   %r12
push   %r14
call   1110 <execlp@plt>
add    $0x40,%rsp
lea    0xa24(%rip),%rdi
jmp    162a <input_file+0x42a>
lea    0xa22(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xa,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [4 x i8] c"raw\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"stat\00"
@.str.3 = [5 x i8] c"pipe\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [5 x i8] c"dup2\00"
@.str.6 = [4 x i8] c"sox\00"
@.str.7 = [3 x i8] c"-t\00"
@.str.8 = [3 x i8] c"-s\00"
@.str.9 = [3 x i8] c"-w\00"
@.str.10 = [3 x i8] c"-r\00"
@.str.11 = [2 x i8] c"-\00"
@.str.12 = [7 x i8] c"execlp\00"
@.str.13 = [5 x i8] c"fork\00"
@errno = global i64 0
@EAGAIN = global i64 0
@.str.14 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.15 = [44 x i8] c"warning: noninteger number of samples read\0A\00"
define void @input_file(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.stat
%10 = alloca [2 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [8192 x i16]
%16 = alloca [16384 x float]
%17 = alloca i32
%18 = alloca i16*
%19 = alloca [8 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %11
store i32 0, i32* %17
%20 = load i8*, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %4
%23 = load i8*, i8** %8
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %35, label %26
26: ; preds = %22, %4
%27 = load i8*, i8** %7
%28 = load i32, i32* @O_RDONLY
%29 = call i32 @open(i8* %27, i32 %28)
store i32 %29, i32* %13
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 10)
unreachable
34: ; preds = %26
br label %88
35: ; preds = %22
%36 = load i8*, i8** %7
%37 = call i64 @stat(i8* %36, %struct.stat* %9)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 10)
unreachable
42: ; preds = %35
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%44 = call i64 @pipe(i32* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 @exit(i32 10)
unreachable
49: ; preds = %42
%50 = call i32 (...) @fork()
store i32 %50, i32* %11
%51 = icmp ne i32 %50, 0
br i1 %51, label %76, label %52
52: ; preds = %49
%53 = getelementptr inbounds [8 x i8], [8 x i8]* %19, i64 0, i64 0
%54 = load i32, i32* %5
%55 = call i32 @sprintf(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%57 = load i32, i32* %56
%58 = call i32 @close(i32 %57)
%59 = call i32 @close(i32 1)
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%61 = load i32, i32* %60
%62 = call i64 @dup2(i32 %61, i32 1)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %52
%65 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %52
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%68 = load i32, i32* %67
%69 = call i32 @close(i32 %68)
%70 = load i8*, i8** %8
%71 = load i8*, i8** %7
%72 = getelementptr inbounds [8 x i8], [8 x i8]* %19, i64 0, i64 0
%73 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %70, i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32* null)
%74 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%75 = call i32 @exit(i32 10)
unreachable
76: ; preds = %49
%77 = load i32, i32* %11
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%81 = call i32 @exit(i32 10)
unreachable
82: ; preds = %76
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%84 = load i32, i32* %83
%85 = call i32 @close(i32 %84)
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%87 = load i32, i32* %86
store i32 %87, i32* %13
br label %88
88: ; preds = %82, %34
br label %89
89: ; preds = %164, %88
%90 = load i32, i32* %13
%91 = getelementptr inbounds [8192 x i16], [8192 x i16]* %15, i64 0, i64 0
store i16* %91, i16** %18
%92 = call i32 @read(i32 %90, i16* %91, i32 16384)
store i32 %92, i32* %14
%93 = load i32, i32* %14
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %102
95: ; preds = %89
%96 = load i64, i64* @errno
%97 = load i64, i64* @EAGAIN
%98 = icmp ne i64 %96, %97
br i1 %98, label %99, label %102
99: ; preds = %95
%100 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%101 = call i32 @exit(i32 4)
unreachable
102: ; preds = %95, %89
%103 = load i32, i32* %14
%104 = icmp ne i32 %103, 0
br i1 %104, label %106, label %105
105: ; preds = %102
br label %165
106: ; preds = %102
%107 = load i32, i32* %14
%108 = icmp sgt i32 %107, 0
br i1 %108, label %109, label %164
109: ; preds = %106
br label %110
110: ; preds = %125, %109
%111 = load i32, i32* %14
%112 = sext i32 %111 to i64
%113 = icmp uge i64 %112, 2
br i1 %113, label %114, label %132
114: ; preds = %110
%115 = load i16*, i16** %18
%116 = load i16, i16* %115
%117 = sext i16 %116 to i32
%118 = sitofp i32 %117 to double
%119 = fmul double %118, 0x3F00000000000000
%120 = fptrunc double %119 to float
%121 = load i32, i32* %17
%122 = add i32 %121, 1
store i32 %122, i32* %17
%123 = zext i32 %121 to i64
%124 = getelementptr inbounds [16384 x float], [16384 x float]* %16, i64 0, i64 %123
store float %120, float* %124
br label %125
125: ; preds = %114
%126 = load i32, i32* %14
%127 = sext i32 %126 to i64
%128 = sub i64 %127, 2
%129 = trunc i64 %128 to i32
store i32 %129, i32* %14
%130 = load i16*, i16** %18
%131 = getelementptr inbounds i16, i16* %130, i32 1
store i16* %131, i16** %18
br label %110
132: ; preds = %110
%133 = load i32, i32* %14
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %132
%136 = load i32, i32* @stderr
%137 = call i32 @fprintf(i32 %136, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0))
br label %138
138: ; preds = %135, %132
%139 = load i32, i32* %17
%140 = load i32, i32* %6
%141 = icmp ugt i32 %139, %140
br i1 %141, label %142, label %163
142: ; preds = %138
%143 = getelementptr inbounds [16384 x float], [16384 x float]* %16, i64 0, i64 0
%144 = load i32, i32* %17
%145 = load i32, i32* %6
%146 = sub i32 %144, %145
%147 = call i32 @process_buffer(float* %143, i32 %146)
%148 = getelementptr inbounds [16384 x float], [16384 x float]* %16, i64 0, i64 0
%149 = getelementptr inbounds [16384 x float], [16384 x float]* %16, i64 0, i64 0
%150 = load i32, i32* %17
%151 = zext i32 %150 to i64
%152 = getelementptr inbounds float, float* %149, i64 %151
%153 = load i32, i32* %6
%154 = zext i32 %153 to i64
%155 = sub i64 0, %154
%156 = getelementptr inbounds float, float* %152, i64 %155
%157 = load i32, i32* %6
%158 = zext i32 %157 to i64
%159 = mul i64 %158, 4
%160 = trunc i64 %159 to i32
%161 = call i32 @memmove(float* %148, float* %156, i32 %160)
%162 = load i32, i32* %6
store i32 %162, i32* %17
br label %163
163: ; preds = %142, %138
br label %164
164: ; preds = %163, %106
br label %89
165: ; preds = %105
%166 = load i32, i32* %13
%167 = call i32 @close(i32 %166)
%168 = load i32, i32* %11
%169 = call i32 @waitpid(i32 %168, i32* %12, i32 0)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [4 x i8] c"raw\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"stat\00"
@.str.3 = [5 x i8] c"pipe\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [5 x i8] c"dup2\00"
@.str.6 = [4 x i8] c"sox\00"
@.str.7 = [3 x i8] c"-t\00"
@.str.8 = [3 x i8] c"-s\00"
@.str.9 = [3 x i8] c"-w\00"
@.str.10 = [3 x i8] c"-r\00"
@.str.11 = [2 x i8] c"-\00"
@.str.12 = [7 x i8] c"execlp\00"
@.str.13 = [5 x i8] c"fork\00"
@errno = global i64 0
@EAGAIN = global i64 0
@.str.14 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.15 = [44 x i8] c"warning: noninteger number of samples read\0A\00"
define void @input_file(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca %struct.stat
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca [8192 x i16]
%9 = alloca [16384 x float]
%10 = alloca [8 x i8]
%11 = bitcast %struct.stat* %5 to i8*
%12 = bitcast [2 x i32]* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast [8192 x i16]* %8 to i8*
%15 = bitcast [16384 x float]* %9 to i8*
%16 = icmp eq i8* %3, null
br i1 %16, label %20, label %17
17: ; preds = %4
%18 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17, %4
%21 = load i32, i32* @O_RDONLY
%22 = tail call i32 @open(i8* %2, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %71
24: ; preds = %20
%25 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @exit(i32 10)
unreachable
27: ; preds = %17
%28 = call i64 @stat(i8* %2, %struct.stat* %5)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 10)
unreachable
33: ; preds = %27
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%35 = call i64 @pipe(i32* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @exit(i32 10)
unreachable
40: ; preds = %33
%41 = call i32 (...) @fork()
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %61
43: ; preds = %40
%44 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%45 = call i32 @sprintf(i8* %44, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %0)
%46 = load i32, i32* %34
%47 = call i32 @close(i32 %46)
%48 = call i32 @close(i32 1)
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%50 = load i32, i32* %49
%51 = call i64 @dup2(i32 %50, i32 1)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %43
%54 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %43
%56 = load i32, i32* %49
%57 = call i32 @close(i32 %56)
%58 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %3, i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32* null)
%59 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%60 = call i32 @exit(i32 10)
unreachable
61: ; preds = %40
%62 = icmp slt i32 %41, 0
br i1 %62, label %63, label %66
63: ; preds = %61
%64 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%65 = call i32 @exit(i32 10)
unreachable
66: ; preds = %61
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%68 = load i32, i32* %67
%69 = call i32 @close(i32 %68)
%70 = load i32, i32* %34
br label %71
71: ; preds = %20, %66
%72 = phi i32 [ %41, %66 ], [ 0, %20 ]
%73 = phi i32 [ %70, %66 ], [ %22, %20 ]
%74 = getelementptr inbounds [8192 x i16], [8192 x i16]* %8, i64 0, i64 0
%75 = getelementptr inbounds [16384 x float], [16384 x float]* %9, i64 0, i64 0
%76 = zext i32 %1 to i64
%77 = sub nsw i64 0, %76
%78 = shl i32 %1, 2
br label %79
79: ; preds = %206, %71
%80 = phi i32 [ 0, %71 ], [ %207, %206 ]
br label %81
81: ; preds = %79, %84
%82 = call i32 @read(i32 %73, i16* %74, i32 16384)
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %81
%85 = load i64, i64* @errno
%86 = load i64, i64* @EAGAIN
%87 = icmp eq i64 %85, %86
br i1 %87, label %81, label %88
88: ; preds = %84
%89 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%90 = call i32 @exit(i32 4)
unreachable
91: ; preds = %81
switch i32 %82, label %92 [
i32 0, label %208
i32 1, label %192
]
92: ; preds = %91
%93 = add i32 %82, -1
%94 = icmp ne i32 %82, 2
%95 = sext i1 %94 to i32
%96 = add i32 %93, %95
%97 = lshr i32 %96, 1
%98 = add nuw i32 %97, 1
%99 = zext i32 %98 to i64
%100 = icmp ult i32 %96, 6
br i1 %100, label %170, label %101
101: ; preds = %92
%102 = add i32 %82, -1
%103 = icmp ne i32 %82, 2
%104 = sext i1 %103 to i32
%105 = add i32 %102, %104
%106 = lshr i32 %105, 1
%107 = xor i32 %80, -1
%108 = icmp ugt i32 %106, %107
br i1 %108, label %170, label %109
109: ; preds = %101
%110 = and i64 %99, 4294967292
%111 = getelementptr [8192 x i16], [8192 x i16]* %8, i64 0, i64 %110
%112 = trunc i64 %110 to i32
%113 = add i32 %80, %112
%114 = trunc i64 %110 to i32
%115 = mul i32 %114, -2
%116 = add i32 %82, %115
%117 = add nsw i64 %110, -4
%118 = lshr exact i64 %117, 2
%119 = add nuw nsw i64 %118, 1
%120 = and i64 %119, 1
%121 = icmp eq i64 %117, 0
br i1 %121, label %153, label %122
122: ; preds = %109
%123 = and i64 %119, 9223372036854775806
br label %124
124: ; preds = %124, %122
%125 = phi i64 [ 0, %122 ], [ %150, %124 ]
%126 = phi i64 [ 0, %122 ], [ %151, %124 ]
%127 = getelementptr [8192 x i16], [8192 x i16]* %8, i64 0, i64 %125
%128 = trunc i64 %125 to i32
%129 = add i32 %80, %128
%130 = bitcast i16* %127 to <4 x i16>*
%131 = load <4 x i16>, <4 x i16>* %130
%132 = sitofp <4 x i16> %131 to <4 x double>
%133 = fmul <4 x double> %132, <double 0x3F00000000000000, double 0x3F00000000000000, double 0x3F00000000000000, double 0x3F00000000000000>
%134 = fptrunc <4 x double> %133 to <4 x float>
%135 = zext i32 %129 to i64
%136 = getelementptr inbounds [16384 x float], [16384 x float]* %9, i64 0, i64 %135
%137 = bitcast float* %136 to <4 x float>*
store <4 x float> %134, <4 x float>* %137
%138 = or i64 %125, 4
%139 = getelementptr [8192 x i16], [8192 x i16]* %8, i64 0, i64 %138
%140 = trunc i64 %138 to i32
%141 = add i32 %80, %140
%142 = bitcast i16* %139 to <4 x i16>*
%143 = load <4 x i16>, <4 x i16>* %142
%144 = sitofp <4 x i16> %143 to <4 x double>
%145 = fmul <4 x double> %144, <double 0x3F00000000000000, double 0x3F00000000000000, double 0x3F00000000000000, double 0x3F00000000000000>
%146 = fptrunc <4 x double> %145 to <4 x float>
%147 = zext i32 %141 to i64
%148 = getelementptr inbounds [16384 x float], [16384 x float]* %9, i64 0, i64 %147
%149 = bitcast float* %148 to <4 x float>*
store <4 x float> %146, <4 x float>* %149
%150 = add nuw i64 %125, 8
%151 = add i64 %126, 2
%152 = icmp eq i64 %151, %123
br i1 %152, label %153, label %124
153: ; preds = %124, %109
%154 = phi i64 [ 0, %109 ], [ %150, %124 ]
%155 = icmp eq i64 %120, 0
br i1 %155, label %168, label %156
156: ; preds = %153
%157 = getelementptr [8192 x i16], [8192 x i16]* %8, i64 0, i64 %154
%158 = trunc i64 %154 to i32
%159 = add i32 %80, %158
%160 = bitcast i16* %157 to <4 x i16>*
%161 = load <4 x i16>, <4 x i16>* %160
%162 = sitofp <4 x i16> %161 to <4 x double>
%163 = fmul <4 x double> %162, <double 0x3F00000000000000, double 0x3F00000000000000, double 0x3F00000000000000, double 0x3F00000000000000>
%164 = fptrunc <4 x double> %163 to <4 x float>
%165 = zext i32 %159 to i64
%166 = getelementptr inbounds [16384 x float], [16384 x float]* %9, i64 0, i64 %165
%167 = bitcast float* %166 to <4 x float>*
store <4 x float> %164, <4 x float>* %167
br label %168
168: ; preds = %153, %156
%169 = icmp eq i64 %110, %99
br i1 %169, label %188, label %170
170: ; preds = %101, %92, %168
%171 = phi i16* [ %74, %101 ], [ %74, %92 ], [ %111, %168 ]
%172 = phi i32 [ %80, %101 ], [ %80, %92 ], [ %113, %168 ]
%173 = phi i32 [ %82, %101 ], [ %82, %92 ], [ %116, %168 ]
br label %174
174: ; preds = %170, %174
%175 = phi i16* [ %186, %174 ], [ %171, %170 ]
%176 = phi i32 [ %182, %174 ], [ %172, %170 ]
%177 = phi i32 [ %185, %174 ], [ %173, %170 ]
%178 = load i16, i16* %175
%179 = sitofp i16 %178 to double
%180 = fmul double %179, 0x3F00000000000000
%181 = fptrunc double %180 to float
%182 = add i32 %176, 1
%183 = zext i32 %176 to i64
%184 = getelementptr inbounds [16384 x float], [16384 x float]* %9, i64 0, i64 %183
store float %181, float* %184
%185 = add i32 %177, -2
%186 = getelementptr inbounds i16, i16* %175, i64 1
%187 = icmp ugt i32 %185, 1
br i1 %187, label %174, label %188
188: ; preds = %174, %168
%189 = phi i32 [ %113, %168 ], [ %182, %174 ]
%190 = phi i32 [ %116, %168 ], [ %185, %174 ]
%191 = icmp eq i32 %190, 0
br i1 %191, label %196, label %192
192: ; preds = %91, %188
%193 = phi i32 [ %189, %188 ], [ %80, %91 ]
%194 = load i32, i32* @stderr
%195 = call i32 @fprintf(i32 %194, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0))
br label %196
196: ; preds = %192, %188
%197 = phi i32 [ %193, %192 ], [ %189, %188 ]
%198 = icmp ugt i32 %197, %1
br i1 %198, label %199, label %206
199: ; preds = %196
%200 = sub i32 %197, %1
%201 = call i32 @process_buffer(float* %75, i32 %200)
%202 = zext i32 %197 to i64
%203 = getelementptr inbounds [16384 x float], [16384 x float]* %9, i64 0, i64 %202
%204 = getelementptr inbounds float, float* %203, i64 %77
%205 = call i32 @memmove(float* %75, float* %204, i32 %78)
br label %206
206: ; preds = %199, %196
%207 = phi i32 [ %197, %196 ], [ %1, %199 ]
br label %79
208: ; preds = %91
%209 = call i32 @close(i32 %73)
%210 = call i32 @waitpid(i32 %72, i32* %7, i32 0)
ret void
}