#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 tcb {
  int dummy;
};
struct sg_io_hdr {
  scalar_t__ dxfer_direction;
  int /*<<< orphan*/ info;
  int /*<<< orphan*/ duration;
  int /*<<< orphan*/ resid;
  int /*<<< orphan*/ driver_status;
  int /*<<< orphan*/ host_status;
  int /*<<< orphan*/ sb_len_wr;
  int /*<<< orphan*/ sbp;
  int /*<<< orphan*/ masked_status;
  int /*<<< orphan*/ status;
  int /*<<< orphan*/ dxfer_len;
  scalar_t__ dxferp;
};

/* Variables and functions */
scalar_t__ SG_DXFER_FROM_DEV;
scalar_t__ SG_DXFER_TO_FROM_DEV;
int /*<<< orphan*/ print_sg_io_buffer(struct tcb *, int /*<<< orphan*/,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ printstr(struct tcb *, unsigned long, int /*<<< orphan*/);
int /*<<< orphan*/ tprintf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ tprints(char *);
void print_sg_io_res(struct tcb *tcp, struct sg_io_hdr *sg_io) {
  if (sg_io->dxfer_direction == SG_DXFER_FROM_DEV ||
      sg_io->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
    tprintf(", data[%u]=[", sg_io->dxfer_len);
    printstr(tcp, (unsigned long)sg_io->dxferp, sg_io->dxfer_len);
    tprints("]");
  }
  tprintf(", status=%02x, ", sg_io->status);
  tprintf("masked_status=%02x, ", sg_io->masked_status);
  tprintf("sb[%u]=[", sg_io->sb_len_wr);
  print_sg_io_buffer(tcp, sg_io->sbp, sg_io->sb_len_wr);
  tprintf("], host_status=%#x, ", sg_io->host_status);
  tprintf("driver_status=%#x, ", sg_io->driver_status);
  tprintf("resid=%d, ", sg_io->resid);
  tprintf("duration=%d, ", sg_io->duration);
  tprintf("info=%#x}", sg_io->info);
}


x86 assembly (clang, -O0):
<print_sg_io_res>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     117e <print_sg_io_res+0x3e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <print_sg_io_res+0x75>
mov    -0x10(%rbp),%rax
mov    0x2c(%rax),%esi
lea    0xe74(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x2c(%rax),%edx
call   1040 <printstr@plt>
lea    0xe5d(%rip),%rdi
call   1060 <tprints@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%esi
lea    0xe4c(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x24(%rax),%esi
lea    0xe49(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x1c(%rax),%esi
lea    0xe4b(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x1c(%rax),%edx
call   1050 <print_sg_io_buffer@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%esi
lea    0xe2a(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xe2c(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xe2d(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe25(%rip),%rdi
call   1030 <tprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe20(%rip),%rdi
call   1030 <tprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sg_io_res>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
je     1165 <print_sg_io_res+0x25>
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%rax
jne    118f <print_sg_io_res+0x4f>
mov    0x2c(%rbx),%esi
lea    0xe91(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x30(%rbx),%rsi
mov    0x2c(%rbx),%edx
mov    %r14,%rdi
call   1040 <printstr@plt>
lea    0xe83(%rip),%rdi
call   1060 <tprints@plt>
mov    0x28(%rbx),%esi
lea    0xe76(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x24(%rbx),%esi
lea    0xe77(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x1c(%rbx),%esi
lea    0xe7d(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x1c(%rbx),%edx
mov    0x20(%rbx),%esi
mov    %r14,%rdi
call   1050 <print_sg_io_buffer@plt>
mov    0x18(%rbx),%esi
lea    0xe69(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x14(%rbx),%esi
lea    0xe6f(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x10(%rbx),%esi
lea    0xe74(%rip),%rdi
call   1030 <tprintf@plt>
mov    0xc(%rbx),%esi
lea    0xe70(%rip),%rdi
call   1030 <tprintf@plt>
mov    0x8(%rbx),%esi
lea    0xe6f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <tprintf@plt>

LLVM IR (-O0):
%struct.tcb = type { i32 }
%struct.sg_io_hdr = type { i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }
@SG_DXFER_FROM_DEV = global i64 0
@SG_DXFER_TO_FROM_DEV = global i64 0
@.str = [13 x i8] c", data[%u]=[\00"
@.str.1 = [2 x i8] c"]\00"
@.str.2 = [16 x i8] c", status=%02x, \00"
@.str.3 = [21 x i8] c"masked_status=%02x, \00"
@.str.4 = [9 x i8] c"sb[%u]=[\00"
@.str.5 = [21 x i8] c"], host_status=%#x, \00"
@.str.6 = [20 x i8] c"driver_status=%#x, \00"
@.str.7 = [11 x i8] c"resid=%d, \00"
@.str.8 = [14 x i8] c"duration=%d, \00"
@.str.9 = [10 x i8] c"info=%#x}\00"
define void @print_sg_io_res(%struct.tcb* %0, %struct.sg_io_hdr* %1) {
%3 = alloca %struct.tcb*
%4 = alloca %struct.sg_io_hdr*
store %struct.tcb* %0, %struct.tcb** %3
store %struct.sg_io_hdr* %1, %struct.sg_io_hdr** %4
%5 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%6 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %5, i32 0, i32 0
%7 = load i64, i64* %6
%8 = load i64, i64* @SG_DXFER_FROM_DEV
%9 = icmp eq i64 %7, %8
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%12 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @SG_DXFER_TO_FROM_DEV
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %10, %2
%17 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%18 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %17, i32 0, i32 10
%19 = load i32, i32* %18
%20 = call i32 @tprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load %struct.tcb*, %struct.tcb** %3
%22 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%23 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %22, i32 0, i32 11
%24 = load i64, i64* %23
%25 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%26 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %25, i32 0, i32 10
%27 = load i32, i32* %26
%28 = call i32 @printstr(%struct.tcb* %21, i64 %24, i32 %27)
%29 = call i32 @tprints(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %16, %10
%31 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%32 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %31, i32 0, i32 9
%33 = load i32, i32* %32
%34 = call i32 @tprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%36 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %35, i32 0, i32 8
%37 = load i32, i32* %36
%38 = call i32 @tprintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%40 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %39, i32 0, i32 6
%41 = load i32, i32* %40
%42 = call i32 @tprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load %struct.tcb*, %struct.tcb** %3
%44 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%45 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %44, i32 0, i32 7
%46 = load i32, i32* %45
%47 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%48 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %47, i32 0, i32 6
%49 = load i32, i32* %48
%50 = call i32 @print_sg_io_buffer(%struct.tcb* %43, i32 %46, i32 %49)
%51 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%52 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %51, i32 0, i32 5
%53 = load i32, i32* %52
%54 = call i32 @tprintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%56 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %55, i32 0, i32 4
%57 = load i32, i32* %56
%58 = call i32 @tprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %57)
%59 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%60 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %59, i32 0, i32 3
%61 = load i32, i32* %60
%62 = call i32 @tprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %61)
%63 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%64 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %63, i32 0, i32 2
%65 = load i32, i32* %64
%66 = call i32 @tprintf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %65)
%67 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%68 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %67, i32 0, i32 1
%69 = load i32, i32* %68
%70 = call i32 @tprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %69)
ret void
}

LLVM IR (-O2):
%struct.tcb = type { i32 }
%struct.sg_io_hdr = type { i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }
@SG_DXFER_FROM_DEV = global i64 0
@SG_DXFER_TO_FROM_DEV = global i64 0
@.str = [13 x i8] c", data[%u]=[\00"
@.str.1 = [2 x i8] c"]\00"
@.str.2 = [16 x i8] c", status=%02x, \00"
@.str.3 = [21 x i8] c"masked_status=%02x, \00"
@.str.4 = [9 x i8] c"sb[%u]=[\00"
@.str.5 = [21 x i8] c"], host_status=%#x, \00"
@.str.6 = [20 x i8] c"driver_status=%#x, \00"
@.str.7 = [11 x i8] c"resid=%d, \00"
@.str.8 = [14 x i8] c"duration=%d, \00"
@.str.9 = [10 x i8] c"info=%#x}\00"
define void @print_sg_io_res(%struct.tcb* %0, %struct.sg_io_hdr* nocapture %1) {
%3 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 0
%4 = load i64, i64* %3
%5 = load i64, i64* @SG_DXFER_FROM_DEV
%6 = icmp eq i64 %4, %5
%7 = load i64, i64* @SG_DXFER_TO_FROM_DEV
%8 = icmp eq i64 %4, %7
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 10
%12 = load i32, i32* %11
%13 = tail call i32 @tprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 11
%15 = load i64, i64* %14
%16 = load i32, i32* %11
%17 = tail call i32 @printstr(%struct.tcb* %0, i64 %15, i32 %16)
%18 = tail call i32 @tprints(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %2, %10
%20 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 9
%21 = load i32, i32* %20
%22 = tail call i32 @tprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 8
%24 = load i32, i32* %23
%25 = tail call i32 @tprintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 6
%27 = load i32, i32* %26
%28 = tail call i32 @tprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 7
%30 = load i32, i32* %29
%31 = load i32, i32* %26
%32 = tail call i32 @print_sg_io_buffer(%struct.tcb* %0, i32 %30, i32 %31)
%33 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 5
%34 = load i32, i32* %33
%35 = tail call i32 @tprintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 4
%37 = load i32, i32* %36
%38 = tail call i32 @tprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 3
%40 = load i32, i32* %39
%41 = tail call i32 @tprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 2
%43 = load i32, i32* %42
%44 = tail call i32 @tprintf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %1, i64 0, i32 1
%46 = load i32, i32* %45
%47 = tail call i32 @tprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %46)
ret void
}