#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 */
char *cpy_str(char *, char *);
int /*<<< orphan*/ free(char *);
int my_access(char *);
int check_access(char **s1, char **path) {
  int i;
  char *str;
  i = 0;
  if (s1[0][0] == '/') {
    if ((my_access(s1[0])) == 2)
      return (0);
  }
  if (path == NULL)
    return (1);
  while (path[i]) {
    str = cpy_str(path[i], s1[0]);
    if ((my_access(str)) == 2)
      return (0);
    i++;
    free(str);
  }
  return (1);
}


x86 assembly (clang, -O0):
<check_access>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1180 <check_access+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <my_access@plt>
cmp    $0x2,%eax
jne    117b <check_access+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1207 <check_access+0xd7>
jmp    1180 <check_access+0x50>
cmpq   $0x0,-0x18(%rbp)
jne    1197 <check_access+0x67>
movl   $0x1,-0x4(%rbp)
jmp    1207 <check_access+0xd7>
jmp    119c <check_access+0x6c>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1200 <check_access+0xd0>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <cpy_str@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <my_access@plt>
cmp    $0x2,%eax
jne    11e9 <check_access+0xb9>
movl   $0x0,-0x4(%rbp)
jmp    1207 <check_access+0xd7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    119c <check_access+0x6c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_access>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rdi),%rdi
cmpb   $0x2f,(%rdi)
jne    1152 <check_access+0x22>
call   1050 <my_access@plt>
xor    %r14d,%r14d
cmp    $0x2,%eax
je     11a1 <check_access+0x71>
mov    $0x1,%r14d
test   %rbx,%rbx
je     11a1 <check_access+0x71>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     11a1 <check_access+0x71>
add    $0x8,%rbx
nopl   0x0(%rax)
mov    (%r15),%rsi
call   1040 <cpy_str@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <my_access@plt>
cmp    $0x2,%eax
je     119e <check_access+0x6e>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1170 <check_access+0x40>
jmp    11a1 <check_access+0x71>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_access(i8** %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i8** %0, i8*** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 47
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @my_access(i8* %18)
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %3
br label %55
22: ; preds = %15
br label %23
23: ; preds = %22, %2
%24 = load i8**, i8*** %5
%25 = icmp eq i8** %24, null
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 1, i32* %3
br label %55
27: ; preds = %23
br label %28
28: ; preds = %49, %27
%29 = load i8**, i8*** %5
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %54
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = load i8**, i8*** %4
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i8* @cpy_str(i8* %40, i8* %43)
store i8* %44, i8** %7
%45 = load i8*, i8** %7
%46 = call i32 @my_access(i8* %45)
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %49
48: ; preds = %35
store i32 0, i32* %3
br label %55
49: ; preds = %35
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
%52 = load i8*, i8** %7
%53 = call i32 @free(i8* %52)
br label %28
54: ; preds = %28
store i32 1, i32* %3
br label %55
55: ; preds = %54, %48, %26, %21
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
define i32 @check_access(i8** nocapture %0, i8** %1) {
%3 = load i8*, i8** %0
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 47
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @my_access(i8* %3)
%8 = icmp eq i32 %7, 2
br i1 %8, label %27, label %9
9: ; preds = %6, %2
%10 = icmp eq i8** %1, null
br i1 %10, label %27, label %11
11: ; preds = %9
%12 = load i8*, i8** %1
%13 = icmp eq i8* %12, null
br i1 %13, label %27, label %14
14: ; preds = %11, %21
%15 = phi i64 [ %22, %21 ], [ 0, %11 ]
%16 = phi i8* [ %25, %21 ], [ %12, %11 ]
%17 = load i8*, i8** %0
%18 = tail call i8* @cpy_str(i8* %16, i8* %17)
%19 = tail call i32 @my_access(i8* %18)
%20 = icmp eq i32 %19, 2
br i1 %20, label %27, label %21
21: ; preds = %14
%22 = add nuw i64 %15, 1
%23 = tail call i32 @free(i8* %18)
%24 = getelementptr inbounds i8*, i8** %1, i64 %22
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %14
27: ; preds = %14, %21, %11, %9, %6
%28 = phi i32 [ 0, %6 ], [ 1, %9 ], [ 1, %11 ], [ 0, %14 ], [ 1, %21 ]
ret i32 %28
}