#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 find_file_helper(char *, char *, char *, char *, char *);
int find_file(char *includepath, char *origin, char *actualpath, char *cwd) {
  int i;
  int success;
  extern char include_folders[32][512];
  for (i = 0; i < 32 && include_folders[i][0] != 0; i++) {
    success = find_file_helper(includepath, origin, include_folders[i],
                               actualpath, cwd);
    if (success != 2)
      return success;
  }
  return 2;
}


x86 assembly (clang, -O0):
<find_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x20,-0x2c(%rbp)
mov    %al,-0x31(%rbp)
jge    115c <find_file+0x4c>
movslq -0x2c(%rbp),%rcx
mov    0x2e97(%rip),%rax
shl    $0x9,%rcx
add    %rcx,%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    116c <find_file+0x5c>
jmp    11be <find_file+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x2c(%rbp),%rax
mov    0x2e61(%rip),%rdx
shl    $0x9,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <find_file_helper@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
je     11ab <find_file+0x9b>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <find_file+0xb5>
jmp    11b0 <find_file+0xa0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    112f <find_file+0x1f>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebx,%ebx
mov    0x2eaf(%rip),%r14
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,(%r14,%rbx,1)
je     1176 <find_file+0x66>
lea    (%r14,%rbx,1),%rdx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rcx
mov    (%rsp),%r8
call   1030 <find_file_helper@plt>
cmp    $0x2,%eax
jne    1174 <find_file+0x64>
add    $0x200,%rbx
cmp    $0x4000,%rbx
jne    1140 <find_file+0x30>
jmp    1176 <find_file+0x66>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@include_folders = external global [32 x [512 x i8]]
define i32 @find_file(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %10
br label %12
12: ; preds = %40, %4
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 32
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [32 x [512 x i8]], [32 x [512 x i8]]* @include_folders, i64 0, i64 %17
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br label %23
23: ; preds = %15, %12
%24 = phi i1 [ false, %12 ], [ %22, %15 ]
br i1 %24, label %25, label %43
25: ; preds = %23
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [32 x [512 x i8]], [32 x [512 x i8]]* @include_folders, i64 0, i64 %29
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %30, i64 0, i64 0
%32 = load i8*, i8** %8
%33 = load i8*, i8** %9
%34 = call i32 @find_file_helper(i8* %26, i8* %27, i8* %31, i8* %32, i8* %33)
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = icmp ne i32 %35, 2
br i1 %36, label %37, label %39
37: ; preds = %25
%38 = load i32, i32* %11
store i32 %38, i32* %5
br label %44
39: ; preds = %25
br label %40
40: ; preds = %39
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 1
store i32 %42, i32* %10
br label %12
43: ; preds = %23
store i32 2, i32* %5
br label %44
44: ; preds = %43, %37
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@include_folders = external global [32 x [512 x i8]]
define i32 @find_file(i8* %0, i8* %1, i8* %2, i8* %3) {
br label %8
5: ; preds = %13
%6 = add nuw nsw i64 %9, 1
%7 = icmp eq i64 %6, 32
br i1 %7, label %16, label %8
8: ; preds = %4, %5
%9 = phi i64 [ 0, %4 ], [ %6, %5 ]
%10 = getelementptr inbounds [32 x [512 x i8]], [32 x [512 x i8]]* @include_folders, i64 0, i64 %9, i64 0
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 @find_file_helper(i8* %0, i8* %1, i8* %10, i8* %2, i8* %3)
%15 = icmp eq i32 %14, 2
br i1 %15, label %5, label %16
16: ; preds = %8, %5, %13
%17 = phi i32 [ %14, %13 ], [ 2, %5 ], [ 2, %8 ]
ret i32 %17
}