#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 */
struct stat {
  int st_mode;
};

/* Variables and functions */
int S_IXUSR;
int /*<<< orphan*/ lt_debugprintf(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ nonempty(char const *);
scalar_t__ stat(char const *, struct stat *);
int check_executable(const char *path) {
  struct stat st;
  lt_debugprintf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/filip-be/ImageComparer/"
                 "refs/heads/master/exiv2/expat/xmlwf/.libs/lt-xmlwf.c",
                 345, "(check_executable): %s\n", nonempty(path));
  if ((!path) || (!*path))
    return 0;
  if ((stat(path, &st) >= 0) && (st.st_mode & (S_IXUSR | 0 | 0)))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<check_executable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <nonempty@plt>
mov    %eax,%ecx
lea    0xeb2(%rip),%rdi
mov    $0x159,%esi
lea    0xf4c(%rip),%rdx
call   1050 <lt_debugprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1177 <check_executable+0x47>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1183 <check_executable+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11ca <check_executable+0x9a>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
jl     11c3 <check_executable+0x93>
mov    -0x18(%rbp),%eax
mov    0x2e44(%rip),%rcx
mov    (%rcx),%ecx
or     $0x0,%ecx
or     $0x0,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11c3 <check_executable+0x93>
movl   $0x1,-0x4(%rbp)
jmp    11ca <check_executable+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_executable>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <nonempty@plt>
lea    0xebc(%rip),%rdi
lea    0xf5b(%rip),%rdx
mov    $0x159,%esi
mov    %eax,%ecx
call   1050 <lt_debugprintf@plt>
xor    %eax,%eax
test   %rbx,%rbx
je     118b <check_executable+0x5b>
cmpb   $0x0,(%rbx)
je     118b <check_executable+0x5b>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
test   %rax,%rax
js     1189 <check_executable+0x59>
mov    0x2e6c(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
test   %ecx,0x8(%rsp)
jne    118b <check_executable+0x5b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/filip-be/ImageComparer/refs/heads/master/exiv2/expat/xmlwf/.libs/lt-xmlwf.c\00"
@.str.1 = [24 x i8] c"(check_executable): %s\0A\00"
@S_IXUSR = global i32 0
define i32 @check_executable(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @nonempty(i8* %5)
%7 = call i32 @lt_debugprintf(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 345, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10, %1
store i32 0, i32* %2
br label %29
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = call i64 @stat(i8* %16, %struct.stat* %4)
%18 = icmp sge i64 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%21 = load i32, i32* %20
%22 = load i32, i32* @S_IXUSR
%23 = or i32 %22, 0
%24 = or i32 %23, 0
%25 = and i32 %21, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %19
store i32 1, i32* %2
br label %29
28: ; preds = %19, %15
store i32 0, i32* %2
br label %29
29: ; preds = %28, %27, %14
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/filip-be/ImageComparer/refs/heads/master/exiv2/expat/xmlwf/.libs/lt-xmlwf.c\00"
@.str.1 = [24 x i8] c"(check_executable): %s\0A\00"
@S_IXUSR = global i32 0
define i32 @check_executable(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = tail call i32 @nonempty(i8* %0)
%5 = tail call i32 @lt_debugprintf(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 345, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = icmp eq i8* %0, null
br i1 %6, label %20, label %7
7: ; preds = %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = call i64 @stat(i8* %0, %struct.stat* %2)
%12 = icmp sgt i64 %11, -1
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%15 = load i32, i32* %14
%16 = load i32, i32* @S_IXUSR
%17 = and i32 %16, %15
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13, %10
br label %20
20: ; preds = %13, %1, %7, %19
%21 = phi i32 [ 0, %19 ], [ 0, %7 ], [ 0, %1 ], [ 1, %13 ]
ret i32 %21
}