#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 udev {
  int dummy;
};
typedef int /*<<< orphan*/ err;

/* Variables and functions */
int /*<<< orphan*/ udev_log_null(struct udev *, char *, char *, ...);
void info_scsi_cmd_err(struct udev *udev, char *cmd, int err) {
  if (err == -1) {
    udev_log_null(udev, "%s failed\n", cmd);
    return;
  }
  udev_log_null(udev, "%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh\n", cmd,
                (((err) >> 16) & 0xF), (((err) >> 8) & 0xFF), ((err)&0xFF));
}


x86 assembly (clang, -O0):
<info_scsi_cmd_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1148 <info_scsi_cmd_err+0x38>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <udev_log_null@plt>
jmp    1181 <info_scsi_cmd_err+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
sar    $0x10,%ecx
and    $0xf,%ecx
mov    -0x14(%rbp),%r8d
sar    $0x8,%r8d
and    $0xff,%r8d
mov    -0x14(%rbp),%r9d
and    $0xff,%r9d
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <udev_log_null@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<info_scsi_cmd_err>:
mov    %edx,%eax
mov    %rsi,%rdx
cmp    $0xffffffff,%eax
je     113c <info_scsi_cmd_err+0x2c>
push   %rbx
mov    %eax,%ecx
shr    $0x10,%ecx
and    $0xf,%ecx
movzbl %ah,%ebx
movzbl %al,%r9d
lea    0xeda(%rip),%rsi
mov    %ebx,%r8d
xor    %eax,%eax
pop    %rbx
jmp    1030 <udev_log_null@plt>
lea    0xebd(%rip),%rsi
xor    %eax,%eax
jmp    1030 <udev_log_null@plt>

LLVM IR (-O0):
%struct.udev = type { i32 }
@.str = [11 x i8] c"%s failed\0A\00"
@.str.1 = [43 x i8] c"%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh\0A\00"
define void @info_scsi_cmd_err(%struct.udev* %0, i8* %1, i32 %2) {
%4 = alloca %struct.udev*
%5 = alloca i8*
%6 = alloca i32
store %struct.udev* %0, %struct.udev** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load %struct.udev*, %struct.udev** %4
%11 = load i8*, i8** %5
%12 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %25
13: ; preds = %3
%14 = load %struct.udev*, %struct.udev** %4
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = ashr i32 %16, 16
%18 = and i32 %17, 15
%19 = load i32, i32* %6
%20 = ashr i32 %19, 8
%21 = and i32 %20, 255
%22 = load i32, i32* %6
%23 = and i32 %22, 255
%24 = call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %18, i32 %21, i32 %23)
br label %25
25: ; preds = %13, %9
ret void
}

LLVM IR (-O2):
%struct.udev = type { i32 }
@.str = [11 x i8] c"%s failed\0A\00"
@.str.1 = [43 x i8] c"%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh\0A\00"
define void @info_scsi_cmd_err(%struct.udev* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, -1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %14
7: ; preds = %3
%8 = lshr i32 %2, 16
%9 = and i32 %8, 15
%10 = lshr i32 %2, 8
%11 = and i32 %10, 255
%12 = and i32 %2, 255
%13 = tail call i32 (%struct.udev*, i8*, i8*, ...) @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %9, i32 %11, i32 %12)
br label %14
14: ; preds = %7, %5
ret void
}