#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 /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ get_next_file_name(int /*<<< orphan*/ *, char *);
int open(char *, int);
scalar_t__ play_file(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ set_audio_config(int, int /*<<< orphan*/ *);
int main(int ac, char *av[]) {
  FILE *fd_file, *fd_list;
  int fd_audio, fd_audio2, open_flag;
  int i, j, loop, ssi_index, liip;
  int err = 0;
  char file_name[256];
  printf("Hi... \n");
  if (ac == 1) {
    printf("main <ssi_nb> <playlist.txt> <file_loops> <list_loop> [device]\n "
           "Play files to /dev/dspX (uncompressed data)\n");
    printf("ssi_nb : 1 for SSI1 ... \n");
    printf("device : 0 for StDac, 1 for Codec... \n");
    return 0;
  }
  loop = atoi(av[3]);
  liip = atoi(av[4]);
  if (ac == 6) {
    if (atoi(av[5]) == 0)
      open_flag = O_WRONLY;
    else
      open_flag = O_RDWR;
  } else {
    open_flag = O_WRONLY;
  }
  if ((fd_list = fopen(av[2], "r")) <= 0) {
    err++;
    goto _err_list_not_found;
  }
  ssi_index = atoi(av[1]);
  if ((fd_audio = open("/dev/sound/dsp", O_WRONLY)) < 0) {
    printf("Error opening dsp");
    err++;
    goto _err_drv_open;
  }
  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;
    }
  }
  for (j = 0; j < liip; j++) {
    get_next_file_name(fd_list, file_name);
    while (*file_name != '\0') {
      if (*file_name == '\0')
        continue;
      if ((fd_file = fopen(file_name, "r")) <= 0) {
        printf("Error at file opening. Skip.\n");
        err++;
        goto _next;
      }
      if (set_audio_config(fd_audio, fd_file) < 0) {
        printf("Bad format for file %s. Skip.\n", file_name);
        fclose(fd_file);
        err++;
        goto _next;
      }
      for (i = 0; i < loop; i++) {
        err += play_file(fd_audio, fd_file);
      }
      fclose(fd_file);
    _next:
      get_next_file_name(fd_list, file_name);
    }
    fseek(fd_list, 0, SEEK_SET);
  }
  printf("************** Closing the device\n");
  fclose(fd_list);
  close(fd_audio);
  if (ssi_index == 2)
    close(fd_audio2);
  if (err)
    goto _end_err;
  printf("All tests passed with success\n");
  return 0;
_err_drv_open2:
  close(fd_audio);
_err_drv_open:
  fclose(fd_list);
