#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 */
scalar_t__ EEXIST;
scalar_t__ EPERM;
int O_CREAT;
int O_EXCL;
int O_RDONLY;
int O_RDWR;
int O_WRONLY;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
scalar_t__ getenv(char *);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int fd, flags;
  if (argc < 2)
    return 125;
  flags = 0;
  if (!strcmp(argv[2], "rdonly")) {
    fd = open(argv[1], O_RDONLY);
    if (fd < 0) {
      perror("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/alip/pandora/refs/heads/master/tests/"
             "t003_open.c");
      return 1;
    }
    return 0;
  }
  if (!strcmp(argv[2], "rdonly-creat"))
    flags |= O_RDONLY | O_CREAT;
  else if (!strcmp(argv[2], "rdonly-creat-excl"))
    flags |= O_RDONLY | O_CREAT | O_EXCL;
  else if (!strcmp(argv[2], "wronly"))
    flags |= O_WRONLY;
  else if (!strcmp(argv[2], "wronly-creat"))
    flags |= O_WRONLY | O_CREAT;
  else if (!strcmp(argv[2], "wronly-creat-excl"))
    flags |= O_WRONLY | O_CREAT | O_EXCL;
  else if (!strcmp(argv[2], "rdwr"))
    flags |= O_RDWR;
  else if (!strcmp(argv[2], "rdwr-creat"))
    flags |= O_RDWR | O_CREAT;
  else if (!strcmp(argv[2], "rdwr-creat-excl"))
    flags |= O_RDWR | O_CREAT | O_EXCL;
  else
    return 125;
  fd = open(argv[1], flags, 0644);
  if (fd < 0) {
    if (getenv("PANDORA_TEST_SUCCESS")) {
      perror("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/alip/pandora/refs/heads/master/tests/"
             "t003_open.c");
      return 1;
    }
    if (getenv("PANDORA_TEST_EEXIST") && errno == EEXIST)
      return 0;
    if (getenv("PANDORA_TEST_EPERM") && errno == EPERM)
      return 0;
    perror("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/alip/pandora/refs/heads/master/tests/"
           "t003_open.c");
    return 1;
  }
  if (!(flags & O_CREAT) && argc > 2)
    write(fd, argv[3], strlen(argv[5]));
  close(fd);
  return getenv("PANDORA_TEST_SUCCESS") ? 0 : 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119c <main+0x2c>
