#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 ufat_dirent {
  int dummy;
};
struct ufat_directory {
  int dummy;
};
struct ufat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int ufat_dir_find_path(struct ufat_directory *, char const *,
                       struct ufat_dirent *, char const **);
int /*<<< orphan*/ ufat_open_root(struct ufat *, struct ufat_directory *);
char *ufat_strerror(int);
int find_path(struct ufat *uf, struct ufat_directory *dir, const char *path,
              struct ufat_dirent *inf, const char **path_out) {
  int err;
  ufat_open_root(uf, dir);
  err = ufat_dir_find_path(dir, path, inf, path_out);
  if (err < 0)
    fprintf(stderr, "ufat_dir_find_path: %s\n", ufat_strerror(err));
  return err;
}


x86 assembly (clang, -O0):
<find_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <ufat_open_root@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <ufat_dir_find_path@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11b1 <find_path+0x71>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <ufat_strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xe54(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_path>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
call   1060 <ufat_open_root@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <ufat_dir_find_path@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1191 <find_path+0x51>
mov    0x2e69(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1040 <ufat_strerror@plt>
lea    0xe79(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1030 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ufat = type { i32 }
%struct.ufat_directory = type { i32 }
%struct.ufat_dirent = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"ufat_dir_find_path: %s\0A\00"
define i32 @find_path(%struct.ufat* %0, %struct.ufat_directory* %1, i8* %2, %struct.ufat_dirent* %3, i8** %4) {
%6 = alloca %struct.ufat*
%7 = alloca %struct.ufat_directory*
%8 = alloca i8*
%9 = alloca %struct.ufat_dirent*
%10 = alloca i8**
%11 = alloca i32
store %struct.ufat* %0, %struct.ufat** %6
store %struct.ufat_directory* %1, %struct.ufat_directory** %7
store i8* %2, i8** %8
store %struct.ufat_dirent* %3, %struct.ufat_dirent** %9
store i8** %4, i8*** %10
%12 = load %struct.ufat*, %struct.ufat** %6
%13 = load %struct.ufat_directory*, %struct.ufat_directory** %7
%14 = call i32 @ufat_open_root(%struct.ufat* %12, %struct.ufat_directory* %13)
%15 = load %struct.ufat_directory*, %struct.ufat_directory** %7
%16 = load i8*, i8** %8
%17 = load %struct.ufat_dirent*, %struct.ufat_dirent** %9
%18 = load i8**, i8*** %10
%19 = call i32 @ufat_dir_find_path(%struct.ufat_directory* %15, i8* %16, %struct.ufat_dirent* %17, i8** %18)
store i32 %19, i32* %11
%20 = load i32, i32* %11
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %5
%23 = load i32, i32* @stderr
%24 = load i32, i32* %11
%25 = call i8* @ufat_strerror(i32 %24)
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %22, %5
%28 = load i32, i32* %11
ret i32 %28
}

LLVM IR (-O2):
%struct.ufat = type { i32 }
%struct.ufat_directory = type { i32 }
%struct.ufat_dirent = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"ufat_dir_find_path: %s\0A\00"
define i32 @find_path(%struct.ufat* %0, %struct.ufat_directory* %1, i8* %2, %struct.ufat_dirent* %3, i8** %4) {
%6 = tail call i32 @ufat_open_root(%struct.ufat* %0, %struct.ufat_directory* %1)
%7 = tail call i32 @ufat_dir_find_path(%struct.ufat_directory* %1, i8* %2, %struct.ufat_dirent* %3, i8** %4)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i8* @ufat_strerror(i32 %7)
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %9, %5
ret i32 %7
}