#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_RDONLY;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int ac, char *av[]) {
  int fd_audio[2], i, err;
  err = 0;
  printf("Hi... \n");
  printf("This program checks that it is possible to open the driver for 2W "
         "and 1R \n");
  printf("-> main <no arg>\n\n");
  for (i = 0; i < 2; i++) {
    fd_audio[i] = -1;
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_RDWR)) < 0) {
    printf("[2 open in RDWR] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_RDWR)) >= 0) {
    printf("[2 open in RDWR] Error : 2RW allowed\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i] >= 0) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_WRONLY)) < 0) {
    printf("[2 open in WR] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_WRONLY)) < 0) {
    printf("[2 open in WR] Error at second opening\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i] >= 0) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_RDONLY)) < 0) {
    printf("[2 open in RD] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_RDONLY)) >= 0) {
    printf("[2 open in RD] Error : 2RW allowed\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i] >= 0) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_RDONLY)) < 0) {
    printf("[1 RD + 1 WR] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_WRONLY)) < 0) {
    printf("[1 RD + 1 WR] Error at second opening\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i] >= 0) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_RDWR)) < 0) {
    printf("[1 RDWR + 1 WR] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_WRONLY)) < 0) {
    printf("[1 RDWR + 1 WR] Error at second opening\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i] >= 0) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_RDONLY)) < 0) {
    printf("[1 RD + 1 RDWR] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_RDWR)) >= 0) {
    printf("[1 RD + 1 RDWR] Error : second opening should fail\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i]) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if ((fd_audio[0] = open("/dev/sound/dsp", O_RDWR)) < 0) {
    printf("[1 RDWR + 1 RD] Error at first opening\n");
    err++;
  }
  if ((fd_audio[1] = open("/dev/sound/dsp1", O_RDONLY)) >= 0) {
    printf("[1 RDWR + 1 RD] Error : second opening should fail\n");
    err++;
  }
  for (i = 0; i < 2; i++) {
    if (fd_audio[i] >= 0) {
      close(fd_audio[i]);
      fd_audio[i] = -1;
    }
  }
  if (err == 0) {
    printf("\n --> All the tests were passed successfully\n");
  } else {
    printf("\nEncountered %i errors\n", err);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11a2 <main+0x72>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <main+0x4e>
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
lea    0xeb4(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    11da <main+0xaa>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    0xeb4(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     1212 <main+0xe2>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    125e <main+0x12e>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
jl     124b <main+0x11b>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    1250 <main+0x120>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1219 <main+0xe9>
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
lea    0xdf8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1296 <main+0x166>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
lea    0xdf8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12ce <main+0x19e>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    131a <main+0x1ea>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
jl     1307 <main+0x1d7>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    130c <main+0x1dc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12d5 <main+0x1a5>
mov    0x2cbf(%rip),%rax
mov    (%rax),%esi
lea    0xd3c(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1352 <main+0x222>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2c87(%rip),%rax
mov    (%rax),%esi
lea    0xd3c(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     138a <main+0x25a>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    13d6 <main+0x2a6>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
jl     13c3 <main+0x293>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    13c8 <main+0x298>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1391 <main+0x261>
mov    0x2c03(%rip),%rax
mov    (%rax),%esi
lea    0xc80(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    140e <main+0x2de>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2bb3(%rip),%rax
mov    (%rax),%esi
lea    0xc80(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1446 <main+0x316>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1492 <main+0x362>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
jl     147f <main+0x34f>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    1484 <main+0x354>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    144d <main+0x31d>
mov    0x2b4f(%rip),%rax
mov    (%rax),%esi
lea    0xbc4(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    14ca <main+0x39a>
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2af7(%rip),%rax
mov    (%rax),%esi
lea    0xbc4(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1502 <main+0x3d2>
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    154e <main+0x41e>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
jl     153b <main+0x40b>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    1540 <main+0x410>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1509 <main+0x3d9>
mov    0x2a8b(%rip),%rax
mov    (%rax),%esi
lea    0xb08(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1586 <main+0x456>
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2a5b(%rip),%rax
mov    (%rax),%esi
lea    0xb08(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     15be <main+0x48e>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    160a <main+0x4da>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
je     15f7 <main+0x4c7>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    15fc <main+0x4cc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    15c5 <main+0x495>
mov    0x29d7(%rip),%rax
mov    (%rax),%esi
lea    0xa4c(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1642 <main+0x512>
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2997(%rip),%rax
mov    (%rax),%esi
lea    0xa4c(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     167a <main+0x54a>
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    16c6 <main+0x596>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x18(%rbp,%rax,4)
jl     16b3 <main+0x583>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%edi
call   1040 <close@plt>
movslq -0x1c(%rbp),%rax
movl   $0xffffffff,-0x18(%rbp,%rax,4)
ff
jmp    16b8 <main+0x588>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1681 <main+0x551>
cmpl   $0x0,-0x20(%rbp)
jne    16e3 <main+0x5b3>
lea    0xbed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    16f4 <main+0x5c4>
mov    -0x20(%rbp),%esi
lea    0xc05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e72(%rip),%r15
mov    (%r15),%esi
lea    0xe80(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
xor    %r14d,%r14d
test   %eax,%eax
jns    11a0 <main+0x60>
lea    0x113b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
mov    (%r15),%esi
lea    0xe65(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     11c5 <main+0x85>
lea    0x10ef(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
js     11d0 <main+0x90>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
js     11db <main+0x9b>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2de6(%rip),%r13
mov    0x0(%r13),%esi
lea    0xe13(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1208 <main+0xc8>
lea    0x1086(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    0x0(%r13),%esi
lea    0xdfc(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1426 <main+0x2e6>
test   %ebp,%ebp
js     122d <main+0xed>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
js     1238 <main+0xf8>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2da1(%rip),%r12
mov    (%r12),%esi
lea    0xdb6(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1265 <main+0x125>
lea    0xfdc(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    (%r12),%esi
lea    0xd9f(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     128b <main+0x14b>
lea    0xf93(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
js     1296 <main+0x156>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
js     12a1 <main+0x161>
mov    %ebx,%edi
call   1050 <close@plt>
mov    (%r12),%esi
lea    0xd54(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12c7 <main+0x187>
lea    0xf32(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    0x0(%r13),%esi
lea    0xd3d(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1443 <main+0x303>
test   %ebp,%ebp
js     12ec <main+0x1ac>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
js     12f7 <main+0x1b7>
mov    %ebx,%edi
call   1050 <close@plt>
mov    (%r15),%esi
lea    0xcff(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    131c <main+0x1dc>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    0x0(%r13),%esi
lea    0xce8(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1460 <main+0x320>
test   %ebp,%ebp
js     1341 <main+0x201>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
js     134c <main+0x20c>
mov    %ebx,%edi
call   1050 <close@plt>
mov    (%r12),%esi
lea    0xca9(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1372 <main+0x232>
lea    0xdeb(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    (%r15),%esi
lea    0xc93(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1397 <main+0x257>
lea    0xd93(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
je     13a2 <main+0x262>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
je     13ad <main+0x26d>
mov    %ebx,%edi
call   1050 <close@plt>
mov    (%r15),%esi
lea    0xc49(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    13d2 <main+0x292>
lea    0xd31(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
mov    (%r12),%esi
lea    0xc32(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     13f8 <main+0x2b8>
lea    0xcd8(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
js     1403 <main+0x2c3>
mov    %ebp,%edi
call   1050 <close@plt>
test   %ebx,%ebx
js     140e <main+0x2ce>
mov    %ebx,%edi
call   1050 <close@plt>
test   %r14d,%r14d
je     147d <main+0x33d>
lea    0xc05(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1489 <main+0x349>
lea    0xe31(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
jns    1226 <main+0xe6>
jmp    122d <main+0xed>
lea    0xd80(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
jns    12e5 <main+0x1a5>
jmp    12ec <main+0x1ac>
lea    0xd14(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14d
test   %ebp,%ebp
jns    133a <main+0x1fa>
jmp    1341 <main+0x201>
lea    0xc16(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%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 = [75 x i8] c"This program checks that it is possible to open the driver for 2W and 1R \0A\00"
@.str.2 = [19 x i8] c"-> main <no arg>\0A\0A\00"
@.str.3 = [15 x i8] c"/dev/sound/dsp\00"
@O_RDWR = global i32 0
@.str.4 = [41 x i8] c"[2 open in RDWR] Error at first opening\0A\00"
@.str.5 = [16 x i8] c"/dev/sound/dsp1\00"
@.str.6 = [38 x i8] c"[2 open in RDWR] Error : 2RW allowed\0A\00"
@O_WRONLY = global i32 0
@.str.7 = [39 x i8] c"[2 open in WR] Error at first opening\0A\00"
@.str.8 = [40 x i8] c"[2 open in WR] Error at second opening\0A\00"
@O_RDONLY = global i32 0
@.str.9 = [39 x i8] c"[2 open in RD] Error at first opening\0A\00"
@.str.10 = [36 x i8] c"[2 open in RD] Error : 2RW allowed\0A\00"
@.str.11 = [38 x i8] c"[1 RD + 1 WR] Error at first opening\0A\00"
@.str.12 = [39 x i8] c"[1 RD + 1 WR] Error at second opening\0A\00"
@.str.13 = [40 x i8] c"[1 RDWR + 1 WR] Error at first opening\0A\00"
@.str.14 = [41 x i8] c"[1 RDWR + 1 WR] Error at second opening\0A\00"
@.str.15 = [40 x i8] c"[1 RD + 1 RDWR] Error at first opening\0A\00"
@.str.16 = [52 x i8] c"[1 RD + 1 RDWR] Error : second opening should fail\0A\00"
@.str.17 = [40 x i8] c"[1 RDWR + 1 RD] Error at first opening\0A\00"
@.str.18 = [52 x i8] c"[1 RDWR + 1 RD] Error : second opening should fail\0A\00"
@.str.19 = [46 x i8] c"\0A --> All the tests were passed successfully\0A\00"
@.str.20 = [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 [2 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %12
12: ; preds = %19, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %17
store i32 -1, i32* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %12
22: ; preds = %12
%23 = load i32, i32* @O_RDWR
%24 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %24, i32* %25
%26 = icmp slt i32 %24, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %31
31: ; preds = %27, %22
%32 = load i32, i32* @O_RDWR
%33 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %33, i32* %34
%35 = icmp sge i32 %33, 0
br i1 %35, label %36, label %40
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %40
40: ; preds = %36, %31
store i32 0, i32* %7
br label %41
41: ; preds = %60, %40
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 2
br i1 %43, label %44, label %63
44: ; preds = %41
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = icmp sge i32 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %44
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = call i32 @close(i32 %54)
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %57
store i32 -1, i32* %58
br label %59
59: ; preds = %50, %44
br label %60
60: ; preds = %59
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %41
63: ; preds = %41
%64 = load i32, i32* @O_WRONLY
%65 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %65, i32* %66
%67 = icmp slt i32 %65, 0
br i1 %67, label %68, label %72
68: ; preds = %63
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
br label %72
72: ; preds = %68, %63
%73 = load i32, i32* @O_WRONLY
%74 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %73)
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %74, i32* %75
%76 = icmp slt i32 %74, 0
br i1 %76, label %77, label %81
77: ; preds = %72
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%79 = load i32, i32* %8
%80 = add nsw i32 %79, 1
store i32 %80, i32* %8
br label %81
81: ; preds = %77, %72
store i32 0, i32* %7
br label %82
82: ; preds = %101, %81
%83 = load i32, i32* %7
%84 = icmp slt i32 %83, 2
br i1 %84, label %85, label %104
85: ; preds = %82
%86 = load i32, i32* %7
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %87
%89 = load i32, i32* %88
%90 = icmp sge i32 %89, 0
br i1 %90, label %91, label %100
91: ; preds = %85
%92 = load i32, i32* %7
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %93
%95 = load i32, i32* %94
%96 = call i32 @close(i32 %95)
%97 = load i32, i32* %7
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %98
store i32 -1, i32* %99
br label %100
100: ; preds = %91, %85
br label %101
101: ; preds = %100
%102 = load i32, i32* %7
%103 = add nsw i32 %102, 1
store i32 %103, i32* %7
br label %82
104: ; preds = %82
%105 = load i32, i32* @O_RDONLY
%106 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %105)
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %106, i32* %107
%108 = icmp slt i32 %106, 0
br i1 %108, label %109, label %113
109: ; preds = %104
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%111 = load i32, i32* %8
%112 = add nsw i32 %111, 1
store i32 %112, i32* %8
br label %113
113: ; preds = %109, %104
%114 = load i32, i32* @O_RDONLY
%115 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %114)
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %115, i32* %116
%117 = icmp sge i32 %115, 0
br i1 %117, label %118, label %122
118: ; preds = %113
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%120 = load i32, i32* %8
%121 = add nsw i32 %120, 1
store i32 %121, i32* %8
br label %122
122: ; preds = %118, %113
store i32 0, i32* %7
br label %123
123: ; preds = %142, %122
%124 = load i32, i32* %7
%125 = icmp slt i32 %124, 2
br i1 %125, label %126, label %145
126: ; preds = %123
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = icmp sge i32 %130, 0
br i1 %131, label %132, label %141
132: ; preds = %126
%133 = load i32, i32* %7
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %134
%136 = load i32, i32* %135
%137 = call i32 @close(i32 %136)
%138 = load i32, i32* %7
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %139
store i32 -1, i32* %140
br label %141
141: ; preds = %132, %126
br label %142
142: ; preds = %141
%143 = load i32, i32* %7
%144 = add nsw i32 %143, 1
store i32 %144, i32* %7
br label %123
145: ; preds = %123
%146 = load i32, i32* @O_RDONLY
%147 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %146)
%148 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %147, i32* %148
%149 = icmp slt i32 %147, 0
br i1 %149, label %150, label %154
150: ; preds = %145
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
%152 = load i32, i32* %8
%153 = add nsw i32 %152, 1
store i32 %153, i32* %8
br label %154
154: ; preds = %150, %145
%155 = load i32, i32* @O_WRONLY
%156 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %155)
%157 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %156, i32* %157
%158 = icmp slt i32 %156, 0
br i1 %158, label %159, label %163
159: ; preds = %154
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0))
%161 = load i32, i32* %8
%162 = add nsw i32 %161, 1
store i32 %162, i32* %8
br label %163
163: ; preds = %159, %154
store i32 0, i32* %7
br label %164
164: ; preds = %183, %163
%165 = load i32, i32* %7
%166 = icmp slt i32 %165, 2
br i1 %166, label %167, label %186
167: ; preds = %164
%168 = load i32, i32* %7
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %169
%171 = load i32, i32* %170
%172 = icmp sge i32 %171, 0
br i1 %172, label %173, label %182
173: ; preds = %167
%174 = load i32, i32* %7
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %175
%177 = load i32, i32* %176
%178 = call i32 @close(i32 %177)
%179 = load i32, i32* %7
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %180
store i32 -1, i32* %181
br label %182
182: ; preds = %173, %167
br label %183
183: ; preds = %182
%184 = load i32, i32* %7
%185 = add nsw i32 %184, 1
store i32 %185, i32* %7
br label %164
186: ; preds = %164
%187 = load i32, i32* @O_RDWR
%188 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %187)
%189 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %188, i32* %189
%190 = icmp slt i32 %188, 0
br i1 %190, label %191, label %195
191: ; preds = %186
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0))
%193 = load i32, i32* %8
%194 = add nsw i32 %193, 1
store i32 %194, i32* %8
br label %195
195: ; preds = %191, %186
%196 = load i32, i32* @O_WRONLY
%197 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %196)
%198 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %197, i32* %198
%199 = icmp slt i32 %197, 0
br i1 %199, label %200, label %204
200: ; preds = %195
%201 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0))
%202 = load i32, i32* %8
%203 = add nsw i32 %202, 1
store i32 %203, i32* %8
br label %204
204: ; preds = %200, %195
store i32 0, i32* %7
br label %205
205: ; preds = %224, %204
%206 = load i32, i32* %7
%207 = icmp slt i32 %206, 2
br i1 %207, label %208, label %227
208: ; preds = %205
%209 = load i32, i32* %7
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %210
%212 = load i32, i32* %211
%213 = icmp sge i32 %212, 0
br i1 %213, label %214, label %223
214: ; preds = %208
%215 = load i32, i32* %7
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %216
%218 = load i32, i32* %217
%219 = call i32 @close(i32 %218)
%220 = load i32, i32* %7
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %221
store i32 -1, i32* %222
br label %223
223: ; preds = %214, %208
br label %224
224: ; preds = %223
%225 = load i32, i32* %7
%226 = add nsw i32 %225, 1
store i32 %226, i32* %7
br label %205
227: ; preds = %205
%228 = load i32, i32* @O_RDONLY
%229 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %228)
%230 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %229, i32* %230
%231 = icmp slt i32 %229, 0
br i1 %231, label %232, label %236
232: ; preds = %227
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.15, i64 0, i64 0))
%234 = load i32, i32* %8
%235 = add nsw i32 %234, 1
store i32 %235, i32* %8
br label %236
236: ; preds = %232, %227
%237 = load i32, i32* @O_RDWR
%238 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %237)
%239 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %238, i32* %239
%240 = icmp sge i32 %238, 0
br i1 %240, label %241, label %245
241: ; preds = %236
%242 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.16, i64 0, i64 0))
%243 = load i32, i32* %8
%244 = add nsw i32 %243, 1
store i32 %244, i32* %8
br label %245
245: ; preds = %241, %236
store i32 0, i32* %7
br label %246
246: ; preds = %265, %245
%247 = load i32, i32* %7
%248 = icmp slt i32 %247, 2
br i1 %248, label %249, label %268
249: ; preds = %246
%250 = load i32, i32* %7
%251 = sext i32 %250 to i64
%252 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %251
%253 = load i32, i32* %252
%254 = icmp ne i32 %253, 0
br i1 %254, label %255, label %264
255: ; preds = %249
%256 = load i32, i32* %7
%257 = sext i32 %256 to i64
%258 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %257
%259 = load i32, i32* %258
%260 = call i32 @close(i32 %259)
%261 = load i32, i32* %7
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %262
store i32 -1, i32* %263
br label %264
264: ; preds = %255, %249
br label %265
265: ; preds = %264
%266 = load i32, i32* %7
%267 = add nsw i32 %266, 1
store i32 %267, i32* %7
br label %246
268: ; preds = %246
%269 = load i32, i32* @O_RDWR
%270 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %269)
%271 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %270, i32* %271
%272 = icmp slt i32 %270, 0
br i1 %272, label %273, label %277
273: ; preds = %268
%274 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.17, i64 0, i64 0))
%275 = load i32, i32* %8
%276 = add nsw i32 %275, 1
store i32 %276, i32* %8
br label %277
277: ; preds = %273, %268
%278 = load i32, i32* @O_RDONLY
%279 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %278)
%280 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %279, i32* %280
%281 = icmp sge i32 %279, 0
br i1 %281, label %282, label %286
282: ; preds = %277
%283 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.18, i64 0, i64 0))
%284 = load i32, i32* %8
%285 = add nsw i32 %284, 1
store i32 %285, i32* %8
br label %286
286: ; preds = %282, %277
store i32 0, i32* %7
br label %287
287: ; preds = %306, %286
%288 = load i32, i32* %7
%289 = icmp slt i32 %288, 2
br i1 %289, label %290, label %309
290: ; preds = %287
%291 = load i32, i32* %7
%292 = sext i32 %291 to i64
%293 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %292
%294 = load i32, i32* %293
%295 = icmp sge i32 %294, 0
br i1 %295, label %296, label %305
296: ; preds = %290
%297 = load i32, i32* %7
%298 = sext i32 %297 to i64
%299 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %298
%300 = load i32, i32* %299
%301 = call i32 @close(i32 %300)
%302 = load i32, i32* %7
%303 = sext i32 %302 to i64
%304 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 %303
store i32 -1, i32* %304
br label %305
305: ; preds = %296, %290
br label %306
306: ; preds = %305
%307 = load i32, i32* %7
%308 = add nsw i32 %307, 1
store i32 %308, i32* %7
br label %287
309: ; preds = %287
%310 = load i32, i32* %8
%311 = icmp eq i32 %310, 0
br i1 %311, label %312, label %314
312: ; preds = %309
%313 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.19, i64 0, i64 0))
br label %317
314: ; preds = %309
%315 = load i32, i32* %8
%316 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0), i32 %315)
br label %317
317: ; preds = %314, %312
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [15 x i8] c"/dev/sound/dsp\00"
@O_RDWR = global i32 0
@.str.5 = [16 x i8] c"/dev/sound/dsp1\00"
@O_WRONLY = global i32 0
@O_RDONLY = global i32 0
@.str.20 = [24 x i8] c"\0AEncountered %i errors\0A\00"
@str = [7 x i8] c"Hi... \00"
@str.21 = [74 x i8] c"This program checks that it is possible to open the driver for 2W and 1R \00"
@str.22 = [18 x i8] c"-> main <no arg>\0A\00"
@str.23 = [45 x i8] c"\0A --> All the tests were passed successfully\00"
@str.24 = [51 x i8] c"[1 RDWR + 1 RD] Error : second opening should fail\00"
@str.25 = [39 x i8] c"[1 RDWR + 1 RD] Error at first opening\00"
@str.26 = [51 x i8] c"[1 RD + 1 RDWR] Error : second opening should fail\00"
@str.27 = [39 x i8] c"[1 RD + 1 RDWR] Error at first opening\00"
@str.28 = [40 x i8] c"[1 RDWR + 1 WR] Error at second opening\00"
@str.29 = [39 x i8] c"[1 RDWR + 1 WR] Error at first opening\00"
@str.30 = [38 x i8] c"[1 RD + 1 WR] Error at second opening\00"
@str.31 = [37 x i8] c"[1 RD + 1 WR] Error at first opening\00"
@str.32 = [35 x i8] c"[2 open in RD] Error : 2RW allowed\00"
@str.33 = [38 x i8] c"[2 open in RD] Error at first opening\00"
@str.34 = [39 x i8] c"[2 open in WR] Error at second opening\00"
@str.35 = [38 x i8] c"[2 open in WR] Error at first opening\00"
@str.36 = [37 x i8] c"[2 open in RDWR] Error : 2RW allowed\00"
@str.37 = [40 x i8] c"[2 open in RDWR] Error at first opening\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.21, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.22, i64 0, i64 0))
%6 = load i32, i32* @O_RDWR
%7 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.37, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = phi i32 [ 1, %9 ], [ 0, %2 ]
%13 = load i32, i32* @O_RDWR
%14 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.36, i64 0, i64 0))
%18 = add nuw nsw i32 %12, 1
br label %19
19: ; preds = %16, %11
%20 = phi i32 [ %18, %16 ], [ %12, %11 ]
%21 = icmp sgt i32 %7, -1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @close(i32 %7)
br label %24
24: ; preds = %19, %22
br i1 %15, label %25, label %27
25: ; preds = %24
%26 = tail call i32 @close(i32 %14)
br label %27
27: ; preds = %25, %24
%28 = load i32, i32* @O_WRONLY
%29 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.35, i64 0, i64 0))
%33 = add nuw nsw i32 %20, 1
br label %34
34: ; preds = %31, %27
%35 = phi i32 [ %33, %31 ], [ %20, %27 ]
%36 = load i32, i32* @O_WRONLY
%37 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.34, i64 0, i64 0))
%41 = add nuw nsw i32 %35, 1
br label %42
42: ; preds = %39, %34
%43 = phi i32 [ %41, %39 ], [ %35, %34 ]
%44 = icmp sgt i32 %29, -1
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 @close(i32 %29)
br label %47
47: ; preds = %42, %45
%48 = icmp sgt i32 %37, -1
br i1 %48, label %49, label %51
49: ; preds = %47
%50 = tail call i32 @close(i32 %37)
br label %51
51: ; preds = %49, %47
%52 = load i32, i32* @O_RDONLY
%53 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.33, i64 0, i64 0))
%57 = add nuw nsw i32 %43, 1
br label %58
58: ; preds = %55, %51
%59 = phi i32 [ %57, %55 ], [ %43, %51 ]
%60 = load i32, i32* @O_RDONLY
%61 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = icmp sgt i32 %61, -1
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.32, i64 0, i64 0))
%65 = add nuw nsw i32 %59, 1
br label %66
66: ; preds = %63, %58
%67 = phi i32 [ %65, %63 ], [ %59, %58 ]
%68 = icmp sgt i32 %53, -1
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = tail call i32 @close(i32 %53)
br label %71
71: ; preds = %66, %69
br i1 %62, label %72, label %74
72: ; preds = %71
%73 = tail call i32 @close(i32 %61)
br label %74
74: ; preds = %72, %71
%75 = load i32, i32* @O_RDONLY
%76 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.31, i64 0, i64 0))
%80 = add nuw nsw i32 %67, 1
br label %81
81: ; preds = %78, %74
%82 = phi i32 [ %80, %78 ], [ %67, %74 ]
%83 = load i32, i32* @O_WRONLY
%84 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %81
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.30, i64 0, i64 0))
%88 = add nuw nsw i32 %82, 1
br label %89
89: ; preds = %86, %81
%90 = phi i32 [ %88, %86 ], [ %82, %81 ]
%91 = icmp sgt i32 %76, -1
br i1 %91, label %92, label %94
92: ; preds = %89
%93 = tail call i32 @close(i32 %76)
br label %94
94: ; preds = %89, %92
%95 = icmp sgt i32 %84, -1
br i1 %95, label %96, label %98
96: ; preds = %94
%97 = tail call i32 @close(i32 %84)
br label %98
98: ; preds = %96, %94
%99 = load i32, i32* @O_RDWR
%100 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %99)
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %98
%103 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.29, i64 0, i64 0))
%104 = add nuw nsw i32 %90, 1
br label %105
105: ; preds = %102, %98
%106 = phi i32 [ %104, %102 ], [ %90, %98 ]
%107 = load i32, i32* @O_WRONLY
%108 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %107)
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %105
%111 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.28, i64 0, i64 0))
%112 = add nuw nsw i32 %106, 1
br label %113
113: ; preds = %110, %105
%114 = phi i32 [ %112, %110 ], [ %106, %105 ]
%115 = icmp sgt i32 %100, -1
br i1 %115, label %116, label %118
116: ; preds = %113
%117 = tail call i32 @close(i32 %100)
br label %118
118: ; preds = %113, %116
%119 = icmp sgt i32 %108, -1
br i1 %119, label %120, label %122
120: ; preds = %118
%121 = tail call i32 @close(i32 %108)
br label %122
122: ; preds = %120, %118
%123 = load i32, i32* @O_RDONLY
%124 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %123)
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %122
%127 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.27, i64 0, i64 0))
%128 = add nuw nsw i32 %114, 1
br label %129
129: ; preds = %126, %122
%130 = phi i32 [ %128, %126 ], [ %114, %122 ]
%131 = load i32, i32* @O_RDWR
%132 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %131)
%133 = icmp sgt i32 %132, -1
br i1 %133, label %134, label %137
134: ; preds = %129
%135 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.26, i64 0, i64 0))
%136 = add nuw nsw i32 %130, 1
br label %137
137: ; preds = %134, %129
%138 = phi i32 [ %136, %134 ], [ %130, %129 ]
%139 = icmp eq i32 %124, 0
br i1 %139, label %142, label %140
140: ; preds = %137
%141 = tail call i32 @close(i32 %124)
br label %142
142: ; preds = %137, %140
%143 = icmp eq i32 %132, 0
br i1 %143, label %146, label %144
144: ; preds = %142
%145 = tail call i32 @close(i32 %132)
br label %146
146: ; preds = %144, %142
%147 = load i32, i32* @O_RDWR
%148 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %147)
%149 = icmp slt i32 %148, 0
br i1 %149, label %150, label %153
150: ; preds = %146
%151 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.25, i64 0, i64 0))
%152 = add nuw nsw i32 %138, 1
br label %153
153: ; preds = %150, %146
%154 = phi i32 [ %152, %150 ], [ %138, %146 ]
%155 = load i32, i32* @O_RDONLY
%156 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %155)
%157 = icmp sgt i32 %156, -1
br i1 %157, label %158, label %161
158: ; preds = %153
%159 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.24, i64 0, i64 0))
%160 = add nuw nsw i32 %154, 1
br label %161
161: ; preds = %158, %153
%162 = phi i32 [ %160, %158 ], [ %154, %153 ]
%163 = icmp sgt i32 %148, -1
br i1 %163, label %164, label %166
164: ; preds = %161
%165 = tail call i32 @close(i32 %148)
br label %166
166: ; preds = %161, %164
br i1 %157, label %167, label %169
167: ; preds = %166
%168 = tail call i32 @close(i32 %156)
br label %169
169: ; preds = %167, %166
%170 = icmp eq i32 %162, 0
br i1 %170, label %171, label %173
171: ; preds = %169
%172 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.23, i64 0, i64 0))
br label %175
173: ; preds = %169
%174 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0), i32 %162)
br label %175
175: ; preds = %173, %171
ret i32 0
}