#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 fb_cmap {
  struct fb_cmap *transp;
  struct fb_cmap *blue;
  struct fb_cmap *green;
  struct fb_cmap *red;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct fb_cmap *);
void fb_cmap_destroy(struct fb_cmap *cmap) {
  if (cmap->red)
    free(cmap->red);
  if (cmap->green)
    free(cmap->green);
  if (cmap->blue)
    free(cmap->blue);
  if (cmap->transp)
    free(cmap->transp);
  free(cmap);
}


x86 assembly (clang, -O0):
<fb_cmap_destroy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     1138 <fb_cmap_destroy+0x28>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1154 <fb_cmap_destroy+0x44>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1170 <fb_cmap_destroy+0x60>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     118a <fb_cmap_destroy+0x7a>
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):
<fb_cmap_destroy>:
push   %rbx
mov    %rdi,%rbx
mov    0x18(%rdi),%rdi
test   %rdi,%rdi
je     1122 <fb_cmap_destroy+0x12>
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     1130 <fb_cmap_destroy+0x20>
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     113e <fb_cmap_destroy+0x2e>
call   1030 <free@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     114b <fb_cmap_destroy+0x3b>
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

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

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