#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 sg_io_hdr {
  struct sg_io_hdr *cmdp;
  struct sg_io_hdr *sbp;
  struct sg_io_hdr *dxferp;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct sg_io_hdr *);
void disk_sn_hdr_destroy(struct sg_io_hdr *phdr) {
  if (!phdr)
    return;
  if (phdr->dxferp)
    free(phdr->dxferp);
  if (phdr->sbp)
    free(phdr->sbp);
  if (phdr->cmdp)
    free(phdr->cmdp);
  free(phdr);
}


x86 assembly (clang, -O0):
<disk_sn_hdr_destroy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <disk_sn_hdr_destroy+0x1c>
jmp    1187 <disk_sn_hdr_destroy+0x77>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1148 <disk_sn_hdr_destroy+0x38>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1164 <disk_sn_hdr_destroy+0x54>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     117e <disk_sn_hdr_destroy+0x6e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disk_sn_hdr_destroy>:
test   %rdi,%rdi
je     114b <disk_sn_hdr_destroy+0x3b>
push   %rbx
mov    %rdi,%rbx
mov    0x10(%rdi),%rdi
test   %rdi,%rdi
je     1127 <disk_sn_hdr_destroy+0x17>
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1135 <disk_sn_hdr_destroy+0x25>
call   1030 <free@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1142 <disk_sn_hdr_destroy+0x32>
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>
ret

LLVM IR (-O0):
%struct.sg_io_hdr = type { %struct.sg_io_hdr*, %struct.sg_io_hdr*, %struct.sg_io_hdr* }
define void @disk_sn_hdr_destroy(%struct.sg_io_hdr* %0) {
%2 = alloca %struct.sg_io_hdr*
store %struct.sg_io_hdr* %0, %struct.sg_io_hdr** %2
%3 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%4 = icmp ne %struct.sg_io_hdr* %3, null
br i1 %4, label %6, label %5
5: ; preds = %1
br label %39
6: ; preds = %1
%7 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%8 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i32 0, i32 2
%9 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %8
%10 = icmp ne %struct.sg_io_hdr* %9, null
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%13 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 2
%14 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %13
%15 = call i32 @free(%struct.sg_io_hdr* %14)
br label %16
16: ; preds = %11, %6
%17 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%18 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %17, i32 0, i32 1
%19 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %18
%20 = icmp ne %struct.sg_io_hdr* %19, null
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%23 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %22, i32 0, i32 1
%24 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %23
%25 = call i32 @free(%struct.sg_io_hdr* %24)
br label %26
26: ; preds = %21, %16
%27 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%28 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %27, i32 0, i32 0
%29 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %28
%30 = icmp ne %struct.sg_io_hdr* %29, null
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%33 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %32, i32 0, i32 0
%34 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %33
%35 = call i32 @free(%struct.sg_io_hdr* %34)
br label %36
36: ; preds = %31, %26
%37 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %2
%38 = call i32 @free(%struct.sg_io_hdr* %37)
br label %39
39: ; preds = %36, %5
ret void
}

LLVM IR (-O2):
%struct.sg_io_hdr = type { %struct.sg_io_hdr*, %struct.sg_io_hdr*, %struct.sg_io_hdr* }
define void @disk_sn_hdr_destroy(%struct.sg_io_hdr* %0) {
%2 = icmp eq %struct.sg_io_hdr* %0, null
br i1 %2, label %23, label %3
3: ; preds = %1
%4 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %0, i64 0, i32 2
%5 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %4
%6 = icmp eq %struct.sg_io_hdr* %5, null
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @free(%struct.sg_io_hdr* %5)
br label %9
9: ; preds = %7, %3
%10 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %0, i64 0, i32 1
%11 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %10
%12 = icmp eq %struct.sg_io_hdr* %11, null
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @free(%struct.sg_io_hdr* %11)
br label %15
15: ; preds = %13, %9
%16 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %0, i64 0, i32 0
%17 = load %struct.sg_io_hdr*, %struct.sg_io_hdr** %16
%18 = icmp eq %struct.sg_io_hdr* %17, null
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i32 @free(%struct.sg_io_hdr* %17)
br label %21
21: ; preds = %19, %15
%22 = tail call i32 @free(%struct.sg_io_hdr* %0)
br label %23
23: ; preds = %1, %21
ret void
}