#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 */
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Colormap;

/* Variables and functions */
scalar_t__ DefaultColormap(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ Error(char *);
scalar_t__ XCopyColormapAndFree(int /*<<< orphan*/ *, scalar_t__);
Colormap CopyColormapAndFree(Display *dpy, Colormap colormap) {
  if (colormap == DefaultColormap(dpy, DefaultScreen(dpy)))
    return XCopyColormapAndFree(dpy, colormap);
  Error("Visual type is not large enough to hold all colors of the image.");
  return (Colormap)0;
}


x86 assembly (clang, -O0):
<CopyColormapAndFree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <DefaultScreen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1050 <DefaultColormap@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    119a <CopyColormapAndFree+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <XCopyColormapAndFree@plt>
mov    %rax,-0x8(%rbp)
jmp    11ae <CopyColormapAndFree+0x6e>
lea    0xe5f(%rip),%rdi
call   1030 <Error@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyColormapAndFree>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1060 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <DefaultColormap@plt>
cmp    %r14,%rax
jne    1170 <CopyColormapAndFree+0x30>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <XCopyColormapAndFree@plt>
lea    0xe89(%rip),%rdi
call   1030 <Error@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [65 x i8] c"Visual type is not large enough to hold all colors of the image.\00"
define i64 @CopyColormapAndFree(i32* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = load i32*, i32** %4
%8 = load i32*, i32** %4
%9 = call i32 @DefaultScreen(i32* %8)
%10 = call i64 @DefaultColormap(i32* %7, i32 %9)
%11 = icmp eq i64 %6, %10
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = load i64, i64* %5
%15 = call i64 @XCopyColormapAndFree(i32* %13, i64 %14)
store i64 %15, i64* %3
br label %18
16: ; preds = %2
%17 = call i32 @Error(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %3
br label %18
18: ; preds = %16, %12
%19 = load i64, i64* %3
ret i64 %19
}

LLVM IR (-O2):
@.str = [65 x i8] c"Visual type is not large enough to hold all colors of the image.\00"
define i64 @CopyColormapAndFree(i32* %0, i64 %1) {
%3 = tail call i32 @DefaultScreen(i32* %0)
%4 = tail call i64 @DefaultColormap(i32* %0, i32 %3)
%5 = icmp eq i64 %4, %1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i64 @XCopyColormapAndFree(i32* %0, i64 %1)
br label %10
8: ; preds = %2
%9 = tail call i32 @Error(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = phi i64 [ %7, %6 ], [ 0, %8 ]
ret i64 %11
}