#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*/ FILE;

/* Variables and functions */
int O_RDWR;
int O_WRONLY;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int open(char *, int);
scalar_t__ play_file(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ set_audio_config(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int ac, char *av[]) {
  FILE *fd_file;
  int fd_audio, fd_audio2;
  int i, loop, ssi_index;
  int err = 0;
  char rep[32];
  int flag;
  printf("Hi... \n");
  if (ac == 1) {
    printf("main <device> <ssi_nb> <soundfile.wav> [nb_loops]\n Plays the file "
           "to /dev/dspX (uncompressed data)\n");
    printf("device : 0 for stdac; 1 for codec ... \n");
    printf("ssi_nb : 1 for SSI1 ... \n");
    return 0;
  }
  flag = (atoi(av[1]) == 0 ? O_WRONLY : O_RDWR);
  ssi_index = atoi(av[2]);
  if ((fd_audio = open("/dev/sound/dsp", flag)) < 0) {
    printf("Error opening dsp");
    err++;
    goto _err_drv_open1;
  }
  if (ssi_index == 2) {
    fd_audio2 = fd_audio;
    if ((fd_audio = open("/dev/sound/dsp1", O_WRONLY)) < 0) {
      printf("Error opening dsp1");
      err++;
      goto _err_drv_open2;
    }
  }
  if (ac == 5)
    loop = atoi(av[4]);
  else
    loop = 1;
  if ((fd_file = fopen(av[3], "r")) <= 0) {
    err++;
    goto _err_file_not_found;
  }
  if (set_audio_config(fd_audio, fd_file) < 0) {
    printf("Bad format for file 1. ");
    printf("Do you want to continue ? (y/n) : ");
    scanf("%s", rep);
    err++;
    if (rep[0] != 'y')
      goto _err_fmt;
  }
  for (i = 0; i < loop; i++) {
    err += play_file(fd_audio, fd_file);
  }
  write(fd_audio, NULL, 0);
  printf("************** Closing the device\n");
  fclose(fd_file);
  close(fd_audio);
  close(fd_audio2);
  if (err)
    goto _end_err;
  printf("All tests passed with success\n");
  return 0;
_err_fmt:
  fclose(fd_file);
_err_file_not_found:
  close(fd_audio2);
_err_drv_open2:
  close(fd_audio);
_err_drv_open1:
_end_err:
  printf("Encountered %d errors\n", err);
  return err;
}


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,-0x30(%rbp)
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    120b <main+0x6b>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1462 <main+0x2c2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
cmp    $0x0,%eax
jne    1232 <main+0x92>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
jmp    123e <main+0x9e>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x54(%rbp),%esi
lea    0xe50(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    128b <main+0xeb>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1446 <main+0x2a6>
cmpl   $0x2,-0x2c(%rbp)
jne    12dd <main+0x13d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d2e(%rip),%rax
mov    (%rax),%esi
lea    0xe24(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    12d8 <main+0x138>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    143e <main+0x29e>
jmp    12dd <main+0x13d>
cmpl   $0x5,-0x8(%rbp)
jne    12fc <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    1303 <main+0x163>
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xde0(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
ja     1333 <main+0x193>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1436 <main+0x296>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <set_audio_config@plt>
cmp    $0x0,%rax
jge    1395 <main+0x1f5>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xdbf(%rip),%rdi
call   1090 <scanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movsbl -0x50(%rbp),%eax
cmp    $0x79,%eax
je     1390 <main+0x1f0>
jmp    142d <main+0x28d>
jmp    1395 <main+0x1f5>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    13cf <main+0x22f>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <play_file@plt>
mov    %rax,%rcx
movslq -0x30(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    139c <main+0x1fc>
mov    -0x1c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <write@plt>
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
cmpl   $0x0,-0x30(%rbp)
je     1413 <main+0x273>
jmp    144b <main+0x2ab>
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1462 <main+0x2c2>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
jmp    144b <main+0x2ab>
mov    -0x30(%rbp),%esi
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r12
mov    %edi,%ebx
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%ebx
jne    11ff <main+0x4f>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf79(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
jmp    1395 <main+0x1e5>
mov    0x8(%r12),%rdi
call   10d0 <atoi@plt>
test   %eax,%eax
jne    1216 <main+0x66>
mov    0x2dbc(%rip),%rax
jmp    121d <main+0x6d>
mov    0x2dcb(%rip),%rax
mov    (%rax),%ebp
mov    0x10(%r12),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r13d
lea    0xdcd(%rip),%rdi
mov    %ebp,%esi
call   10b0 <open@plt>
test   %eax,%eax
js     1346 <main+0x196>
mov    %eax,%r14d
mov    %eax,%r15d
cmp    $0x2,%r13d
jne    126e <main+0xbe>
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
lea    0xdc3(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
js     1356 <main+0x1a6>
mov    $0x1,%ebp
cmp    $0x5,%ebx
jne    1284 <main+0xd4>
mov    0x20(%r12),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%r12),%rdi
lea    0xdb4(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     136e <main+0x1be>
mov    %rax,%r12
mov    %r15d,%edi
mov    %rax,%rsi
call   1050 <set_audio_config@plt>
xor    %ebx,%ebx
test   %rax,%rax
jns    12e9 <main+0x139>
lea    0xd8c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdab(%rip),%rdi
mov    %rsp,%rsi
call   10a0 <scanf@plt>
mov    $0x1,%ebx
cmpb   $0x79,(%rsp)
jne    1366 <main+0x1b6>
test   %ebp,%ebp
jle    1302 <main+0x152>
nopl   (%rax)
mov    %r15d,%edi
mov    %r12,%rsi
call   1060 <play_file@plt>
add    %eax,%ebx
add    $0xffffffff,%ebp
jne    12f0 <main+0x140>
xor    %ebp,%ebp
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <write@plt>
lea    0xd8b(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1070 <fclose@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    %r14d,%edi
call   1090 <close@plt>
test   %ebx,%ebx
jne    1383 <main+0x1d3>
lea    0xd85(%rip),%rdi
call   1030 <puts@plt>
jmp    1395 <main+0x1e5>
lea    0xcc2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    137e <main+0x1ce>
lea    0xcd4(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1376 <main+0x1c6>
mov    %r12,%rdi
call   1070 <fclose@plt>
mov    %r14d,%edi
call   1090 <close@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    $0x1,%ebx
lea    0xcfa(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebx,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Hi... \0A\00"
@.str.1 = [100 x i8] c"main <device> <ssi_nb> <soundfile.wav> [nb_loops]\0A Plays the file to /dev/dspX (uncompressed data)\0A\00"
@.str.2 = [40 x i8] c"device : 0 for stdac; 1 for codec ... \0A\00"
@.str.3 = [26 x i8] c"ssi_nb : 1 for SSI1 ... \0A\00"
@O_WRONLY = global i32 0
@O_RDWR = global i32 0
@.str.4 = [15 x i8] c"/dev/sound/dsp\00"
@.str.5 = [18 x i8] c"Error opening dsp\00"
@.str.6 = [16 x i8] c"/dev/sound/dsp1\00"
@.str.7 = [19 x i8] c"Error opening dsp1\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [24 x i8] c"Bad format for file 1. \00"
@.str.10 = [35 x i8] c"Do you want to continue ? (y/n) : \00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [35 x i8] c"************** Closing the device\0A\00"
@.str.13 = [31 x i8] c"All tests passed with success\0A\00"
@.str.14 = [23 x i8] c"Encountered %d errors\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 [32 x i8]
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %139
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32, i32* @O_WRONLY
br label %32
30: ; preds = %22
%31 = load i32, i32* @O_RDWR
br label %32
32: ; preds = %30, %28
%33 = phi i32 [ %29, %28 ], [ %31, %30 ]
store i32 %33, i32* %14
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %11
%38 = load i32, i32* %14
%39 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %38)
store i32 %39, i32* %7
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1
store i32 %44, i32* %12
br label %134
45: ; preds = %32
%46 = load i32, i32* %11
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i32, i32* %7
store i32 %49, i32* %8
%50 = load i32, i32* @O_WRONLY
%51 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %50)
store i32 %51, i32* %7
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
store i32 %56, i32* %12
br label %131
57: ; preds = %48
br label %58
58: ; preds = %57, %45
%59 = load i32, i32* %4
%60 = icmp eq i32 %59, 5
br i1 %60, label %61, label %66
61: ; preds = %58
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 4
%64 = load i8*, i8** %63
%65 = call i32 @atoi(i8* %64)
store i32 %65, i32* %10
br label %67
66: ; preds = %58
store i32 1, i32* %10
br label %67
67: ; preds = %66, %61
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 3
%70 = load i8*, i8** %69
%71 = call i32* @fopen(i8* %70, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %71, i32** %6
%72 = icmp ule i32* %71, null
br i1 %72, label %73, label %76
73: ; preds = %67
%74 = load i32, i32* %12
%75 = add nsw i32 %74, 1
store i32 %75, i32* %12
br label %128
76: ; preds = %67
%77 = load i32, i32* %7
%78 = load i32*, i32** %6
%79 = call i64 @set_audio_config(i32 %77, i32* %78)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %94
81: ; preds = %76
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%84 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%85 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %84)
%86 = load i32, i32* %12
%87 = add nsw i32 %86, 1
store i32 %87, i32* %12
%88 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = icmp ne i32 %90, 121
br i1 %91, label %92, label %93
92: ; preds = %81
br label %125
93: ; preds = %81
br label %94
94: ; preds = %93, %76
store i32 0, i32* %9
br label %95
95: ; preds = %107, %94
%96 = load i32, i32* %9
%97 = load i32, i32* %10
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %110
99: ; preds = %95
%100 = load i32, i32* %7
%101 = load i32*, i32** %6
%102 = call i64 @play_file(i32 %100, i32* %101)
%103 = load i32, i32* %12
%104 = sext i32 %103 to i64
%105 = add nsw i64 %104, %102
%106 = trunc i64 %105 to i32
store i32 %106, i32* %12
br label %107
107: ; preds = %99
%108 = load i32, i32* %9
%109 = add nsw i32 %108, 1
store i32 %109, i32* %9
br label %95
110: ; preds = %95
%111 = load i32, i32* %7
%112 = call i32 @write(i32 %111, i32* null, i32 0)
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
%114 = load i32*, i32** %6
%115 = call i32 @fclose(i32* %114)
%116 = load i32, i32* %7
%117 = call i32 @close(i32 %116)
%118 = load i32, i32* %8
%119 = call i32 @close(i32 %118)
%120 = load i32, i32* %12
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %123
122: ; preds = %110
br label %135
123: ; preds = %110
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %3
br label %139
125: ; preds = %92
%126 = load i32*, i32** %6
%127 = call i32 @fclose(i32* %126)
br label %128
128: ; preds = %125, %73
%129 = load i32, i32* %8
%130 = call i32 @close(i32 %129)
br label %131
131: ; preds = %128, %53
%132 = load i32, i32* %7
%133 = call i32 @close(i32 %132)
br label %134
134: ; preds = %131, %41
br label %135
135: ; preds = %134, %122
%136 = load i32, i32* %12
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i32 %136)
%138 = load i32, i32* %12
store i32 %138, i32* %3
br label %139
139: ; preds = %135, %123, %18
%140 = load i32, i32* %3
ret i32 %140
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_RDWR = global i32 0
@.str.4 = [15 x i8] c"/dev/sound/dsp\00"
@.str.5 = [18 x i8] c"Error opening dsp\00"
@.str.6 = [16 x i8] c"/dev/sound/dsp1\00"
@.str.7 = [19 x i8] c"Error opening dsp1\00"
@.str.8 = [2 x i8] c"r\00"
@.str.9 = [24 x i8] c"Bad format for file 1. \00"
@.str.10 = [35 x i8] c"Do you want to continue ? (y/n) : \00"
@.str.11 = [3 x i8] c"%s\00"
@.str.14 = [23 x i8] c"Encountered %d errors\0A\00"
@str = [7 x i8] c"Hi... \00"
@str.15 = [34 x i8] c"************** Closing the device\00"
@str.16 = [30 x i8] c"All tests passed with success\00"
@str.17 = [99 x i8] c"main <device> <ssi_nb> <soundfile.wav> [nb_loops]\0A Plays the file to /dev/dspX (uncompressed data)\00"
@str.18 = [39 x i8] c"device : 0 for stdac; 1 for codec ... \00"
@str.19 = [25 x i8] c"ssi_nb : 1 for SSI1 ... \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.18, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.19, i64 0, i64 0))
br label %87
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp eq i32 %14, 0
%16 = load i32, i32* @O_WRONLY
%17 = load i32, i32* @O_RDWR
%18 = select i1 %15, i32 %16, i32 %17
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %11
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %84
26: ; preds = %11
%27 = icmp eq i32 %21, 2
br i1 %27, label %28, label %34
28: ; preds = %26
%29 = load i32, i32* @O_WRONLY
%30 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %81
34: ; preds = %28, %26
%35 = phi i32 [ %30, %28 ], [ %22, %26 ]
%36 = icmp eq i32 %0, 5
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = getelementptr inbounds i8*, i8** %1, i64 4
%39 = load i8*, i8** %38
%40 = tail call i32 @atoi(i8* %39)
br label %41
41: ; preds = %34, %37
%42 = phi i32 [ %40, %37 ], [ 1, %34 ]
%43 = getelementptr inbounds i8*, i8** %1, i64 3
%44 = load i8*, i8** %43
%45 = tail call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %79, label %47
47: ; preds = %41
%48 = tail call i64 @set_audio_config(i32 %35, i32* %45)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %56
50: ; preds = %47
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %4)
%54 = load i8, i8* %4
%55 = icmp eq i8 %54, 121
br i1 %55, label %56, label %77
56: ; preds = %50, %47
%57 = phi i32 [ 1, %50 ], [ 0, %47 ]
%58 = icmp sgt i32 %42, 0
br i1 %58, label %59, label %67
59: ; preds = %56, %59
%60 = phi i32 [ %64, %59 ], [ %57, %56 ]
%61 = phi i32 [ %65, %59 ], [ 0, %56 ]
%62 = call i64 @play_file(i32 %35, i32* %45)
%63 = trunc i64 %62 to i32
%64 = add i32 %60, %63
%65 = add nuw nsw i32 %61, 1
%66 = icmp eq i32 %65, %42
br i1 %66, label %67, label %59
67: ; preds = %59, %56
%68 = phi i32 [ %57, %56 ], [ %64, %59 ]
%69 = call i32 @write(i32 %35, i32* null, i32 0)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.15, i64 0, i64 0))
%71 = call i32 @fclose(i32* %45)
%72 = call i32 @close(i32 %35)
%73 = call i32 @close(i32 %22)
%74 = icmp eq i32 %68, 0
br i1 %74, label %75, label %84
75: ; preds = %67
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.16, i64 0, i64 0))
br label %87
77: ; preds = %50
%78 = call i32 @fclose(i32* %45)
br label %79
79: ; preds = %41, %77
%80 = call i32 @close(i32 %22)
br label %81
81: ; preds = %79, %32
%82 = phi i32 [ %30, %32 ], [ %35, %79 ]
%83 = call i32 @close(i32 %82)
br label %84
84: ; preds = %24, %81, %67
%85 = phi i32 [ 1, %24 ], [ 1, %81 ], [ %68, %67 ]
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %84, %75, %7
%88 = phi i32 [ 0, %7 ], [ %85, %84 ], [ 0, %75 ]
ret i32 %88
}