#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 off_t;

/* Variables and functions */
int AFMT_S16_LE;
int /*<<< orphan*/ F_SETFL;
int OSPC_Init(void *, int);
int OSPC_Run(int, void *, int);
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ SNDCTL_DSP_CHANNELS;
int /*<<< orphan*/ SNDCTL_DSP_SETFMT;
int /*<<< orphan*/ SNDCTL_DSP_SPEED;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fcntl(int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ free(void *);
int ioctl(int, int /*<<< orphan*/, int *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
void *malloc(int);
int open(char *, int /*<<< orphan*/, ...);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ write(int, void *, int);
int main(int argc, char *argv[]) {
  int optionoffset = 0, audio_fd, channels = 2, rformat, rchannels,
      format = AFMT_S16_LE, speed = 32000, fd;
  char audio_device[] = "/dev/dsp";
  char ver[] = "0.2";
  char c;
  void *ptr, *buf;
  off_t size;
  if ((argc < 2)) {
    printf("\n[?] Usage: soap [sound device] SPC_FILE_NAME\n[?] Optional "
           "parameters are in brackets.\n[?] SOAP Version %s (2003) Steve B "
           "Melvin Jr\n\n",
           ver);
    exit(1);
  }
  if ((argc > 2)) {
    strcpy(audio_device, argv[1]);
    optionoffset++;
  }
  if ((audio_fd = open(audio_device, O_WRONLY, 0)) == -1) {
    printf("[-] Could not open, %s.\n", audio_device);
    exit(1);
  }
  printf("[+] Successfully opened, %s.\n", audio_device);
  rformat = format;
  if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format) == -1) {
    printf("[-] Could not set sound format.\n");
    exit(1);
  }
  if (format != rformat) {
    printf("[-] Could not set sound format.\n");
    exit(1);
  }
  printf("[+] Successfully set sound format.\n");
  rchannels = channels;
  if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels) == -1) {
    printf("[-] Could not set channels.\n");
    exit(1);
  }
  if (channels != rchannels) {
    printf("[-] Could not set channels.\n");
    exit(1);
  }
  printf("[+] Successfully set channels.\n");
  if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed) == -1) {
    printf("[-] Could not set speed.\n");
    exit(1);
  }
  printf("[+] Using speed, {%iHz}\n", speed);
  buf = malloc(32000);
  fd = open(argv[1 + optionoffset], O_RDONLY);
  if (fd < 0) {
    printf("[-] Could not open \'%s\'\n.", argv[1]);
    exit(1);
  }
  size = lseek(fd, 0, SEEK_END);
  lseek(fd, 0, SEEK_SET);
  ptr = malloc(size);
  read(fd, ptr, size);
  close(fd);
  fd = OSPC_Init(ptr, size);
  free(ptr);
  fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
  printf("[+] Playing SPC, press Enter to quit.\n");
  while ((read(STDIN_FILENO, &c, 1)) <= 0) {
    size = OSPC_Run(-1, buf, 32000);
    write(audio_fd, buf, size);
  }
  printf("\nGoodbye!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movl   $0x7d00,-0x2c(%rbp)
mov    0xde2(%rip),%rax
mov    %rax,-0x39(%rbp)
mov    0xde0(%rip),%al
mov    %al,-0x31(%rbp)
mov    0xdd8(%rip),%eax
mov    %eax,-0x3d(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    125a <main+0x7a>
lea    -0x3d(%rbp),%rsi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jle    127e <main+0x9e>
lea    -0x39(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    -0x39(%rbp),%rdi
mov    0x2cff(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    12bc <main+0xdc>
lea    -0x39(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x39(%rbp),%rsi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2cc2(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    130a <main+0x12a>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     132e <main+0x14e>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2c5c(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1378 <main+0x198>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     139c <main+0x1bc>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    0x2c0c(%rip),%rax
mov    (%rax),%esi
lea    -0x2c(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    13e0 <main+0x200>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x2c(%rbp),%esi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x7d00,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2bc1(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    144d <main+0x26d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x30(%rbp),%edi
mov    0x2b91(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%edi
mov    0x2b43(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
mov    -0x54(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   10b0 <read@plt>
mov    -0x30(%rbp),%edi
call   10a0 <close@plt>
mov    -0x48(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   10f0 <OSPC_Init@plt>
mov    %eax,-0x30(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
mov    0x2af7(%rip),%rax
mov    (%rax),%esi
mov    0x2b16(%rip),%rax
mov    (%rax),%edx
call   1050 <fcntl@plt>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2ab2(%rip),%rax
mov    (%rax),%edi
lea    -0x3e(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmp    $0x0,%rax
jg     152a <main+0x34a>
mov    -0x50(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0x7d00,%edx
call   10d0 <OSPC_Run@plt>
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1060 <write@plt>
jmp    14df <main+0x2ff>
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0x2,0xc(%rsp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,0x8(%rsp)
movl   $0x7d00,0x4(%rsp)
movabs $0x7073642f7665642f,%rax
64 73 70
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
movl   $0x322e30,0x1c(%rsp)
cmp    $0x1,%edi
jle    1461 <main+0x271>
mov    %rsi,%r14
mov    $0x1,%ebp
cmp    $0x2,%edi
je     125e <main+0x6e>
mov    0x8(%r14),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
mov    $0x2,%ebp
mov    0x2d23(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   10f0 <open@plt>
cmp    $0xffffffff,%eax
je     146f <main+0x27f>
mov    %eax,%r15d
lea    0xe20(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d05(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r15d,%edi
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
je     144f <main+0x25f>
cmp    %ebx,0x8(%rsp)
jne    144f <main+0x25f>
lea    0xe35(%rip),%rdi
call   1050 <puts@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %r15d,%edi
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1458 <main+0x268>
cmpl   $0x2,0xc(%rsp)
jne    1458 <main+0x268>
lea    0xe22(%rip),%rdi
call   1050 <puts@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %r15d,%edi
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
je     147d <main+0x28d>
mov    0x4(%rsp),%esi
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x7d00,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
mov    (%r14,%rbp,8),%rdi
mov    0x2c90(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10f0 <open@plt>
test   %eax,%eax
js     1493 <main+0x2a3>
mov    %eax,%ebp
mov    0x2c86(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
mov    %eax,%r14d
mov    0x2c39(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
mov    %r14d,%edi
call   10d0 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%edi
mov    %rax,%rsi
mov    %r14d,%edx
call   10c0 <read@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1100 <OSPC_Init@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x2bdd(%rip),%r14
mov    (%r14),%edi
mov    0x2bf3(%rip),%rax
mov    (%rax),%esi
mov    0x2c12(%rip),%rax
mov    (%rax),%edx
call   1060 <fcntl@plt>
lea    0xd5f(%rip),%rdi
call   1050 <puts@plt>
mov    (%r14),%edi
lea    0x3(%rsp),%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
test   %rax,%rax
jg     1434 <main+0x244>
lea    0x3(%rsp),%rbp
nopl   (%rax)
mov    $0xffffffff,%edi
mov    %rbx,%rsi
mov    $0x7d00,%edx
call   10e0 <OSPC_Run@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <write@plt>
mov    (%r14),%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
test   %rax,%rax
jle    1400 <main+0x210>
lea    0xd26(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd4a(%rip),%rdi
jmp    1484 <main+0x294>
lea    0xd25(%rip),%rdi
jmp    1484 <main+0x294>
lea    0xba1(%rip),%rdi
lea    0x1c(%rsp),%rsi
jmp    149e <main+0x2ae>
lea    0xc19(%rip),%rdi
lea    0x10(%rsp),%rsi
jmp    149e <main+0x2ae>
lea    0xce7(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x8(%r14),%rsi
lea    0xc41(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@AFMT_S16_LE = global i32 0
@__const.main.audio_device = [9 x i8] c"/dev/dsp\00"
@__const.main.ver = [4 x i8] c"0.2\00"
@.str = [134 x i8] c"\0A[?] Usage: soap [sound device] SPC_FILE_NAME\0A[?] Optional parameters are in brackets.\0A[?] SOAP Version %s (2003) Steve B Melvin Jr\0A\0A\00"
@O_WRONLY = global i32 0
@.str.1 = [25 x i8] c"[-] Could not open, %s.\0A\00"
@.str.2 = [30 x i8] c"[+] Successfully opened, %s.\0A\00"
@SNDCTL_DSP_SETFMT = global i32 0
@.str.3 = [33 x i8] c"[-] Could not set sound format.\0A\00"
@.str.4 = [36 x i8] c"[+] Successfully set sound format.\0A\00"
@SNDCTL_DSP_CHANNELS = global i32 0
@.str.5 = [29 x i8] c"[-] Could not set channels.\0A\00"
@.str.6 = [32 x i8] c"[+] Successfully set channels.\0A\00"
@SNDCTL_DSP_SPEED = global i32 0
@.str.7 = [26 x i8] c"[-] Could not set speed.\0A\00"
@.str.8 = [25 x i8] c"[+] Using speed, {%iHz}\0A\00"
@O_RDONLY = global i32 0
@.str.9 = [26 x i8] c"[-] Could not open '%s'\0A.\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@STDIN_FILENO = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.10 = [39 x i8] c"[+] Playing SPC, press Enter to quit.\0A\00"
@.str.11 = [11 x i8] c"\0AGoodbye!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [9 x i8]
%15 = alloca [4 x i8]
%16 = alloca i8
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 2, i32* %8
%20 = load i32, i32* @AFMT_S16_LE
store i32 %20, i32* %11
store i32 32000, i32* %12
%21 = bitcast [9 x i8]* %14 to i8*
%22 = bitcast [4 x i8]* %15 to i8*
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %15, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 2
br i1 %31, label %32, label %40
32: ; preds = %29
%33 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @strcpy(i8* %33, i8* %36)
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %40
40: ; preds = %32, %29
%41 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%42 = load i32, i32* @O_WRONLY
%43 = call i32 (i8*, i32, ...) @open(i8* %41, i32 %42, i32 0)
store i32 %43, i32* %7
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %49
45: ; preds = %40
%46 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %40
%50 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %50)
%52 = load i32, i32* %11
store i32 %52, i32* %9
%53 = load i32, i32* %7
%54 = load i32, i32* @SNDCTL_DSP_SETFMT
%55 = call i32 @ioctl(i32 %53, i32 %54, i32* %11)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %60
57: ; preds = %49
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %49
%61 = load i32, i32* %11
%62 = load i32, i32* %9
%63 = icmp ne i32 %61, %62
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %60
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%69 = load i32, i32* %8
store i32 %69, i32* %10
%70 = load i32, i32* %7
%71 = load i32, i32* @SNDCTL_DSP_CHANNELS
%72 = call i32 @ioctl(i32 %70, i32 %71, i32* %8)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %67
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %67
%78 = load i32, i32* %8
%79 = load i32, i32* %10
%80 = icmp ne i32 %78, %79
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %77
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%86 = load i32, i32* %7
%87 = load i32, i32* @SNDCTL_DSP_SPEED
%88 = call i32 @ioctl(i32 %86, i32 %87, i32* %12)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %93
90: ; preds = %84
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %84
%94 = load i32, i32* %12
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %94)
%96 = call i8* @malloc(i32 32000)
store i8* %96, i8** %18
%97 = load i8**, i8*** %5
%98 = load i32, i32* %6
%99 = add nsw i32 1, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8*, i8** %97, i64 %100
%102 = load i8*, i8** %101
%103 = load i32, i32* @O_RDONLY
%104 = call i32 (i8*, i32, ...) @open(i8* %102, i32 %103)
store i32 %104, i32* %13
%105 = load i32, i32* %13
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %93
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 1
%110 = load i8*, i8** %109
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %93
%114 = load i32, i32* %13
%115 = load i32, i32* @SEEK_END
%116 = call i32 @lseek(i32 %114, i32 0, i32 %115)
store i32 %116, i32* %19
%117 = load i32, i32* %13
%118 = load i32, i32* @SEEK_SET
%119 = call i32 @lseek(i32 %117, i32 0, i32 %118)
%120 = load i32, i32* %19
%121 = call i8* @malloc(i32 %120)
store i8* %121, i8** %17
%122 = load i32, i32* %13
%123 = load i8*, i8** %17
%124 = load i32, i32* %19
%125 = call i64 @read(i32 %122, i8* %123, i32 %124)
%126 = load i32, i32* %13
%127 = call i32 @close(i32 %126)
%128 = load i8*, i8** %17
%129 = load i32, i32* %19
%130 = call i32 @OSPC_Init(i8* %128, i32 %129)
store i32 %130, i32* %13
%131 = load i8*, i8** %17
%132 = call i32 @free(i8* %131)
%133 = load i32, i32* @STDIN_FILENO
%134 = load i32, i32* @F_SETFL
%135 = load i32, i32* @O_NONBLOCK
%136 = call i32 @fcntl(i32 %133, i32 %134, i32 %135)
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %138
138: ; preds = %142, %113
%139 = load i32, i32* @STDIN_FILENO
%140 = call i64 @read(i32 %139, i8* %16, i32 1)
%141 = icmp sle i64 %140, 0
br i1 %141, label %142, label %149
142: ; preds = %138
%143 = load i8*, i8** %18
%144 = call i32 @OSPC_Run(i32 -1, i8* %143, i32 32000)
store i32 %144, i32* %19
%145 = load i32, i32* %7
%146 = load i8*, i8** %18
%147 = load i32, i32* %19
%148 = call i32 @write(i32 %145, i8* %146, i32 %147)
br label %138
149: ; preds = %138
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@AFMT_S16_LE = global i32 0
@__const.main.audio_device = [9 x i8] c"/dev/dsp\00"
@.str = [134 x i8] c"\0A[?] Usage: soap [sound device] SPC_FILE_NAME\0A[?] Optional parameters are in brackets.\0A[?] SOAP Version %s (2003) Steve B Melvin Jr\0A\0A\00"
@O_WRONLY = global i32 0
@.str.1 = [25 x i8] c"[-] Could not open, %s.\0A\00"
@.str.2 = [30 x i8] c"[+] Successfully opened, %s.\0A\00"
@SNDCTL_DSP_SETFMT = global i32 0
@SNDCTL_DSP_CHANNELS = global i32 0
@SNDCTL_DSP_SPEED = global i32 0
@.str.8 = [25 x i8] c"[+] Using speed, {%iHz}\0A\00"
@O_RDONLY = global i32 0
@.str.9 = [26 x i8] c"[-] Could not open '%s'\0A.\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@STDIN_FILENO = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@str = [35 x i8] c"[+] Successfully set sound format.\00"
@str.12 = [31 x i8] c"[+] Successfully set channels.\00"
@str.13 = [38 x i8] c"[+] Playing SPC, press Enter to quit.\00"
@str.14 = [10 x i8] c"\0AGoodbye!\00"
@str.15 = [25 x i8] c"[-] Could not set speed.\00"
@str.17 = [28 x i8] c"[-] Could not set channels.\00"
@str.19 = [32 x i8] c"[-] Could not set sound format.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [9 x i8]
%7 = alloca i32
%8 = alloca i8
%9 = bitcast i32* %3 to i8*
store i32 2, i32* %3
%10 = bitcast i32* %4 to i8*
%11 = load i32, i32* @AFMT_S16_LE
store i32 %11, i32* %4
%12 = bitcast i32* %5 to i8*
store i32 32000, i32* %5
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%14 = bitcast i32* %7 to i8*
store i32 3288624, i32* %7
%15 = icmp slt i32 %0, 2
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32* %7)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = icmp eq i32 %0, 2
br i1 %20, label %25, label %21
21: ; preds = %19
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strcpy(i8* %13, i8* %23)
br label %25
25: ; preds = %21, %19
%26 = phi i64 [ 2, %21 ], [ 1, %19 ]
%27 = load i32, i32* @O_WRONLY
%28 = call i32 (i8*, i32, ...) @open(i8* %13, i32 %27, i32 0)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%35 = load i32, i32* @SNDCTL_DSP_SETFMT
%36 = call i32 @ioctl(i32 %28, i32 %35, i32* %4)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.19, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %33
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, %11
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.19, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %41
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%49 = load i32, i32* @SNDCTL_DSP_CHANNELS
%50 = call i32 @ioctl(i32 %28, i32 %49, i32* %3)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %47
%56 = load i32, i32* %3
%57 = icmp eq i32 %56, 2
br i1 %57, label %61, label %58
58: ; preds = %55
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %55
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0))
%63 = load i32, i32* @SNDCTL_DSP_SPEED
%64 = call i32 @ioctl(i32 %28, i32 %63, i32* %5)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.15, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %61
%70 = load i32, i32* %5
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %70)
%72 = call dereferenceable_or_null(32000) i8* @malloc(i32 32000)
%73 = getelementptr inbounds i8*, i8** %1, i64 %26
%74 = load i8*, i8** %73
%75 = load i32, i32* @O_RDONLY
%76 = call i32 (i8*, i32, ...) @open(i8* %74, i32 %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %69
%79 = getelementptr inbounds i8*, i8** %1, i64 1
%80 = load i8*, i8** %79
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %69
%84 = load i32, i32* @SEEK_END
%85 = call i32 @lseek(i32 %76, i32 0, i32 %84)
%86 = load i32, i32* @SEEK_SET
%87 = call i32 @lseek(i32 %76, i32 0, i32 %86)
%88 = call i8* @malloc(i32 %85)
%89 = call i64 @read(i32 %76, i8* %88, i32 %85)
%90 = call i32 @close(i32 %76)
%91 = call i32 @OSPC_Init(i8* %88, i32 %85)
%92 = call i32 @free(i8* %88)
%93 = load i32, i32* @STDIN_FILENO
%94 = load i32, i32* @F_SETFL
%95 = load i32, i32* @O_NONBLOCK
%96 = call i32 @fcntl(i32 %93, i32 %94, i32 %95)
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
%98 = load i32, i32* @STDIN_FILENO
%99 = call i64 @read(i32 %98, i8* %8, i32 1)
%100 = icmp slt i64 %99, 1
br i1 %100, label %101, label %107
101: ; preds = %83, %101
%102 = call i32 @OSPC_Run(i32 -1, i8* %72, i32 32000)
%103 = call i32 @write(i32 %28, i8* %72, i32 %102)
%104 = load i32, i32* @STDIN_FILENO
%105 = call i64 @read(i32 %104, i8* %8, i32 1)
%106 = icmp slt i64 %105, 1
br i1 %106, label %101, label %107
107: ; preds = %101, %83
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.14, i64 0, i64 0))
ret i32 0
}