#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__ EPERM;
scalar_t__ chmod(char *, int);
scalar_t__ errno;
scalar_t__ getenv(char *);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  if (argc < 2)
    return 125;
  if (chmod(argv[1], 0000) < 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/"
             "t001_chmod.c");
      return 1;
    } else 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/"
           "t001_chmod.c");
    return 1;
  }
  return getenv("PANDORA_TEST_SUCCESS") ? 0 : 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0x7d,-0x4(%rbp)
jmp    121c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
call   1040 <chmod@plt>
cmp    $0x0,%rax
jge    11fc <main+0xcc>
lea    0xe84(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11a3 <main+0x73>
lea    0xe83(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    121c <main+0xec>
lea    0xef7(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11df <main+0xaf>
mov    0x2e20(%rip),%rax
mov    (%rax),%rax
mov    0x2e06(%rip),%rcx
cmp    (%rcx),%rax
jne    11df <main+0xaf>
movl   $0x0,-0x4(%rbp)
jmp    121c <main+0xec>
jmp    11e4 <main+0xb4>
lea    0xe2a(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    121c <main+0xec>
lea    0xdfd(%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    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x7d,%eax
cmp    $0x2,%edi
jl     1197 <main+0x67>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
call   1040 <chmod@plt>
mov    %rax,%rbx
lea    0xeb0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
test   %rbx,%rbx
js     1169 <main+0x39>
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    %eax,%eax
jmp    1197 <main+0x67>
test   %rcx,%rcx
jne    1199 <main+0x69>
lea    0xf2c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1199 <main+0x69>
mov    0x2e5a(%rip),%rax
mov    (%rax),%rcx
mov    0x2e40(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
jne    1199 <main+0x69>
pop    %rbx
ret
lea    0xe75(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"PANDORA_TEST_SUCCESS\00"
@.str.1 = [140 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/t001_chmod.c\00"
@.str.2 = [19 x i8] c"PANDORA_TEST_EPERM\00"
@errno = global i64 0
@EPERM = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 125, i32* %3
br label %36
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @chmod(i8* %12, i32 0)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %31
15: ; preds = %9
%16 = call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @perror(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %36
20: ; preds = %15
%21 = call i64 @getenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i64, i64* @errno
%25 = load i64, i64* @EPERM
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 0, i32* %3
br label %36
28: ; preds = %23, %20
br label %29
29: ; preds = %28
%30 = call i32 @perror(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %36
31: ; preds = %9
%32 = call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 0, i32 2
store i32 %35, i32* %3
br label %36
36: ; preds = %31, %29, %27, %18, %8
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [21 x i8] c"PANDORA_TEST_SUCCESS\00"
@.str.1 = [140 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/t001_chmod.c\00"
@.str.2 = [19 x i8] c"PANDORA_TEST_EPERM\00"
@errno = global i64 0
@EPERM = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @chmod(i8* %6, i32 0)
%8 = icmp slt i64 %7, 0
%9 = tail call i64 @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %8, label %11, label %23
11: ; preds = %4
br i1 %10, label %14, label %12
12: ; preds = %11
%13 = tail call i32 @perror(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0))
br label %25
14: ; preds = %11
%15 = tail call i64 @getenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i64, i64* @errno
%19 = load i64, i64* @EPERM
%20 = icmp eq i64 %18, %19
br i1 %20, label %25, label %21
21: ; preds = %14, %17
%22 = tail call i32 @perror(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0))
br label %25
23: ; preds = %4
%24 = select i1 %10, i32 2, i32 0
br label %25
25: ; preds = %17, %2, %23, %21, %12
%26 = phi i32 [ 1, %12 ], [ 1, %21 ], [ %24, %23 ], [ 125, %2 ], [ 0, %17 ]
ret i32 %26
}