#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 */
scalar_t__ NAME_MAX;
scalar_t__ PATH_MAX;
scalar_t__ nvme_getdev_by_fid(char *, char *);
int nvme_getdev_by_nsid(char *, char *, char *);
int nvme_getdev(char *fid_str, char *nsid_str, char *dev_path) {
  char path_tmp[(PATH_MAX + NAME_MAX + 1)];
  if (nvme_getdev_by_fid(fid_str, path_tmp))
    return -1;
  return nvme_getdev_by_nsid(nsid_str, path_tmp, dev_path);
}


x86 assembly (clang, -O0):
<nvme_getdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%rcx
mov    0x2e8b(%rip),%rax
mov    (%rax),%rdx
lea    0x1(%rcx,%rdx,1),%rax
mov    %rsp,%rsi
mov    %rsi,-0x28(%rbp)
lea    0x10(%rcx,%rdx,1),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x40(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <nvme_getdev_by_fid@plt>
cmp    $0x0,%rax
je     1194 <nvme_getdev+0x74>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    11af <nvme_getdev+0x8f>
mov    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
call   1030 <nvme_getdev_by_nsid@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nvme_getdev>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    0x2eb9(%rip),%rax
mov    (%rax),%rax
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%rcx
add    %rcx,%rax
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rsi
call   1040 <nvme_getdev_by_fid@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    117b <nvme_getdev+0x5b>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <nvme_getdev_by_nsid@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i64 0
@NAME_MAX = global i64 0
define i32 @nvme_getdev(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i64, i64* @PATH_MAX
%12 = load i64, i64* @NAME_MAX
%13 = add nsw i64 %11, %12
%14 = add nsw i64 %13, 1
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %8
%16 = alloca i8, i64 %14
store i64 %14, i64* %9
%17 = load i8*, i8** %5
%18 = call i64 @nvme_getdev_by_fid(i8* %17, i8* %16)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 -1, i32* %4
store i32 1, i32* %10
br label %25
21: ; preds = %3
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = call i32 @nvme_getdev_by_nsid(i8* %22, i8* %16, i8* %23)
store i32 %24, i32* %4
store i32 1, i32* %10
br label %25
25: ; preds = %21, %20
%26 = load i8*, i8** %8
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@PATH_MAX = global i64 0
@NAME_MAX = global i64 0
define i32 @nvme_getdev(i8* %0, i8* %1, i8* %2) {
%4 = load i64, i64* @PATH_MAX
%5 = load i64, i64* @NAME_MAX
%6 = add i64 %4, 1
%7 = add i64 %6, %5
%8 = alloca i8, i64 %7
%9 = call i64 @nvme_getdev_by_fid(i8* %0, i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @nvme_getdev_by_nsid(i8* %1, i8* %8, i8* %2)
br label %13
13: ; preds = %3, %11
%14 = phi i32 [ %12, %11 ], [ -1, %3 ]
ret i32 %14
}