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

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int atoi(char *);
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int main(int ac, char *av[]) {
  int fd_audio[4], i, j, tmp, err, toterr, inst_num;
  char drv_name[32];
  printf("Hi... \n");
  if (ac == 1) {
    printf("This program checks that it is possible to open only once a driver "
           "instance\n");
    printf(
        "and that it is possible to open all the driver instances at a time\n");
    printf("-> %s <supported_driver_instance_number>\n\n", av[0]);
    return 0;
  }
  inst_num = atoi(av[1]);
  if (inst_num > 4) {
    printf("Sounds like too many instances.\n");
    inst_num = 4;
    printf("Will check till #%i. Change limitation in source and recompile if "
           "needed...\n",
           inst_num);
  }
  for (i = 0; i < 4; i++)
    fd_audio[i] = 0;
  for (i = 0, toterr = 0; i < inst_num; i++) {
    if (i == 0)
      sprintf(drv_name, "/dev/sound/dsp");
    else
      sprintf(drv_name, "/dev/sound/dsp%i", i);
    for (j = 0, err = 0; j < 3; j++) {
      if ((tmp = open(drv_name, O_WRONLY)) < 0) {
        if (j == 0) {
          printf("Error at first opening %s\n", drv_name);
          err++;
          break;
        }
      } else {
        if (j == 0)
          fd_audio[i] = tmp;
        else {
          printf("Error : driver re-opened\n");
          close(tmp);
          err++;
          break;
        }
      }
    }
    if (!err)
      printf("Test passed successfully for %s\n", drv_name);
    toterr += err;
  }
  printf("All driver opened. Now, close them\n");
  sleep(1);
  for (i = 0; i < inst_num; i++) {
    if (fd_audio[i])
      close(fd_audio[i]);
  }
  if (!toterr)
    printf("\n --> All the tests were passed successfully\n");
  else
    printf("\nEncountered %i errors\n", toterr);
  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)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11cb <main+0x6b>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1403 <main+0x2a3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x4,-0x38(%rbp)
