#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ w1_abspath(char *, char *, int);
int w1_getch();
int w1_isdir(char *);
int w1_isfile(char *);
int main() {
  printf("Should be true : %d\n", w1_isfile("w1ce.h"));
  printf("Should be false: %d\n", w1_isfile("skjdfnskdw1ce.h"));
  printf("Should be false: %d\n", w1_isfile("."));
  printf("Should be true : %d\n", w1_isdir("."));
  char abspath[4096];
  w1_abspath(".", abspath, 4096);
  printf("Abs path       : %s\n", abspath);
  printf("Press key...\n");
  int c = w1_getch();
  printf("Key pressed is: %d\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <w1_isfile@plt>
mov    %eax,%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
call   1040 <w1_isfile@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
call   1040 <w1_isfile@plt>
mov    %eax,%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1070 <w1_isdir@plt>
mov    %eax,%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x1000,%edx
call   1060 <w1_abspath@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <w1_getch@plt>
mov    %eax,-0x1014(%rbp)
mov    -0x1014(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1008,%rsp
lea    0xebe(%rip),%rdi
call   1050 <w1_isfile@plt>
lea    0xe7f(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe96(%rip),%rdi
call   1050 <w1_isfile@plt>
lea    0xe75(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xebb(%rip),%r12
mov    %r12,%rdi
call   1050 <w1_isfile@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   1080 <w1_isdir@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1070 <w1_abspath@plt>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <w1_getch@plt>
lea    0xe36(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Should be true : %d\0A\00"
@.str.1 = [7 x i8] c"w1ce.h\00"
@.str.2 = [21 x i8] c"Should be false: %d\0A\00"
@.str.3 = [16 x i8] c"skjdfnskdw1ce.h\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [21 x i8] c"Abs path : %s\0A\00"
@.str.6 = [14 x i8] c"Press key...\0A\00"
@.str.7 = [20 x i8] c"Key pressed is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @w1_isfile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @w1_isfile(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = call i32 @w1_isfile(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = call i32 @w1_isdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%13 = call i32 @w1_abspath(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %12, i32 4096)
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 (...) @w1_getch()
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Should be true : %d\0A\00"
@.str.1 = [7 x i8] c"w1ce.h\00"
@.str.2 = [21 x i8] c"Should be false: %d\0A\00"
@.str.3 = [16 x i8] c"skjdfnskdw1ce.h\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [21 x i8] c"Abs path : %s\0A\00"
@.str.7 = [20 x i8] c"Key pressed is: %d\0A\00"
@str = [13 x i8] c"Press key...\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = tail call i32 @w1_isfile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 @w1_isfile(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%6 = tail call i32 @w1_isfile(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 @w1_isdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%11 = call i32 @w1_abspath(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %10, i32 4096)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%14 = call i32 (...) @w1_getch()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %14)
ret i32 0
}