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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ play(int, unsigned char *, int);
int setupdsp(unsigned char, unsigned char, unsigned char, unsigned int,
             unsigned char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int dsp;
  unsigned char bigendian = 0, sign = 1, size = 16, channels;
  unsigned int speed;
  char *fname = argv[1];
  unsigned char buffer[1024 * 128];
  FILE *f;
  size_t read;
  if (argc != 5)
    usage(argv[0]);
  if (!strcmp(argv[2], "s8")) {
    size = 8;
    sign = 1;
  } else if (!strcmp(argv[2], "u8")) {
    size = 8;
    sign = 0;
  } else if (!strcmp(argv[2], "sbe16")) {
    sign = 1;
    bigendian = 1;
  } else if (!strcmp(argv[2], "sle16")) {
    sign = 1;
    bigendian = 0;
  } else if (!strcmp(argv[2], "ube16")) {
    sign = 0;
    bigendian = 1;
  } else if (!strcmp(argv[2], "ule16")) {
    sign = 0;
    bigendian = 0;
  } else {
    fprintf(stderr, "unknown format: %s\n", argv[2]);
    usage(argv[0]);
  }
  speed = atoi(argv[3]);
  if ((speed != 8000) && (speed != 11025) && (speed != 12000) &&
      (speed != 16000) && (speed != 22050) && (speed != 24000) &&
      (speed != 32000) && (speed != 44100) && (speed != 48000)) {
    fprintf(stderr, "unknown speed: %d\n", speed);
    usage(argv[0]);
  }
  channels = atoi(argv[4]);
  if (channels > 2) {
    fprintf(stderr, "invalid number of channels: %d\n", atoi(argv[4]));
    usage(argv[0]);
  }
  f = fopen(fname, "rb");
  if (!f) {
    perror("error opening audiofile");
    exit(1);
  }
  if ((dsp = setupdsp(size, sign, bigendian, speed, channels)) < 0) {
    fprintf(stderr, "error setting up dsp\n");
    fclose(f);
    exit(1);
  }
  while ((read = fread(buffer, 1, sizeof(buffer), f))) {
    if (read != sizeof(buffer))
      memset(buffer, 0x00, sizeof(buffer) - read);
    if (play(dsp, buffer, sizeof(buffer)) < 0)
      break;
  }
  fclose(f);
  close(dsp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x15(%rbp)
movb   $0x1,-0x16(%rbp)
movb   $0x10,-0x17(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1217 <main+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdda(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1241 <main+0x71>
movb   $0x8,-0x17(%rbp)
movb   $0x1,-0x16(%rbp)
jmp    1357 <main+0x187>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    126b <main+0x9b>
movb   $0x8,-0x17(%rbp)
movb   $0x0,-0x16(%rbp)
jmp    1352 <main+0x182>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd8c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1295 <main+0xc5>
movb   $0x1,-0x16(%rbp)
movb   $0x1,-0x15(%rbp)
jmp    134d <main+0x17d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd68(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12bf <main+0xef>
movb   $0x1,-0x16(%rbp)
movb   $0x0,-0x15(%rbp)
jmp    1348 <main+0x178>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd44(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12e9 <main+0x119>
movb   $0x0,-0x16(%rbp)
movb   $0x1,-0x15(%rbp)
jmp    1343 <main+0x173>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd20(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1313 <main+0x143>
movb   $0x0,-0x16(%rbp)
movb   $0x0,-0x15(%rbp)
jmp    133e <main+0x16e>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
jmp    1343 <main+0x173>
jmp    1348 <main+0x178>
jmp    134d <main+0x17d>
jmp    1352 <main+0x182>
jmp    1357 <main+0x187>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1f40,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0x2b11,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0x2ee0,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0x3e80,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0x5622,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0x5dc0,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0x7d00,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0xac44,-0x1c(%rbp)
je     1402 <main+0x232>
cmpl   $0xbb80,-0x1c(%rbp)
je     1402 <main+0x232>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xc43(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10e0 <atoi@plt>
mov    %al,-0x18(%rbp)
movzbl -0x18(%rbp),%eax
cmp    $0x2,%eax
jle    145d <main+0x28d>
mov    0x2bba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20044(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10e0 <atoi@plt>
mov    -0x20044(%rbp),%edi
mov    %eax,%edx
lea    0xbfb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    -0x28(%rbp),%rdi
lea    0xbfd(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20038(%rbp)
cmpq   $0x0,-0x20038(%rbp)
jne    1498 <main+0x2c8>
lea    0xbdf(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x17(%rbp),%sil
mov    -0x16(%rbp),%dl
mov    -0x15(%rbp),%al
mov    -0x1c(%rbp),%ecx
movzbl %sil,%edi
movzbl %dl,%esi
movzbl %al,%edx
movzbl -0x18(%rbp),%r8d
call   10a0 <setupdsp@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    14f2 <main+0x322>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
lea    0xbab(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20038(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    14f7 <main+0x327>
lea    -0x20030(%rbp),%rdi
mov    -0x20038(%rbp),%rcx
mov    $0x1,%esi
mov    $0x20000,%edx
call   1030 <fread@plt>
mov    %rax,-0x20040(%rbp)
cmp    $0x0,%rax
je     157a <main+0x3aa>
cmpq   $0x20000,-0x20040(%rbp)
je     1552 <main+0x382>
lea    -0x20030(%rbp),%rdi
mov    $0x20000,%eax
sub    -0x20040(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x14(%rbp),%edi
lea    -0x20030(%rbp),%rsi
mov    $0x20000,%edx
call   1090 <play@plt>
cmp    $0x0,%rax
jge    1575 <main+0x3a5>
jmp    157a <main+0x3aa>
jmp    14f7 <main+0x327>
mov    -0x20038(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x20050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20018,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%r14
cmp    $0x5,%edi
je     11f5 <main+0x25>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
mov    0x10(%rbx),%rbp
lea    0xe00(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     12ae <main+0xde>
lea    0xdec(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     12bb <main+0xeb>
lea    0xdd8(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
mov    $0x1,%r13b
test   %eax,%eax
je     12c8 <main+0xf8>
lea    0xdc4(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     12cf <main+0xff>
lea    0xdb7(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     145a <main+0x28a>
lea    0xda6(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1467 <main+0x297>
movb   $0x10,0xf(%rsp)
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
xor    %r13d,%r13d
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
jmp    12d7 <main+0x107>
movb   $0x8,0xf(%rsp)
mov    $0x1,%r12b
xor    %r13d,%r13d
jmp    12da <main+0x10a>
movb   $0x8,0xf(%rsp)
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    12da <main+0x10a>
movb   $0x10,0xf(%rsp)
jmp    12d7 <main+0x107>
movb   $0x10,0xf(%rsp)
xor    %r13d,%r13d
mov    $0x1,%r12b
mov    0x18(%rbx),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r15d
cmp    $0x5621,%eax
jle    1313 <main+0x143>
cmp    $0x7cff,%r15d
jle    1330 <main+0x160>
cmp    $0x7d00,%r15d
je     1378 <main+0x1a8>
cmp    $0xac44,%r15d
je     1378 <main+0x1a8>
cmp    $0xbb80,%r15d
je     1378 <main+0x1a8>
jmp    1356 <main+0x186>
cmp    $0x2edf,%r15d
jg     1344 <main+0x174>
cmp    $0x1f40,%r15d
je     1378 <main+0x1a8>
cmp    $0x2b11,%r15d
je     1378 <main+0x1a8>
jmp    1356 <main+0x186>
cmp    $0x5622,%r15d
je     1378 <main+0x1a8>
cmp    $0x5dc0,%r15d
je     1378 <main+0x1a8>
jmp    1356 <main+0x186>
cmp    $0x2ee0,%r15d
je     1378 <main+0x1a8>
cmp    $0x3e80,%r15d
je     1378 <main+0x1a8>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
lea    0xccc(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
mov    0x20(%rbx),%rdi
call   10e0 <atoi@plt>
movzbl %al,%ebp
cmp    $0x3,%ebp
jb     13aa <main+0x1da>
mov    0x2c50(%rip),%rcx
mov    (%rcx),%edi
lea    0xcac(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
lea    0xcb4(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1471 <main+0x2a1>
mov    %rax,%r14
movzbl 0xf(%rsp),%edi
movzbl %r12b,%esi
movzbl %r13b,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   10a0 <setupdsp@plt>
test   %eax,%eax
js     1487 <main+0x2b7>
mov    %eax,%ebp
lea    0x10(%rsp),%rbx
jmp    1415 <main+0x245>
xchg   %ax,%ax
mov    $0x20000,%edx
sub    %eax,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x20000,%edx
call   1090 <play@plt>
test   %rax,%rax
js     1437 <main+0x267>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x20000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cmp    $0x20000,%rax
je     1401 <main+0x231>
test   %rax,%rax
jne    13f0 <main+0x220>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x20018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movb   $0x10,0xf(%rsp)
xor    %r12d,%r12d
jmp    12da <main+0x10a>
movb   $0x10,0xf(%rsp)
jmp    12c0 <main+0xf0>
lea    0xbf0(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
lea    0xbe9(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"s8\00"
@.str.1 = [3 x i8] c"u8\00"
@.str.2 = [6 x i8] c"sbe16\00"
@.str.3 = [6 x i8] c"sle16\00"
@.str.4 = [6 x i8] c"ube16\00"
@.str.5 = [6 x i8] c"ule16\00"
@stderr = global i32 0
@.str.6 = [20 x i8] c"unknown format: %s\0A\00"
@.str.7 = [19 x i8] c"unknown speed: %d\0A\00"
@.str.8 = [32 x i8] c"invalid number of channels: %d\0A\00"
@.str.9 = [3 x i8] c"rb\00"
@.str.10 = [24 x i8] c"error opening audiofile\00"
@.str.11 = [22 x i8] c"error setting up dsp\0A\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 i8
%10 = alloca i8
%11 = alloca i32
%12 = alloca i8*
%13 = alloca [131072 x i8]
%14 = alloca i32*
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %7
store i8 1, i8* %8
store i8 16, i8* %9
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %12
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 5
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @usage(i8* %24)
br label %26
26: ; preds = %21, %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %26
store i8 8, i8* %9
store i8 1, i8* %8
br label %83
33: ; preds = %26
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %33
store i8 8, i8* %9
store i8 0, i8* %8
br label %82
40: ; preds = %33
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %40
store i8 1, i8* %8
store i8 1, i8* %7
br label %81
47: ; preds = %40
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %47
store i8 1, i8* %8
store i8 0, i8* %7
br label %80
54: ; preds = %47
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i32 @strcmp(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp ne i32 %58, 0
br i1 %59, label %61, label %60
60: ; preds = %54
store i8 0, i8* %8
store i8 1, i8* %7
br label %79
61: ; preds = %54
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 2
%64 = load i8*, i8** %63
%65 = call i32 @strcmp(i8* %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%66 = icmp ne i32 %65, 0
br i1 %66, label %68, label %67
67: ; preds = %61
store i8 0, i8* %8
store i8 0, i8* %7
br label %78
68: ; preds = %61
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 2
%72 = load i8*, i8** %71
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %72)
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
%77 = call i32 @usage(i8* %76)
br label %78
78: ; preds = %68, %67
br label %79
79: ; preds = %78, %60
br label %80
80: ; preds = %79, %53
br label %81
81: ; preds = %80, %46
br label %82
82: ; preds = %81, %39
br label %83
83: ; preds = %82, %32
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 3
%86 = load i8*, i8** %85
%87 = call i32 @atoi(i8* %86)
store i32 %87, i32* %11
%88 = load i32, i32* %11
%89 = icmp ne i32 %88, 8000
br i1 %89, label %90, label %122
90: ; preds = %83
%91 = load i32, i32* %11
%92 = icmp ne i32 %91, 11025
br i1 %92, label %93, label %122
93: ; preds = %90
%94 = load i32, i32* %11
%95 = icmp ne i32 %94, 12000
br i1 %95, label %96, label %122
96: ; preds = %93
%97 = load i32, i32* %11
%98 = icmp ne i32 %97, 16000
br i1 %98, label %99, label %122
99: ; preds = %96
%100 = load i32, i32* %11
%101 = icmp ne i32 %100, 22050
br i1 %101, label %102, label %122
102: ; preds = %99
%103 = load i32, i32* %11
%104 = icmp ne i32 %103, 24000
br i1 %104, label %105, label %122
105: ; preds = %102
%106 = load i32, i32* %11
%107 = icmp ne i32 %106, 32000
br i1 %107, label %108, label %122
108: ; preds = %105
%109 = load i32, i32* %11
%110 = icmp ne i32 %109, 44100
br i1 %110, label %111, label %122
111: ; preds = %108
%112 = load i32, i32* %11
%113 = icmp ne i32 %112, 48000
br i1 %113, label %114, label %122
114: ; preds = %111
%115 = load i32, i32* @stderr
%116 = load i32, i32* %11
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %116)
%118 = load i8**, i8*** %5
%119 = getelementptr inbounds i8*, i8** %118, i64 0
%120 = load i8*, i8** %119
%121 = call i32 @usage(i8* %120)
br label %122
122: ; preds = %114, %111, %108, %105, %102, %99, %96, %93, %90, %83
%123 = load i8**, i8*** %5
%124 = getelementptr inbounds i8*, i8** %123, i64 4
%125 = load i8*, i8** %124
%126 = call i32 @atoi(i8* %125)
%127 = trunc i32 %126 to i8
store i8 %127, i8* %10
%128 = load i8, i8* %10
%129 = zext i8 %128 to i32
%130 = icmp sgt i32 %129, 2
br i1 %130, label %131, label %142
131: ; preds = %122
%132 = load i32, i32* @stderr
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 4
%135 = load i8*, i8** %134
%136 = call i32 @atoi(i8* %135)
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %136)
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 0
%140 = load i8*, i8** %139
%141 = call i32 @usage(i8* %140)
br label %142
142: ; preds = %131, %122
%143 = load i8*, i8** %12
%144 = call i32* @fopen(i8* %143, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %144, i32** %14
%145 = load i32*, i32** %14
%146 = icmp ne i32* %145, null
br i1 %146, label %150, label %147
147: ; preds = %142
%148 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%149 = call i32 @exit(i32 1)
unreachable
150: ; preds = %142
%151 = load i8, i8* %9
%152 = load i8, i8* %8
%153 = load i8, i8* %7
%154 = load i32, i32* %11
%155 = load i8, i8* %10
%156 = call i32 @setupdsp(i8 zeroext %151, i8 zeroext %152, i8 zeroext %153, i32 %154, i8 zeroext %155)
store i32 %156, i32* %6
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %164
158: ; preds = %150
%159 = load i32, i32* @stderr
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%161 = load i32*, i32** %14
%162 = call i32 @fclose(i32* %161)
%163 = call i32 @exit(i32 1)
unreachable
164: ; preds = %150
br label %165
165: ; preds = %185, %164
%166 = getelementptr inbounds [131072 x i8], [131072 x i8]* %13, i64 0, i64 0
%167 = load i32*, i32** %14
%168 = call i64 @fread(i8* %166, i32 1, i32 131072, i32* %167)
store i64 %168, i64* %15
%169 = icmp ne i64 %168, 0
br i1 %169, label %170, label %186
170: ; preds = %165
%171 = load i64, i64* %15
%172 = icmp ne i64 %171, 131072
br i1 %172, label %173, label %179
173: ; preds = %170
%174 = getelementptr inbounds [131072 x i8], [131072 x i8]* %13, i64 0, i64 0
%175 = load i64, i64* %15
%176 = sub i64 131072, %175
%177 = trunc i64 %176 to i32
%178 = call i32 @memset(i8* %174, i32 0, i32 %177)
br label %179
179: ; preds = %173, %170
%180 = load i32, i32* %6
%181 = getelementptr inbounds [131072 x i8], [131072 x i8]* %13, i64 0, i64 0
%182 = call i64 @play(i32 %180, i8* %181, i32 131072)
%183 = icmp slt i64 %182, 0
br i1 %183, label %184, label %185
184: ; preds = %179
br label %186
185: ; preds = %179
br label %165
186: ; preds = %184, %165
%187 = load i32*, i32** %14
%188 = call i32 @fclose(i32* %187)
%189 = load i32, i32* %6
%190 = call i32 @close(i32 %189)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"s8\00"
@.str.1 = [3 x i8] c"u8\00"
@.str.2 = [6 x i8] c"sbe16\00"
@.str.3 = [6 x i8] c"sle16\00"
@.str.4 = [6 x i8] c"ube16\00"
@.str.5 = [6 x i8] c"ule16\00"
@stderr = global i32 0
@.str.6 = [20 x i8] c"unknown format: %s\0A\00"
@.str.7 = [19 x i8] c"unknown speed: %d\0A\00"
@.str.8 = [32 x i8] c"invalid number of channels: %d\0A\00"
@.str.9 = [3 x i8] c"rb\00"
@.str.10 = [24 x i8] c"error opening audiofile\00"
@.str.11 = [22 x i8] c"error setting up dsp\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [131072 x i8]
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = getelementptr inbounds [131072 x i8], [131072 x i8]* %3, i64 0, i64 0
%7 = icmp eq i32 %0, 5
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @usage(i8* %9)
br label %11
11: ; preds = %8, %2
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%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, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %36, label %16
16: ; preds = %11
%17 = 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))
%18 = icmp eq i32 %17, 0
br i1 %18, label %36, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %36, label %25
25: ; preds = %22
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%34 = load i8*, i8** %1
%35 = tail call i32 @usage(i8* %34)
br label %36
36: ; preds = %28, %25, %22, %19, %16, %11, %31
%37 = phi i8 [ 16, %31 ], [ 8, %11 ], [ 8, %16 ], [ 16, %19 ], [ 16, %22 ], [ 16, %25 ], [ 16, %28 ]
%38 = phi i8 [ 1, %31 ], [ 1, %11 ], [ 0, %16 ], [ 1, %19 ], [ 1, %22 ], [ 0, %25 ], [ 0, %28 ]
%39 = phi i8 [ 0, %31 ], [ 0, %11 ], [ 0, %16 ], [ 1, %19 ], [ 0, %22 ], [ 1, %25 ], [ 0, %28 ]
%40 = getelementptr inbounds i8*, i8** %1, i64 3
%41 = load i8*, i8** %40
%42 = tail call i32 @atoi(i8* %41)
switch i32 %42, label %43 [
i32 48000, label %48
i32 44100, label %48
i32 32000, label %48
i32 24000, label %48
i32 22050, label %48
i32 16000, label %48
i32 12000, label %48
i32 11025, label %48
i32 8000, label %48
]
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%46 = load i8*, i8** %1
%47 = tail call i32 @usage(i8* %46)
br label %48
48: ; preds = %36, %36, %36, %36, %36, %36, %36, %36, %36, %43
%49 = getelementptr inbounds i8*, i8** %1, i64 4
%50 = load i8*, i8** %49
%51 = tail call i32 @atoi(i8* %50)
%52 = trunc i32 %51 to i8
%53 = and i32 %51, 255
%54 = icmp ugt i32 %53, 2
br i1 %54, label %55, label %60
55: ; preds = %48
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %51)
%58 = load i8*, i8** %1
%59 = tail call i32 @usage(i8* %58)
br label %60
60: ; preds = %55, %48
%61 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%65 = tail call i32 @exit(i32 1)
unreachable
66: ; preds = %60
%67 = tail call i32 @setupdsp(i8 zeroext %37, i8 zeroext %38, i8 zeroext %39, i32 %42, i8 zeroext %52)
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %66
%70 = load i32, i32* @stderr
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%72 = tail call i32 @fclose(i32* %61)
%73 = tail call i32 @exit(i32 1)
unreachable
74: ; preds = %66, %80
%75 = call i64 @fread(i8* %6, i32 1, i32 131072, i32* %61)
switch i64 %75, label %76 [
i64 0, label %83
i64 131072, label %80
]
76: ; preds = %74
%77 = trunc i64 %75 to i32
%78 = sub i32 131072, %77
%79 = call i32 @memset(i8* %6, i32 0, i32 %78)
br label %80
80: ; preds = %74, %76
%81 = call i64 @play(i32 %67, i8* %6, i32 131072)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %74
83: ; preds = %74, %80
%84 = call i32 @fclose(i32* %61)
%85 = call i32 @close(i32 %67)
ret i32 0
}