_end_err:
_err_list_not_found:
  printf("Encountered %d errors\n", err);
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    120e <main+0x6e>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1513 <main+0x373>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x6,-0x8(%rbp)
jne    1270 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10c0 <atoi@plt>
cmp    $0x0,%eax
jne    125f <main+0xbf>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    126b <main+0xcb>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    127c <main+0xdc>
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
ja     12ac <main+0x10c>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    14fc <main+0x35c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%esi
lea    0xdec(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12f9 <main+0x159>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    14ee <main+0x34e>
cmpl   $0x2,-0x3c(%rbp)
jne    134b <main+0x1ab>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cb8(%rip),%rax
mov    (%rax),%esi
lea    0xdc0(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1346 <main+0x1a6>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    14e6 <main+0x346>
jmp    134b <main+0x1ab>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    148c <main+0x2ec>
mov    -0x20(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   10b0 <get_next_file_name@plt>
movsbl -0x150(%rbp),%eax
cmp    $0x0,%eax
je     146a <main+0x2ca>
movsbl -0x150(%rbp),%eax
cmp    $0x0,%eax
jne    1393 <main+0x1f3>
jmp    136e <main+0x1ce>
lea    -0x150(%rbp),%rdi
lea    0xd15(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
ja     13d0 <main+0x230>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1455 <main+0x2b5>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <set_audio_config@plt>
cmp    $0x0,%rax
jge    1412 <main+0x272>
lea    -0x150(%rbp),%rsi
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1455 <main+0x2b5>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    144c <main+0x2ac>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <play_file@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1419 <main+0x279>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   10b0 <get_next_file_name@plt>
jmp    136e <main+0x1ce>
mov    -0x20(%rbp),%rdi
mov    0x2b63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1352 <main+0x1b2>
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x2,-0x3c(%rbp)
jne    14bd <main+0x31d>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x44(%rbp)
je     14cc <main+0x32c>
jmp    14f7 <main+0x357>
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1513 <main+0x373>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
jmp    14fc <main+0x35c>
mov    -0x44(%rbp),%esi
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%ebx
jne    1202 <main+0x52>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xf62(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6f(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    13fd <main+0x24d>
mov    0x18(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,0x1c(%rsp)
mov    0x20(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    0x10(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   10b0 <fopen@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     13ed <main+0x23d>
mov    %rax,%r15
mov    0x8(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
mov    0x2d81(%rip),%r14
mov    (%r14),%esi
lea    0xda9(%rip),%rdi
call   10a0 <open@plt>
test   %eax,%eax
js     1381 <main+0x1d1>
mov    %eax,0x10(%rsp)
mov    %eax,%r13d
cmp    $0x2,%ebp
jne    128c <main+0xdc>
mov    (%r14),%esi
lea    0xda7(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,%r13d
test   %eax,%eax
js     13cf <main+0x21f>
cmpl   $0x0,0xc(%rsp)
mov    %ebp,0x14(%rsp)
jle    1391 <main+0x1e1>
lea    0x20(%rsp),%rbp
lea    0xd59(%rip),%r14
xor    %ebx,%ebx
xor    %eax,%eax
jmp    12d4 <main+0x124>
nopl   (%rax)
mov    0x2d29(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    0x18(%rsp),%eax
add    $0x1,%eax
cmp    0xc(%rsp),%eax
je     1393 <main+0x1e3>
mov    %eax,0x18(%rsp)
jmp    12ef <main+0x13f>
nopw   0x0(%rax,%rax,1)
lea    0xddc(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
mov    %r15,%rdi
mov    %rbp,%rsi
call   10c0 <get_next_file_name@plt>
cmpb   $0x0,0x20(%rsp)
je     12b0 <main+0x100>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12e0 <main+0x130>
mov    %rax,%r12
mov    %r13d,%edi
mov    %rax,%rsi
call   1040 <set_audio_config@plt>
test   %rax,%rax
js     1360 <main+0x1b0>
mov    0x1c(%rsp),%eax
mov    %eax,%ebp
test   %eax,%eax
jle    1342 <main+0x192>
xchg   %ax,%ax
mov    %r13d,%edi
mov    %r12,%rsi
call   1050 <play_file@plt>
add    %eax,%ebx
add    $0xffffffff,%ebp
jne    1330 <main+0x180>
mov    %r12,%rdi
call   1060 <fclose@plt>
lea    0x20(%rsp),%rbp
jmp    12ef <main+0x13f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xcdf(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
add    $0x1,%ebx
jmp    12ef <main+0x13f>
lea    0xc89(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    13e5 <main+0x235>
xor    %ebx,%ebx
lea    0xce9(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r13d,%edi
call   1080 <close@plt>
cmpl   $0x2,0x14(%rsp)
jne    13bf <main+0x20f>
mov    0x10(%rsp),%edi
call   1080 <close@plt>
test   %ebx,%ebx
jne    13ed <main+0x23d>
lea    0xcdb(%rip),%rdi
jmp    11f6 <main+0x46>
lea    0xc5d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
call   1080 <close@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
lea    0xc71(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%eax
add    $0x128,%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 = [109 x i8] c"main <ssi_nb> <playlist.txt> <file_loops> <list_loop> [device]\0A Play files to /dev/dspX (uncompressed data)\0A\00"
@.str.2 = [26 x i8] c"ssi_nb : 1 for SSI1 ... \0A\00"
@.str.3 = [39 x i8] c"device : 0 for StDac, 1 for Codec... \0A\00"
@O_WRONLY = global i32 0
@O_RDWR = global i32 0
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [15 x i8] c"/dev/sound/dsp\00"
@.str.6 = [18 x i8] c"Error opening dsp\00"
@.str.7 = [16 x i8] c"/dev/sound/dsp1\00"
@.str.8 = [19 x i8] c"Error opening dsp1\00"
@.str.9 = [30 x i8] c"Error at file opening. Skip.\0A\00"
@.str.10 = [31 x i8] c"Bad format for file %s. Skip.\0A\00"
@SEEK_SET = global i32 0
@.str.11 = [35 x i8] c"************** Closing the device\0A\00"
@.str.12 = [31 x i8] c"All tests passed with success\0A\00"
@.str.13 = [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 i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %181
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %13
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %15
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 6
br i1 %35, label %36, label %47
36: ; preds = %25
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 5
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* @O_WRONLY
store i32 %43, i32* %10
br label %46
44: ; preds = %36
%45 = load i32, i32* @O_RDWR
store i32 %45, i32* %10
br label %46
46: ; preds = %44, %42
br label %49
47: ; preds = %25
%48 = load i32, i32* @O_WRONLY
store i32 %48, i32* %10
br label %49
49: ; preds = %47, %46
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %53, i32** %7
%54 = icmp ule i32* %53, null
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = load i32, i32* %16
%57 = add nsw i32 %56, 1
store i32 %57, i32* %16
br label %177
58: ; preds = %49
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32 @atoi(i8* %61)
store i32 %62, i32* %14
%63 = load i32, i32* @O_WRONLY
%64 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %63)
store i32 %64, i32* %8
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %58
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%68 = load i32, i32* %16
%69 = add nsw i32 %68, 1
store i32 %69, i32* %16
br label %173
70: ; preds = %58
%71 = load i32, i32* %14
%72 = icmp eq i32 %71, 2
br i1 %72, label %73, label %83
73: ; preds = %70
%74 = load i32, i32* %8
store i32 %74, i32* %9
%75 = load i32, i32* @O_WRONLY
%76 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %75)
store i32 %76, i32* %8
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %73
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%80 = load i32, i32* %16
%81 = add nsw i32 %80, 1
store i32 %81, i32* %16
br label %170
82: ; preds = %73
br label %83
83: ; preds = %82, %70
store i32 0, i32* %12
br label %84
84: ; preds = %150, %83
%85 = load i32, i32* %12
%86 = load i32, i32* %15
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %153
88: ; preds = %84
%89 = load i32*, i32** %7
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%91 = call i32 @get_next_file_name(i32* %89, i8* %90)
br label %92
92: ; preds = %142, %102, %88
%93 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %146
97: ; preds = %92
%98 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %103
102: ; preds = %97
br label %92
103: ; preds = %97
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%105 = call i32* @fopen(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %105, i32** %6
%106 = icmp ule i32* %105, null
br i1 %106, label %107, label %111
107: ; preds = %103
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%109 = load i32, i32* %16
%110 = add nsw i32 %109, 1
store i32 %110, i32* %16
br label %142
111: ; preds = %103
%112 = load i32, i32* %8
%113 = load i32*, i32** %6
%114 = call i64 @set_audio_config(i32 %112, i32* %113)
%115 = icmp slt i64 %114, 0
br i1 %115, label %116, label %123
116: ; preds = %111
%117 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %117)
%119 = load i32*, i32** %6
%120 = call i32 @fclose(i32* %119)
%121 = load i32, i32* %16
%122 = add nsw i32 %121, 1
store i32 %122, i32* %16
br label %142
123: ; preds = %111
store i32 0, i32* %11
br label %124
124: ; preds = %136, %123
%125 = load i32, i32* %11
%126 = load i32, i32* %13
%127 = icmp slt i32 %125, %126
br i1 %127, label %128, label %139
128: ; preds = %124
%129 = load i32, i32* %8
%130 = load i32*, i32** %6
%131 = call i64 @play_file(i32 %129, i32* %130)
%132 = load i32, i32* %16
%133 = sext i32 %132 to i64
%134 = add nsw i64 %133, %131
%135 = trunc i64 %134 to i32
store i32 %135, i32* %16
br label %136
136: ; preds = %128
%137 = load i32, i32* %11
%138 = add nsw i32 %137, 1
store i32 %138, i32* %11
br label %124
139: ; preds = %124
%140 = load i32*, i32** %6
%141 = call i32 @fclose(i32* %140)
br label %142
142: ; preds = %139, %116, %107
%143 = load i32*, i32** %7
%144 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%145 = call i32 @get_next_file_name(i32* %143, i8* %144)
br label %92
146: ; preds = %92
%147 = load i32*, i32** %7
%148 = load i32, i32* @SEEK_SET
%149 = call i32 @fseek(i32* %147, i32 0, i32 %148)
br label %150
150: ; preds = %146
%151 = load i32, i32* %12
%152 = add nsw i32 %151, 1
store i32 %152, i32* %12
br label %84
153: ; preds = %84
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
%155 = load i32*, i32** %7
%156 = call i32 @fclose(i32* %155)
%157 = load i32, i32* %8
%158 = call i32 @close(i32 %157)
%159 = load i32, i32* %14
%160 = icmp eq i32 %159, 2
br i1 %160, label %161, label %164
161: ; preds = %153
%162 = load i32, i32* %9
%163 = call i32 @close(i32 %162)
br label %164
164: ; preds = %161, %153
%165 = load i32, i32* %16
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %168
167: ; preds = %164
br label %176
168: ; preds = %164
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %3
br label %181
170: ; preds = %78
%171 = load i32, i32* %8
%172 = call i32 @close(i32 %171)
br label %173
173: ; preds = %170, %66
%174 = load i32*, i32** %7
%175 = call i32 @fclose(i32* %174)
br label %176
176: ; preds = %173, %167
br label %177
177: ; preds = %176, %55
%178 = load i32, i32* %16
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i32 %178)
%180 = load i32, i32* %16
store i32 %180, i32* %3
br label %181
181: ; preds = %177, %168, %21
%182 = load i32, i32* %3
ret i32 %182
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_RDWR = global i32 0
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [15 x i8] c"/dev/sound/dsp\00"
@.str.6 = [18 x i8] c"Error opening dsp\00"
@.str.7 = [16 x i8] c"/dev/sound/dsp1\00"
@.str.8 = [19 x i8] c"Error opening dsp1\00"
@.str.10 = [31 x i8] c"Bad format for file %s. Skip.\0A\00"
@SEEK_SET = global i32 0
@.str.13 = [23 x i8] c"Encountered %d errors\0A\00"
@str = [7 x i8] c"Hi... \00"
@str.14 = [34 x i8] c"************** Closing the device\00"
@str.15 = [30 x i8] c"All tests passed with success\00"
@str.16 = [29 x i8] c"Error at file opening. Skip.\00"
@str.17 = [108 x i8] c"main <ssi_nb> <playlist.txt> <file_loops> <list_loop> [device]\0A Play files to /dev/dspX (uncompressed data)\00"
@str.18 = [25 x i8] c"ssi_nb : 1 for SSI1 ... \00"
@str.19 = [38 x i8] c"device : 0 for StDac, 1 for Codec... \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 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 ([108 x i8], [108 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.18, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.19, i64 0, i64 0))
br label %104
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %101, label %22
22: ; preds = %11
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = load i32, i32* @O_WRONLY
%27 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %99
31: ; preds = %22
%32 = icmp eq i32 %25, 2
br i1 %32, label %33, label %40
33: ; preds = %31
%34 = load i32, i32* @O_WRONLY
%35 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%39 = tail call i32 @close(i32 %35)
br label %99
40: ; preds = %33, %31
%41 = phi i32 [ %35, %33 ], [ %27, %31 ]
%42 = icmp sgt i32 %17, 0
br i1 %42, label %43, label %88
43: ; preds = %40
%44 = icmp sgt i32 %14, 0
br label %45
45: ; preds = %43, %82
%46 = phi i32 [ 0, %43 ], [ %83, %82 ]
%47 = phi i32 [ 0, %43 ], [ %86, %82 ]
%48 = call i32 @get_next_file_name(i32* %20, i8* %4)
%49 = load i8, i8* %4
%50 = icmp eq i8 %49, 0
br i1 %50, label %82, label %51
51: ; preds = %45, %77
%52 = phi i32 [ %78, %77 ], [ %46, %45 ]
%53 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.16, i64 0, i64 0))
%57 = add nsw i32 %52, 1
br label %77
58: ; preds = %51
%59 = call i64 @set_audio_config(i32 %41, i32* %53)
%60 = icmp slt i64 %59, 0
br i1 %60, label %62, label %61
61: ; preds = %58
br i1 %44, label %66, label %74
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %4)
%64 = call i32 @fclose(i32* %53)
%65 = add nsw i32 %52, 1
br label %77
66: ; preds = %61, %66
%67 = phi i32 [ %71, %66 ], [ %52, %61 ]
%68 = phi i32 [ %72, %66 ], [ 0, %61 ]
%69 = call i64 @play_file(i32 %41, i32* %53)
%70 = trunc i64 %69 to i32
%71 = add i32 %67, %70
%72 = add nuw nsw i32 %68, 1
%73 = icmp eq i32 %72, %14
br i1 %73, label %74, label %66
74: ; preds = %66, %61
%75 = phi i32 [ %52, %61 ], [ %71, %66 ]
%76 = call i32 @fclose(i32* %53)
br label %77
77: ; preds = %74, %62, %55
%78 = phi i32 [ %57, %55 ], [ %65, %62 ], [ %75, %74 ]
%79 = call i32 @get_next_file_name(i32* %20, i8* %4)
%80 = load i8, i8* %4
%81 = icmp eq i8 %80, 0
br i1 %81, label %82, label %51
82: ; preds = %77, %45
%83 = phi i32 [ %46, %45 ], [ %78, %77 ]
%84 = load i32, i32* @SEEK_SET
%85 = call i32 @fseek(i32* %20, i32 0, i32 %84)
%86 = add nuw nsw i32 %47, 1
%87 = icmp eq i32 %86, %17
br i1 %87, label %88, label %45
88: ; preds = %82, %40
%89 = phi i32 [ 0, %40 ], [ %83, %82 ]
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.14, i64 0, i64 0))
%91 = call i32 @fclose(i32* %20)
%92 = call i32 @close(i32 %41)
br i1 %32, label %93, label %95
93: ; preds = %88
%94 = call i32 @close(i32 %27)
br label %95
95: ; preds = %93, %88
%96 = icmp eq i32 %89, 0
br i1 %96, label %97, label %101
97: ; preds = %95
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.15, i64 0, i64 0))
br label %104
99: ; preds = %37, %29
%100 = tail call i32 @fclose(i32* %20)
br label %101
101: ; preds = %11, %99, %95
%102 = phi i32 [ 1, %99 ], [ %89, %95 ], [ 1, %11 ]
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i32 %102)
br label %104
104: ; preds = %101, %97, %7
%105 = phi i32 [ 0, %7 ], [ %102, %101 ], [ 0, %97 ]
ret i32 %105
}