#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*/ U_swap4(int *, int);
int /*<<< orphan*/ bitmapcoreheader_swap(char *);
int /*<<< orphan*/ bitmapinfo_swap(char *);
int /*<<< orphan*/ memcpy(int *, char *, int);
void dibheader_swap(char *dh, int torev) {
  int Size;
  memcpy(&Size, dh, 4);
  if (!torev)
    U_swap4(&Size, 1);
  if (Size == 0xC) {
    bitmapcoreheader_swap(dh);
  } else {
    bitmapinfo_swap(dh);
  }
}


x86 assembly (clang, -O0):
<dibheader_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdi
mov    $0x4,%edx
call   1050 <memcpy@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1179 <dibheader_swap+0x39>
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <U_swap4@plt>
cmpl   $0xc,-0x10(%rbp)
jne    1191 <dibheader_swap+0x51>
mov    -0x8(%rbp),%rdi
call   1040 <bitmapcoreheader_swap@plt>
jmp    119a <dibheader_swap+0x5a>
mov    -0x8(%rbp),%rdi
call   1060 <bitmapinfo_swap@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dibheader_swap>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
test   %ebp,%ebp
je     116f <dibheader_swap+0x2f>
cmpl   $0xc,0x4(%rsp)
jne    1185 <dibheader_swap+0x45>
mov    %rbx,%rdi
call   1040 <bitmapcoreheader_swap@plt>
jmp    118d <dibheader_swap+0x4d>
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
call   1030 <U_swap4@plt>
cmpl   $0xc,0x4(%rsp)
je     1165 <dibheader_swap+0x25>
mov    %rbx,%rdi
call   1060 <bitmapinfo_swap@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @dibheader_swap(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @memcpy(i32* %5, i8* %6, i32 4)
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = call i32 @U_swap4(i32* %5, i32 1)
br label %12
12: ; preds = %10, %2
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 12
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = call i32 @bitmapcoreheader_swap(i8* %16)
br label %21
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = call i32 @bitmapinfo_swap(i8* %19)
br label %21
21: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
define void @dibheader_swap(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @memcpy(i32* %3, i8* %0, i32 4)
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @U_swap4(i32* %3, i32 1)
br label %9
9: ; preds = %7, %2
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 12
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @bitmapcoreheader_swap(i8* %0)
br label %16
14: ; preds = %9
%15 = call i32 @bitmapinfo_swap(i8* %0)
br label %16
16: ; preds = %14, %12
ret void
}