movl   $0x7d,-0x4(%rbp)
jmp    1567 <main+0x3f7>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1209 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11fd <main+0x8d>
lea    0xe1b(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1567 <main+0x3f7>
movl   $0x0,-0x4(%rbp)
jmp    1567 <main+0x3f7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1243 <main+0xd3>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    0x2dc2(%rip),%rcx
or     (%rcx),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1411 <main+0x2a1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1286 <main+0x116>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    0x2d88(%rip),%rcx
or     (%rcx),%eax
mov    0x2d47(%rip),%rcx
or     (%rcx),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    140c <main+0x29c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe1c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12b7 <main+0x147>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1407 <main+0x297>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12f1 <main+0x181>
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    0x2d14(%rip),%rcx
or     (%rcx),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1402 <main+0x292>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdc5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1334 <main+0x1c4>
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    0x2cda(%rip),%rcx
or     (%rcx),%eax
mov    0x2c99(%rip),%rcx
or     (%rcx),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13fd <main+0x28d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd94(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1365 <main+0x1f5>
mov    0x2c88(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13f8 <main+0x288>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd68(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    139f <main+0x22f>
mov    0x2c57(%rip),%rax
mov    (%rax),%eax
mov    0x2c66(%rip),%rcx
or     (%rcx),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13f3 <main+0x283>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd39(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    13e2 <main+0x272>
mov    0x2c1d(%rip),%rax
mov    (%rax),%eax
mov    0x2c2c(%rip),%rcx
or     (%rcx),%eax
mov    0x2beb(%rip),%rcx
or     (%rcx),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13ee <main+0x27e>
movl   $0x7d,-0x4(%rbp)
jmp    1567 <main+0x3f7>
jmp    13f3 <main+0x283>
jmp    13f8 <main+0x288>
jmp    13fd <main+0x28d>
jmp    1402 <main+0x292>
jmp    1407 <main+0x297>
jmp    140c <main+0x29c>
jmp    1411 <main+0x2a1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    14f3 <main+0x383>
lea    0xcbb(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1463 <main+0x2f3>
lea    0xbb5(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1567 <main+0x3f7>
lea    0xca2(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     149f <main+0x32f>
mov    0x2b38(%rip),%rax
mov    (%rax),%rax
mov    0x2b3e(%rip),%rcx
cmp    (%rcx),%rax
jne    149f <main+0x32f>
movl   $0x0,-0x4(%rbp)
jmp    1567 <main+0x3f7>
lea    0xc7a(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     14db <main+0x36b>
mov    0x2afc(%rip),%rax
mov    (%rax),%rax
mov    0x2ada(%rip),%rcx
cmp    (%rcx),%rax
jne    14db <main+0x36b>
movl   $0x0,-0x4(%rbp)
jmp    1567 <main+0x3f7>
lea    0xb25(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1567 <main+0x3f7>
mov    -0x18(%rbp),%eax
mov    0x2afb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    153f <main+0x3cf>
cmpl   $0x2,-0x8(%rbp)
jle    153f <main+0x3cf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1050 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
lea    0xba9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdx
mov    $0x2,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x7d,%ebx
cmp    $0x2,%edi
jl     138c <main+0x21c>
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x10(%rsi),%rbp
lea    0xe6a(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1267 <main+0xf7>
lea    0xee5(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     128a <main+0x11a>
lea    0xedb(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     129c <main+0x12c>
lea    0xed6(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1399 <main+0x229>
lea    0xec6(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     13a7 <main+0x237>
lea    0xebc(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     13b3 <main+0x243>
lea    0xeb7(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     13bf <main+0x24f>
lea    0xea5(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     13cd <main+0x25d>
lea    0xe99(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    138c <main+0x21c>
mov    0x2d7b(%rip),%rax
jmp    12a3 <main+0x133>
mov    0x8(%r14),%rdi
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <open@plt>
test   %eax,%eax
jns    138c <main+0x21c>
jmp    137b <main+0x20b>
mov    0x2d47(%rip),%rax
mov    0x2d60(%rip),%rcx
mov    (%rcx),%ebx
jmp    12b5 <main+0x145>
mov    0x2d35(%rip),%rax
mov    0x2d4e(%rip),%rcx
mov    (%rcx),%ebx
or     (%rax),%ebx
mov    0x2d0b(%rip),%rax
or     (%rax),%ebx
mov    0x8(%r14),%rdi
mov    %ebx,%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   1080 <open@plt>
test   %eax,%eax
js     1318 <main+0x1a8>
mov    %eax,%ebp
cmp    $0x3,%r15d
jb     12f9 <main+0x189>
mov    0x2d1c(%rip),%rax
and    (%rax),%ebx
jne    12f9 <main+0x189>
mov    0x18(%r14),%rbx
mov    0x28(%r14),%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebp,%edi
call   1060 <close@plt>
lea    0xdf0(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
add    %ebx,%ebx
jmp    138c <main+0x21c>
lea    0xdd8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    137b <main+0x20b>
lea    0xddc(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1352 <main+0x1e2>
mov    0x2c77(%rip),%rax
mov    (%rax),%rax
mov    0x2c7d(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
je     138c <main+0x21c>
lea    0xdc7(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     137b <main+0x20b>
mov    0x2c4e(%rip),%rax
mov    (%rax),%rax
mov    0x2c2c(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
je     138c <main+0x21c>
lea    0xc85(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c08(%rip),%rax
mov    (%rax),%ebx
jmp    12b7 <main+0x147>
mov    0x2bfa(%rip),%rax
jmp    1291 <main+0x121>
mov    0x2bee(%rip),%rax
jmp    12a3 <main+0x133>
mov    0x2c1a(%rip),%rax
mov    (%rax),%ebx
jmp    12b7 <main+0x147>
mov    0x2c0c(%rip),%rax
jmp    1291 <main+0x121>

LLVM IR (-O0):
@.str = [7 x i8] c"rdonly\00"
@O_RDONLY = global i32 0
@.str.1 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/alip/pandora/refs/heads/master/tests/t003_open.c\00"
@.str.2 = [13 x i8] c"rdonly-creat\00"
@O_CREAT = global i32 0
@.str.3 = [18 x i8] c"rdonly-creat-excl\00"
@O_EXCL = global i32 0
@.str.4 = [7 x i8] c"wronly\00"
@O_WRONLY = global i32 0
@.str.5 = [13 x i8] c"wronly-creat\00"
@.str.6 = [18 x i8] c"wronly-creat-excl\00"
@.str.7 = [5 x i8] c"rdwr\00"
@O_RDWR = global i32 0
@.str.8 = [11 x i8] c"rdwr-creat\00"
@.str.9 = [16 x i8] c"rdwr-creat-excl\00"
@.str.10 = [21 x i8] c"PANDORA_TEST_SUCCESS\00"
@.str.11 = [20 x i8] c"PANDORA_TEST_EEXIST\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.12 = [19 x i8] c"PANDORA_TEST_EPERM\00"
@EPERM = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 125, i32* %3
br label %190
11: ; preds = %2
store i32 0, i32* %7
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %28, label %17
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = call i32 (i8*, i32, ...) @open(i8* %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @perror(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %190
27: ; preds = %17
store i32 0, i32* %3
br label %190
28: ; preds = %11
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = load i32, i32* @O_RDONLY
%36 = load i32, i32* @O_CREAT
%37 = or i32 %35, %36
%38 = load i32, i32* %7
%39 = or i32 %38, %37
store i32 %39, i32* %7
br label %134
40: ; preds = %28
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %54, label %46
46: ; preds = %40
%47 = load i32, i32* @O_RDONLY
%48 = load i32, i32* @O_CREAT
%49 = or i32 %47, %48
%50 = load i32, i32* @O_EXCL
%51 = or i32 %49, %50
%52 = load i32, i32* %7
%53 = or i32 %52, %51
store i32 %53, i32* %7
br label %133
54: ; preds = %40
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i32 @strcmp(i8* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp ne i32 %58, 0
br i1 %59, label %64, label %60
60: ; preds = %54
%61 = load i32, i32* @O_WRONLY
%62 = load i32, i32* %7
%63 = or i32 %62, %61
store i32 %63, i32* %7
br label %132
64: ; preds = %54
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %76, label %70
70: ; preds = %64
%71 = load i32, i32* @O_WRONLY
%72 = load i32, i32* @O_CREAT
%73 = or i32 %71, %72
%74 = load i32, i32* %7
%75 = or i32 %74, %73
store i32 %75, i32* %7
br label %131
76: ; preds = %64
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 2
%79 = load i8*, i8** %78
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %90, label %82
82: ; preds = %76
%83 = load i32, i32* @O_WRONLY
%84 = load i32, i32* @O_CREAT
%85 = or i32 %83, %84
%86 = load i32, i32* @O_EXCL
%87 = or i32 %85, %86
%88 = load i32, i32* %7
%89 = or i32 %88, %87
store i32 %89, i32* %7
br label %130
90: ; preds = %76
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 2
%93 = load i8*, i8** %92
%94 = call i32 @strcmp(i8* %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%95 = icmp ne i32 %94, 0
br i1 %95, label %100, label %96
96: ; preds = %90
%97 = load i32, i32* @O_RDWR
%98 = load i32, i32* %7
%99 = or i32 %98, %97
store i32 %99, i32* %7
br label %129
100: ; preds = %90
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 2
%103 = load i8*, i8** %102
%104 = call i32 @strcmp(i8* %103, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%105 = icmp ne i32 %104, 0
br i1 %105, label %112, label %106
106: ; preds = %100
%107 = load i32, i32* @O_RDWR
%108 = load i32, i32* @O_CREAT
%109 = or i32 %107, %108
%110 = load i32, i32* %7
%111 = or i32 %110, %109
store i32 %111, i32* %7
br label %128
112: ; preds = %100
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 2
%115 = load i8*, i8** %114
%116 = call i32 @strcmp(i8* %115, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%117 = icmp ne i32 %116, 0
br i1 %117, label %126, label %118
118: ; preds = %112
%119 = load i32, i32* @O_RDWR
%120 = load i32, i32* @O_CREAT
%121 = or i32 %119, %120
%122 = load i32, i32* @O_EXCL
%123 = or i32 %121, %122
%124 = load i32, i32* %7
%125 = or i32 %124, %123
store i32 %125, i32* %7
br label %127
126: ; preds = %112
store i32 125, i32* %3
br label %190
127: ; preds = %118
br label %128
128: ; preds = %127, %106
br label %129
129: ; preds = %128, %96
br label %130
130: ; preds = %129, %82
br label %131
131: ; preds = %130, %70
br label %132
132: ; preds = %131, %60
br label %133
133: ; preds = %132, %46
br label %134
134: ; preds = %133, %34
%135 = load i8**, i8*** %5
%136 = getelementptr inbounds i8*, i8** %135, i64 1
%137 = load i8*, i8** %136
%138 = load i32, i32* %7
%139 = call i32 (i8*, i32, ...) @open(i8* %137, i32 %138, i32 420)
store i32 %139, i32* %6
%140 = load i32, i32* %6
%141 = icmp slt i32 %140, 0
br i1 %141, label %142, label %165
142: ; preds = %134
%143 = call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%144 = icmp ne i64 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %142
%146 = call i32 @perror(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %190
147: ; preds = %142
%148 = call i64 @getenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%149 = icmp ne i64 %148, 0
br i1 %149, label %150, label %155
150: ; preds = %147
%151 = load i64, i64* @errno
%152 = load i64, i64* @EEXIST
%153 = icmp eq i64 %151, %152
br i1 %153, label %154, label %155
154: ; preds = %150
store i32 0, i32* %3
br label %190
155: ; preds = %150, %147
%156 = call i64 @getenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%157 = icmp ne i64 %156, 0
br i1 %157, label %158, label %163
158: ; preds = %155
%159 = load i64, i64* @errno
%160 = load i64, i64* @EPERM
%161 = icmp eq i64 %159, %160
br i1 %161, label %162, label %163
162: ; preds = %158
store i32 0, i32* %3
br label %190
163: ; preds = %158, %155
%164 = call i32 @perror(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %190
165: ; preds = %134
%166 = load i32, i32* %7
%167 = load i32, i32* @O_CREAT
%168 = and i32 %166, %167
%169 = icmp ne i32 %168, 0
br i1 %169, label %183, label %170
170: ; preds = %165
%171 = load i32, i32* %4
%172 = icmp sgt i32 %171, 2
br i1 %172, label %173, label %183
173: ; preds = %170
%174 = load i32, i32* %6
%175 = load i8**, i8*** %5
%176 = getelementptr inbounds i8*, i8** %175, i64 3
%177 = load i8*, i8** %176
%178 = load i8**, i8*** %5
%179 = getelementptr inbounds i8*, i8** %178, i64 5
%180 = load i8*, i8** %179
%181 = call i32 @strlen(i8* %180)
%182 = call i32 @write(i32 %174, i8* %177, i32 %181)
br label %183
183: ; preds = %173, %170, %165
%184 = load i32, i32* %6
%185 = call i32 @close(i32 %184)
%186 = call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%187 = icmp ne i64 %186, 0
%188 = zext i1 %187 to i64
%189 = select i1 %187, i32 0, i32 2
store i32 %189, i32* %3
br label %190
190: ; preds = %183, %163, %162, %154, %145, %126, %27, %25, %10
%191 = load i32, i32* %3
ret i32 %191
}

LLVM IR (-O2):
@.str = [7 x i8] c"rdonly\00"
@O_RDONLY = global i32 0
@.str.1 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/alip/pandora/refs/heads/master/tests/t003_open.c\00"
@.str.2 = [13 x i8] c"rdonly-creat\00"
@O_CREAT = global i32 0
@.str.3 = [18 x i8] c"rdonly-creat-excl\00"
@O_EXCL = global i32 0
@.str.4 = [7 x i8] c"wronly\00"
@O_WRONLY = global i32 0
@.str.5 = [13 x i8] c"wronly-creat\00"
@.str.6 = [18 x i8] c"wronly-creat-excl\00"
@.str.7 = [5 x i8] c"rdwr\00"
@O_RDWR = global i32 0
@.str.8 = [11 x i8] c"rdwr-creat\00"
@.str.9 = [16 x i8] c"rdwr-creat-excl\00"
@.str.10 = [21 x i8] c"PANDORA_TEST_SUCCESS\00"
@.str.11 = [20 x i8] c"PANDORA_TEST_EEXIST\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.12 = [19 x i8] c"PANDORA_TEST_EPERM\00"
@EPERM = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %120, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 (i8*, i32, ...) @open(i8* %11, i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %120
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0))
br label %120
17: ; preds = %4
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* @O_RDONLY
%22 = load i32, i32* @O_CREAT
%23 = or i32 %22, %21
br label %75
24: ; preds = %17
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i32, i32* @O_RDONLY
%29 = load i32, i32* @O_CREAT
%30 = or i32 %29, %28
%31 = load i32, i32* @O_EXCL
%32 = or i32 %30, %31
br label %75
33: ; preds = %24
%34 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = load i32, i32* @O_WRONLY
br label %75
38: ; preds = %33
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* @O_WRONLY
%43 = load i32, i32* @O_CREAT
%44 = or i32 %43, %42
br label %75
45: ; preds = %38
%46 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = load i32, i32* @O_WRONLY
%50 = load i32, i32* @O_CREAT
%51 = or i32 %50, %49
%52 = load i32, i32* @O_EXCL
%53 = or i32 %51, %52
br label %75
54: ; preds = %45
%55 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = load i32, i32* @O_RDWR
br label %75
59: ; preds = %54
%60 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* @O_RDWR
%64 = load i32, i32* @O_CREAT
%65 = or i32 %64, %63
br label %75
66: ; preds = %59
%67 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %120
69: ; preds = %66
%70 = load i32, i32* @O_RDWR
%71 = load i32, i32* @O_CREAT
%72 = or i32 %71, %70
%73 = load i32, i32* @O_EXCL
%74 = or i32 %72, %73
br label %75
75: ; preds = %27, %41, %57, %69, %62, %48, %36, %20
%76 = phi i32 [ %74, %69 ], [ %65, %62 ], [ %58, %57 ], [ %53, %48 ], [ %44, %41 ], [ %37, %36 ], [ %32, %27 ], [ %23, %20 ]
%77 = getelementptr inbounds i8*, i8** %1, i64 1
%78 = load i8*, i8** %77
%79 = tail call i32 (i8*, i32, ...) @open(i8* %78, i32 %76, i32 420)
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %102
81: ; preds = %75
%82 = tail call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %86, label %84
84: ; preds = %81
%85 = tail call i32 @perror(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0))
br label %120
86: ; preds = %81
%87 = tail call i64 @getenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %93, label %89
89: ; preds = %86
%90 = load i64, i64* @errno
%91 = load i64, i64* @EEXIST
%92 = icmp eq i64 %90, %91
br i1 %92, label %120, label %93
93: ; preds = %89, %86
%94 = tail call i64 @getenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %100, label %96
96: ; preds = %93
%97 = load i64, i64* @errno
%98 = load i64, i64* @EPERM
%99 = icmp eq i64 %97, %98
br i1 %99, label %120, label %100
100: ; preds = %96, %93
%101 = tail call i32 @perror(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.1, i64 0, i64 0))
br label %120
102: ; preds = %75
%103 = load i32, i32* @O_CREAT
%104 = and i32 %103, %76
%105 = icmp eq i32 %104, 0
%106 = icmp ugt i32 %0, 2
%107 = and i1 %106, %105
br i1 %107, label %108, label %115
108: ; preds = %102
%109 = getelementptr inbounds i8*, i8** %1, i64 3
%110 = load i8*, i8** %109
%111 = getelementptr inbounds i8*, i8** %1, i64 5
%112 = load i8*, i8** %111
%113 = tail call i32 @strlen(i8* %112)
%114 = tail call i32 @write(i32 %79, i8* %110, i32 %113)
br label %115
115: ; preds = %108, %102
%116 = tail call i32 @close(i32 %79)
%117 = tail call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%118 = icmp eq i64 %117, 0
%119 = select i1 %118, i32 2, i32 0
br label %120
120: ; preds = %96, %89, %66, %9, %2, %115, %100, %84, %15
%121 = phi i32 [ 1, %84 ], [ 1, %100 ], [ %119, %115 ], [ 1, %15 ], [ 125, %2 ], [ 0, %9 ], [ 125, %66 ], [ 0, %89 ], [ 0, %96 ]
ret i32 %121
}