jle    120b <main+0xab>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1236 <main+0xd6>
movslq -0x24(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1212 <main+0xb2>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1374 <main+0x214>
cmpl   $0x0,-0x24(%rbp)
jne    1271 <main+0x111>
lea    -0x60(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1286 <main+0x126>
lea    -0x60(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    1341 <main+0x1e1>
lea    -0x60(%rbp),%rdi
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    12eb <main+0x18b>
cmpl   $0x0,-0x28(%rbp)
jne    12e6 <main+0x186>
lea    -0x60(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1341 <main+0x1e1>
jmp    132e <main+0x1ce>
cmpl   $0x0,-0x28(%rbp)
jne    1305 <main+0x1a5>
mov    -0x2c(%rbp),%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    1329 <main+0x1c9>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1040 <close@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1341 <main+0x1e1>
jmp    132e <main+0x1ce>
jmp    1333 <main+0x1d3>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1294 <main+0x134>
cmpl   $0x0,-0x30(%rbp)
jne    135d <main+0x1fd>
lea    -0x60(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1244 <main+0xe4>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    13ce <main+0x26e>
movslq -0x24(%rbp),%rax
cmpl   $0x0,-0x20(%rbp,%rax,4)
je     13bb <main+0x25b>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1040 <close@plt>
jmp    13c0 <main+0x260>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1393 <main+0x233>
cmpl   $0x0,-0x34(%rbp)
jne    13eb <main+0x28b>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13fc <main+0x29c>
mov    -0x34(%rbp),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-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    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xf62(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%ebp
jne    11c2 <main+0x52>
lea    0xfe1(%rip),%rdi
call   1030 <puts@plt>
lea    0x1021(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    140e <main+0x29e>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
cmp    $0x5,%eax
jl     11ff <main+0x8f>
lea    0xf85(%rip),%rdi
call   1030 <puts@plt>
lea    0xe48(%rip),%rdi
mov    $0x4,%r15d
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
jmp    1212 <main+0xa2>
mov    %eax,%r15d
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
test   %eax,%eax
jle    1396 <main+0x226>
movabs $0x7073642f646e75,%rax
mov    %rax,0x27(%rsp)
movabs $0x756f732f7665642f,%rax
73 6f 75
mov    %rax,0x20(%rsp)
mov    0x2da1(%rip),%r14
mov    (%r14),%esi
lea    0x20(%rsp),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     128d <main+0x11d>
mov    %eax,%ebx
mov    %eax,0x10(%rsp)
mov    (%r14),%esi
lea    0x20(%rsp),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1278 <main+0x108>
mov    (%r14),%esi
lea    0x20(%rsp),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     141f <main+0x2af>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1050 <close@plt>
jmp    12a2 <main+0x132>
lea    0xe04(%rip),%rdi
xor    %ebx,%ebx
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r12d
mov    $0x1,%bpl
cmp    $0x1,%r15d
jne    12bc <main+0x14c>
mov    $0x1,%r15d
jmp    139d <main+0x22d>
mov    %ebx,0x8(%rsp)
mov    %r15d,0xc(%rsp)
mov    %r15d,%eax
mov    %rax,0x40(%rsp)
mov    $0x1,%ebp
lea    0x20(%rsp),%r13
jmp    1308 <main+0x198>
nopl   0x0(%rax)
lea    0xdb1(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
add    %ebx,%r12d
add    $0x1,%rbp
cmp    %rbp,0x40(%rsp)
je     1388 <main+0x218>
mov    %r13,%rdi
lea    0xd75(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    (%r14),%esi
mov    %r13,%rdi
call   1060 <open@plt>
test   %eax,%eax
js     12e0 <main+0x170>
mov    %eax,0x10(%rsp,%rbp,4)
mov    %r14,%r15
mov    (%r14),%esi
mov    %r13,%rdi
call   1060 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1355 <main+0x1e5>
mov    (%r15),%esi
mov    %r13,%rdi
call   1060 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
js     1373 <main+0x203>
lea    0xde7(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
call   1050 <close@plt>
mov    $0x1,%ebx
mov    %r15,%r14
jmp    12f6 <main+0x186>
xor    %ebx,%ebx
lea    0xd37(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    136e <main+0x1fe>
mov    0xc(%rsp),%r15d
mov    0x8(%rsp),%ebx
mov    $0x1,%bpl
jmp    139d <main+0x22d>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r12d,%r12d
lea    0xd4f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
test   %bpl,%bpl
je     13ea <main+0x27a>
mov    %r15d,%r14d
mov    $0x1,%ebp
test   %ebx,%ebx
je     13d7 <main+0x267>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1050 <close@plt>
cmp    %rbp,%r14
je     13ea <main+0x27a>
mov    0x10(%rsp,%rbp,4),%ebx
add    $0x1,%rbp
test   %ebx,%ebx
jne    13d0 <main+0x260>
jmp    13d7 <main+0x267>
test   %r12d,%r12d
je     1402 <main+0x292>
lea    0xcde(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    140e <main+0x29e>
lea    0xd0d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc8d(%rip),%rdi
xor    %r12d,%r12d
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a8 <main+0x138>

LLVM IR (-O0):
@.str = [8 x i8] c"Hi... \0A\00"
@.str.1 = [77 x i8] c"This program checks that it is possible to open only once a driver instance\0A\00"
@.str.2 = [68 x i8] c"and that it is possible to open all the driver instances at a time\0A\00"
@.str.3 = [43 x i8] c"-> %s <supported_driver_instance_number>\0A\0A\00"
@.str.4 = [33 x i8] c"Sounds like too many instances.\0A\00"
@.str.5 = [77 x i8] c"Will check till #%i. Change limitation in source and recompile if needed...\0A\00"
@.str.6 = [15 x i8] c"/dev/sound/dsp\00"
@.str.7 = [17 x i8] c"/dev/sound/dsp%i\00"
@O_WRONLY = global i32 0
@.str.8 = [27 x i8] c"Error at first opening %s\0A\00"
@.str.9 = [26 x i8] c"Error : driver re-opened\0A\00"
@.str.10 = [33 x i8] c"Test passed successfully for %s\0A\00"
@.str.11 = [36 x i8] c"All driver opened. Now, close them\0A\00"
@.str.12 = [46 x i8] c"\0A --> All the tests were passed successfully\0A\00"
@.str.13 = [24 x i8] c"\0AEncountered %i errors\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %22)
store i32 0, i32* %3
br label %143
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %12
%29 = load i32, i32* %12
%30 = icmp sgt i32 %29, 4
br i1 %30, label %31, label %35
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 4, i32* %12
%33 = load i32, i32* %12
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %31, %24
store i32 0, i32* %7
br label %36
36: ; preds = %43, %35
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 4
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %41
store i32 0, i32* %42
br label %43
43: ; preds = %39
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %36
46: ; preds = %36
store i32 0, i32* %7
store i32 0, i32* %11
br label %47
47: ; preds = %108, %46
%48 = load i32, i32* %7
%49 = load i32, i32* %12
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %111
51: ; preds = %47
%52 = load i32, i32* %7
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* %55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %61
57: ; preds = %51
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%59 = load i32, i32* %7
%60 = call i32 (i8*, i8*, ...) @sprintf(i8* %58, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %57, %54
store i32 0, i32* %8
store i32 0, i32* %10
br label %62
62: ; preds = %95, %61
%63 = load i32, i32* %8
%64 = icmp slt i32 %63, 3
br i1 %64, label %65, label %98
65: ; preds = %62
%66 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%67 = load i32, i32* @O_WRONLY
%68 = call i32 @open(i8* %66, i32 %67)
store i32 %68, i32* %9
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %79
70: ; preds = %65
%71 = load i32, i32* %8
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %70
%74 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %74)
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
br label %98
78: ; preds = %70
br label %94
79: ; preds = %65
%80 = load i32, i32* %8
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %87
82: ; preds = %79
%83 = load i32, i32* %9
%84 = load i32, i32* %7
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %85
store i32 %83, i32* %86
br label %93
87: ; preds = %79
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%89 = load i32, i32* %9
%90 = call i32 @close(i32 %89)
%91 = load i32, i32* %10
%92 = add nsw i32 %91, 1
store i32 %92, i32* %10
br label %98
93: ; preds = %82
br label %94
94: ; preds = %93, %78
br label %95
95: ; preds = %94
%96 = load i32, i32* %8
%97 = add nsw i32 %96, 1
store i32 %97, i32* %8
br label %62
98: ; preds = %87, %73, %62
%99 = load i32, i32* %10
%100 = icmp ne i32 %99, 0
br i1 %100, label %104, label %101
101: ; preds = %98
%102 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %102)
br label %104
104: ; preds = %101, %98
%105 = load i32, i32* %10
%106 = load i32, i32* %11
%107 = add nsw i32 %106, %105
store i32 %107, i32* %11
br label %108
108: ; preds = %104
%109 = load i32, i32* %7
%110 = add nsw i32 %109, 1
store i32 %110, i32* %7
br label %47
111: ; preds = %47
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
%113 = call i32 @sleep(i32 1)
store i32 0, i32* %7
br label %114
114: ; preds = %131, %111
%115 = load i32, i32* %7
%116 = load i32, i32* %12
%117 = icmp slt i32 %115, %116
br i1 %117, label %118, label %134
118: ; preds = %114
%119 = load i32, i32* %7
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %120
%122 = load i32, i32* %121
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %130
124: ; preds = %118
%125 = load i32, i32* %7
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %126
%128 = load i32, i32* %127
%129 = call i32 @close(i32 %128)
br label %130
130: ; preds = %124, %118
br label %131
131: ; preds = %130
%132 = load i32, i32* %7
%133 = add nsw i32 %132, 1
store i32 %133, i32* %7
br label %114
134: ; preds = %114
%135 = load i32, i32* %11
%136 = icmp ne i32 %135, 0
br i1 %136, label %139, label %137
137: ; preds = %134
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0))
br label %142
139: ; preds = %134
%140 = load i32, i32* %11
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i32 %140)
br label %142
142: ; preds = %139, %137
store i32 0, i32* %3
br label %143
143: ; preds = %142, %17
%144 = load i32, i32* %3
ret i32 %144
}

LLVM IR (-O2):
@.str.3 = [43 x i8] c"-> %s <supported_driver_instance_number>\0A\0A\00"
@.str.5 = [77 x i8] c"Will check till #%i. Change limitation in source and recompile if needed...\0A\00"
@.str.6 = [15 x i8] c"/dev/sound/dsp\00"
@.str.7 = [17 x i8] c"/dev/sound/dsp%i\00"
@O_WRONLY = global i32 0
@.str.8 = [27 x i8] c"Error at first opening %s\0A\00"
@.str.10 = [33 x i8] c"Test passed successfully for %s\0A\00"
@.str.13 = [24 x i8] c"\0AEncountered %i errors\0A\00"
@str = [7 x i8] c"Hi... \00"
@str.14 = [35 x i8] c"All driver opened. Now, close them\00"
@str.15 = [45 x i8] c"\0A --> All the tests were passed successfully\00"
@str.16 = [25 x i8] c"Error : driver re-opened\00"
@str.17 = [32 x i8] c"Sounds like too many instances.\00"
@str.18 = [76 x i8] c"This program checks that it is possible to open only once a driver instance\00"
@str.19 = [67 x i8] c"and that it is possible to open all the driver instances at a time\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%8 = icmp eq i32 %0, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str.18, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.19, i64 0, i64 0))
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %12)
br label %108
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp sgt i32 %17, 4
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.17, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.5, i64 0, i64 0), i32 4)
br label %24
22: ; preds = %14
%23 = icmp sgt i32 %17, 0
br i1 %23, label %24, label %81
24: ; preds = %19, %22
%25 = phi i32 [ 4, %19 ], [ %17, %22 ]
%26 = zext i32 %25 to i64
%27 = load i32, i32* @O_WRONLY
%28 = call i32 @open(i8* %6, i32 %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %45, label %30
30: ; preds = %24
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 %28, i32* %31
%32 = load i32, i32* @O_WRONLY
%33 = call i32 @open(i8* %6, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load i32, i32* @O_WRONLY
%37 = call i32 @open(i8* %6, i32 %36)
%38 = icmp slt i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35, %30
%40 = phi i32 [ %33, %30 ], [ %37, %35 ]
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%42 = call i32 @close(i32 %40)
br label %47
43: ; preds = %35
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %6)
br label %47
45: ; preds = %24
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %6)
br label %47
47: ; preds = %45, %43, %39
%48 = phi i32 [ %28, %43 ], [ %28, %39 ], [ 0, %45 ]
%49 = phi i32 [ 0, %43 ], [ 1, %39 ], [ 1, %45 ]
%50 = icmp eq i32 %25, 1
br i1 %50, label %81, label %51
51: ; preds = %47, %76
%52 = phi i64 [ %79, %76 ], [ 1, %47 ]
%53 = phi i32 [ %78, %76 ], [ %49, %47 ]
%54 = trunc i64 %52 to i32
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %54)
%56 = load i32, i32* @O_WRONLY
%57 = call i32 @open(i8* %6, i32 %56)
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %51
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %6)
br label %76
61: ; preds = %70, %65
%62 = phi i32 [ %68, %65 ], [ %72, %70 ]
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%64 = call i32 @close(i32 %62)
br label %76
65: ; preds = %51
%66 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %52
store i32 %57, i32* %66
%67 = load i32, i32* @O_WRONLY
%68 = call i32 @open(i8* %6, i32 %67)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %61
70: ; preds = %65
%71 = load i32, i32* @O_WRONLY
%72 = call i32 @open(i8* %6, i32 %71)
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %61
74: ; preds = %70
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %6)
br label %76
76: ; preds = %59, %61, %74
%77 = phi i32 [ 0, %74 ], [ 1, %61 ], [ 1, %59 ]
%78 = add nuw nsw i32 %77, %53
%79 = add nuw nsw i64 %52, 1
%80 = icmp eq i64 %79, %26
br i1 %80, label %81, label %51
81: ; preds = %76, %47, %22
%82 = phi i1 [ false, %22 ], [ true, %47 ], [ true, %76 ]
%83 = phi i32 [ %17, %22 ], [ 1, %47 ], [ %25, %76 ]
%84 = phi i32 [ 0, %22 ], [ %48, %47 ], [ %48, %76 ]
%85 = phi i32 [ 0, %22 ], [ %49, %47 ], [ %78, %76 ]
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0))
%87 = call i32 @sleep(i32 1)
br i1 %82, label %88, label %102
88: ; preds = %81
%89 = zext i32 %83 to i64
br label %90
90: ; preds = %99, %88
%91 = phi i32 [ %84, %88 ], [ %101, %99 ]
%92 = phi i64 [ 0, %88 ], [ %97, %99 ]
%93 = icmp eq i32 %91, 0
br i1 %93, label %96, label %94
94: ; preds = %90
%95 = call i32 @close(i32 %91)
br label %96
96: ; preds = %90, %94
%97 = add nuw nsw i64 %92, 1
%98 = icmp eq i64 %97, %89
br i1 %98, label %102, label %99
99: ; preds = %96
%100 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %97
%101 = load i32, i32* %100
br label %90
102: ; preds = %96, %81
%103 = icmp eq i32 %85, 0
br i1 %103, label %104, label %106
104: ; preds = %102
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.15, i64 0, i64 0))
br label %108
106: ; preds = %102
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i32 %85)
br label %108
108: ; preds = %104, %106, %9
ret i32 0
}