#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*/ fprintf(int /*<<< orphan*/, char *, char const *, char *,
                           int);
char *nvme_status_to_string(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void handle_nvme_error(const char *cmd, int err) {
  if (err < 0)
    perror("ioctl");
  else if (err)
    fprintf(stderr, "%s:%s(%04x)\n", cmd, nvme_status_to_string(err), err);
}


x86 assembly (clang, -O0):
<handle_nvme_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    115a <handle_nvme_error+0x2a>
lea    0xeb0(%rip),%rdi
call   1050 <perror@plt>
jmp    119f <handle_nvme_error+0x6f>
cmpl   $0x0,-0xc(%rbp)
je     119a <handle_nvme_error+0x6a>
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <nvme_status_to_string@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    %rax,%rcx
mov    -0xc(%rbp),%r8d
lea    0xe71(%rip),%rsi
call   1040 <fprintf@plt>
jmp    119f <handle_nvme_error+0x6f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_nvme_error>:
test   %esi,%esi
js     116b <handle_nvme_error+0x3b>
je     116a <handle_nvme_error+0x3a>
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
mov    0x2e9a(%rip),%rax
mov    (%rax),%ebp
mov    %esi,%edi
call   1030 <nvme_status_to_string@plt>
lea    0xeb0(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
mov    %ebx,%r8d
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fprintf@plt>
ret
lea    0xe8e(%rip),%rdi
jmp    1050 <perror@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"ioctl\00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"%s:%s(%04x)\0A\00"
define void @handle_nvme_error(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = call i8* @nvme_status_to_string(i32 %15)
%17 = load i32, i32* %4
%18 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16, i32 %17)
br label %19
19: ; preds = %12, %9
br label %20
20: ; preds = %19, %7
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"ioctl\00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"%s:%s(%04x)\0A\00"
define void @handle_nvme_error(i8* %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %2
%7 = icmp eq i32 %1, 0
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = load i32, i32* @stderr
%10 = tail call i8* @nvme_status_to_string(i32 %1)
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %10, i32 %1)
br label %12
12: ; preds = %6, %8, %4
ret void
}