#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 sysapi_file_exist(char *);
int test_file_exist() {
  char non_existent[] = "fksjkfiuwaiekwfaew";
  char existent[] = "test_sysfs.c";
  int ret;
  ret = sysapi_file_exist(existent);
  if (ret < 0)
    return -1;
  ret = sysapi_file_exist(non_existent);
  if (ret >= 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<test_file_exist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedb(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xed3(%rip),%al
mov    %al,-0xe(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x2d(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x25(%rbp)
mov    0xec3(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x2d(%rbp),%rdi
call   1030 <sysapi_file_exist@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1181 <test_file_exist+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <test_file_exist+0x9a>
lea    -0x20(%rbp),%rdi
call   1030 <sysapi_file_exist@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11a3 <test_file_exist+0x93>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <test_file_exist+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_file_exist>:
sub    $0x28,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x776561,0x1f(%rsp)
movabs $0x632e7366737973,%rax
mov    %rax,0x5(%rsp)
movabs $0x7379735f74736574,%rax
73 79 73
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1030 <sysapi_file_exist@plt>
test   %eax,%eax
js     1165 <test_file_exist+0x55>
lea    0x10(%rsp),%rdi
call   1030 <sysapi_file_exist@plt>
sar    $0x1f,%eax
not    %eax
add    $0x28,%rsp
ret
mov    $0xffffffff,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.test_file_exist.non_existent = [19 x i8] c"fksjkfiuwaiekwfaew\00"
@__const.test_file_exist.existent = [13 x i8] c"test_sysfs.c\00"
define i32 @test_file_exist() {
%1 = alloca i32
%2 = alloca [19 x i8]
%3 = alloca [13 x i8]
%4 = alloca i32
%5 = bitcast [19 x i8]* %2 to i8*
%6 = bitcast [13 x i8]* %3 to i8*
%7 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%8 = call i32 @sysapi_file_exist(i8* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 -1, i32* %1
br label %19
12: ; preds = %0
%13 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%14 = call i32 @sysapi_file_exist(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -1, i32* %1
br label %19
18: ; preds = %12
store i32 0, i32* %1
br label %19
19: ; preds = %18, %17, %11
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@__const.test_file_exist.non_existent = [19 x i8] c"fksjkfiuwaiekwfaew\00"
@__const.test_file_exist.existent = [13 x i8] c"test_sysfs.c\00"
define i32 @test_file_exist() {
%1 = alloca [19 x i8]
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [19 x i8], [19 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%5 = call i32 @sysapi_file_exist(i8* %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = call i32 @sysapi_file_exist(i8* %3)
%9 = ashr i32 %8, 31
%10 = xor i32 %9, -1
br label %11
11: ; preds = %7, %0
%12 = phi i32 [ -1, %0 ], [ %10, %7 ]
ret i32 %12
}