#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 */
typedef struct TYPE_12__ TYPE_3__;
typedef struct TYPE_11__ TYPE_2__;
typedef struct TYPE_10__ TYPE_1__;

/* Type definitions */
struct TYPE_10__ {
  int bytes_per_line;
  int height;
  char *data;
};
typedef TYPE_1__ XImage;
struct TYPE_11__ {
  int flags;
  int red;
  int green;
  int blue;
  int /*<<< orphan*/ pixel;
  scalar_t__ pad;
};
typedef TYPE_2__ XColor;
struct TYPE_12__ {
  size_t class;
  int bits_per_rgb;
  int /*<<< orphan*/ blue_mask;
  int /*<<< orphan*/ green_mask;
  int /*<<< orphan*/ red_mask;
};
typedef TYPE_3__ Visual;
typedef int /*<<< orphan*/ Screen;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
size_t BitmapBitOrder(int /*<<< orphan*/ *);
int BitmapPad(int /*<<< orphan*/ *);
int BitmapUnit(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultColormapOfScreen(int /*<<< orphan*/ *);
unsigned int DefaultDepthOfScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ *DefaultScreenOfDisplay(int /*<<< orphan*/ *);
TYPE_3__ *DefaultVisualOfScreen(int /*<<< orphan*/ *);
int DoBlue;
int DoGreen;
int DoRed;
size_t ImageByteOrder(int /*<<< orphan*/ *);
int LSBFirst;
int MSBFirst;
int /*<<< orphan*/ XAllocColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_2__ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
TYPE_1__ *XCreateImage(int /*<<< orphan*/ *, TYPE_3__ *, unsigned int, int,
                       int /*<<< orphan*/, int /*<<< orphan*/, unsigned int,
                       unsigned int, int, int /*<<< orphan*/);
int /*<<< orphan*/ XDestroyImage(TYPE_1__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XPutPixel(TYPE_1__ *, int, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int ZPixmap;
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  Display *dpy = XOpenDisplay(NULL);
  Screen *screen = DefaultScreenOfDisplay(dpy);
  Visual *visual = DefaultVisualOfScreen(screen);
  Colormap colormap = DefaultColormapOfScreen(screen);
  unsigned int depth = DefaultDepthOfScreen(screen);
  int format, posn;
  int bitmap_pad;
  XImage *image;
  unsigned char *imageData;
  static char *orders[] = {"LSBFirst", "MSBFirst"};
  static char *types[] = {"StaticGray",  "GrayScale", "StaticColor",
                          "PseudoColor", "TrueColor", "DirectColor"};
  int clientOrder;
  union {
    short volatile value;
    unsigned char volatile buf[2];
  } un;
  XColor color;
  un.value = 0x0102;
  clientOrder = ((un.buf[0] == 0x02) ? LSBFirst : MSBFirst);
  printf("depth             = %d\n", (int)depth);
  printf("class             = %s\n", types[visual->class]);
  printf("bitmap_unit       = %d\n", BitmapUnit(dpy));
  printf("bitmap_pad        = %d\n", BitmapPad(dpy));
  printf("bit_order         = %s\n", orders[BitmapBitOrder(dpy)]);
  printf("image_byte_order  = %s\n", orders[ImageByteOrder(dpy)]);
  printf("client_byte_order = %s\n", orders[clientOrder]);
  printf("red_mask          = 0x%08lX\n", visual->red_mask);
  printf("green_mask        = 0x%08lX\n", visual->green_mask);
  printf("blue_mask         = 0x%08lX\n", visual->blue_mask);
  printf("bits_per_rgb      = %d\n", visual->bits_per_rgb);
  format = ZPixmap;
  if (depth <= 8) {
    bitmap_pad = 8;
  } else if (depth <= 16) {
    bitmap_pad = 16;
  } else {
    bitmap_pad = 32;
  }
  image = XCreateImage(dpy, visual, depth, format, 0, 0, (unsigned int)2,
                       (unsigned int)1, bitmap_pad, 0);
  if (!image) {
    return 0;
  }
  imageData = (unsigned char *)malloc(image->bytes_per_line * image->height);
  if (!imageData) {
    XDestroyImage(image);
    return 0;
  }
  image->data = (char *)imageData;
  color.flags = DoRed | DoGreen | DoBlue;
  color.red = 0xFF00;
  color.green = 0xAA00;
  color.blue = 0x3300;
  color.pad = 0;
  color.pixel = 0;
  XAllocColor(dpy, colormap, &color);
  printf("alloc(#FFAA33)    = 0x%08lX\n", color.pixel);
  XPutPixel(image, 0, 0, color.pixel);
  XPutPixel(image, 1, 0, color.pixel);
  printf("image_bytes       =");
  for (posn = 0; posn < (int)(image->bytes_per_line); ++posn) {
    printf(" %02X", (int)(imageData[posn]));
  }
  printf("\n");
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <DefaultScreenOfDisplay@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <DefaultVisualOfScreen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <DefaultColormapOfScreen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   10e0 <DefaultDepthOfScreen@plt>
mov    %eax,-0x30(%rbp)
movw   $0x102,-0x58(%rbp)
mov    -0x58(%rbp),%al
movzbl %al,%eax
cmp    $0x2,%eax
jne    127e <main+0x7e>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
jmp    128a <main+0x8a>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
lea    0x2e11(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <BitmapUnit@plt>
mov    %eax,%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1110 <BitmapPad@plt>
mov    %eax,%esi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <BitmapBitOrder@plt>
mov    %rax,%rcx
lea    0x2daa(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1120 <ImageByteOrder@plt>
mov    %rax,%rcx
lea    0x2d85(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x54(%rbp),%rcx
lea    0x2d68(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x8,-0x30(%rbp)
ja     13d0 <main+0x1d0>
movl   $0x8,-0x3c(%rbp)
jmp    13f2 <main+0x1f2>
cmpl   $0x10,-0x30(%rbp)
ja     13e6 <main+0x1e6>
movl   $0x10,-0x3c(%rbp)
jmp    13ed <main+0x1ed>
movl   $0x20,-0x3c(%rbp)
jmp    13f2 <main+0x1f2>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x3c(%rbp),%eax
xor    %r9d,%r9d
mov    %r9d,%r8d
movl   $0x2,(%rsp)
movl   $0x1,0x8(%rsp)
mov    %eax,0x10(%rsp)
movl   $0x0,0x18(%rsp)
call   1100 <XCreateImage@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1444 <main+0x244>
movl   $0x0,-0x4(%rbp)
jmp    1577 <main+0x377>
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rax
imul   0x4(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    147b <main+0x27b>
mov    -0x48(%rbp),%rdi
call   1050 <XDestroyImage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1577 <main+0x377>
mov    -0x50(%rbp),%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    0x2b4a(%rip),%rax
mov    (%rax),%eax
mov    0x2b21(%rip),%rcx
or     (%rcx),%eax
mov    0x2b20(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x78(%rbp)
movl   $0xff00,-0x74(%rbp)
movl   $0xaa00,-0x70(%rbp)
movl   $0x3300,-0x6c(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x78(%rbp),%rdx
call   1030 <XAllocColor@plt>
mov    -0x68(%rbp),%esi
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x68(%rbp),%ecx
xor    %edx,%edx
mov    %edx,%esi
call   10d0 <XPutPixel@plt>
mov    -0x48(%rbp),%rdi
mov    -0x68(%rbp),%ecx
mov    $0x1,%esi
xor    %edx,%edx
call   10d0 <XPutPixel@plt>
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x48(%rbp),%rcx
cmp    (%rcx),%eax
jge    1559 <main+0x359>
mov    -0x50(%rbp),%rax
movslq -0x38(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xc59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1522 <main+0x322>
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10f0 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <DefaultScreenOfDisplay@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <DefaultVisualOfScreen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   10c0 <DefaultColormapOfScreen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   10f0 <DefaultDepthOfScreen@plt>
mov    %eax,%r13d
movw   $0x102,0x6(%rsp)
mov    0x6(%rsp),%al
cmp    $0x2,%al
jne    126c <main+0x5c>
mov    0x2d7e(%rip),%rax
jmp    1273 <main+0x63>
mov    0x2d6d(%rip),%rax
movslq (%rax),%r12
lea    0xde8(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%rax
lea    0xf22(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   10b0 <BitmapUnit@plt>
lea    0xddf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1120 <BitmapPad@plt>
lea    0xddf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   10d0 <BitmapBitOrder@plt>
lea    0x2afa(%rip),%rbx
mov    (%rbx,%rax,8),%rsi
lea    0xdd4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1130 <ImageByteOrder@plt>
mov    (%rbx,%rax,8),%rsi
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r12,8),%rsi
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbp),%esi
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbp),%esi
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbp),%esi
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbp),%esi
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c61(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
cmp    $0x11,%r13d
setae  %al
shl    $0x4,%eax
add    $0x10,%eax
cmp    $0x9,%r13d
mov    $0x8,%ebx
cmovae %eax,%ebx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x0
push   %rbx
push   $0x1
push   $0x2
call   1110 <XCreateImage@plt>
add    $0x20,%rsp
test   %rax,%rax
je     14a7 <main+0x297>
mov    %rax,%rbx
mov    0x4(%rax),%edi
imul   (%rax),%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     149f <main+0x28f>
mov    %rax,%r12
mov    %rax,0x8(%rbx)
mov    0x2bff(%rip),%rax
mov    0x2bd8(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2bd5(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x8(%rsp)
movq   $0x0,0x20(%rsp)
movaps 0xbff(%rip),%xmm0
movups %xmm0,0xc(%rsp)
lea    0x8(%rsp),%rdx
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <XAllocColor@plt>
mov    0x18(%rsp),%esi
lea    0xd5b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%ecx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <XPutPixel@plt>
mov    0x18(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   10e0 <XPutPixel@plt>
lea    0xd47(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,(%rbx)
jle    148b <main+0x27b>
lea    0xd48(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
movslq (%rbx),%rax
cmp    %rax,%rbp
jl     1470 <main+0x260>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1100 <XCloseDisplay@plt>
jmp    14a7 <main+0x297>
mov    %rbx,%rdi
call   1060 <XDestroyImage@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_12__ = type { i64, i32, i32, i32, i32 }
%struct.TYPE_10__ = type { i32, i32, i8* }
%union.anon = type { i16 }
%struct.TYPE_11__ = type { i32, i32, i32, i32, i32, i64 }
@main.orders = internal global [2 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0)]
@.str = [9 x i8] c"LSBFirst\00"
@.str.1 = [9 x i8] c"MSBFirst\00"
@main.types = internal global [6 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i32 0, i32 0)]
@.str.2 = [11 x i8] c"StaticGray\00"
@.str.3 = [10 x i8] c"GrayScale\00"
@.str.4 = [12 x i8] c"StaticColor\00"
@.str.5 = [12 x i8] c"PseudoColor\00"
@.str.6 = [10 x i8] c"TrueColor\00"
@.str.7 = [12 x i8] c"DirectColor\00"
@LSBFirst = global i32 0
@MSBFirst = global i32 0
@.str.8 = [24 x i8] c"depth = %d\0A\00"
@.str.9 = [24 x i8] c"class = %s\0A\00"
@.str.10 = [24 x i8] c"bitmap_unit = %d\0A\00"
@.str.11 = [24 x i8] c"bitmap_pad = %d\0A\00"
@.str.12 = [24 x i8] c"bit_order = %s\0A\00"
@.str.13 = [24 x i8] c"image_byte_order = %s\0A\00"
@.str.14 = [24 x i8] c"client_byte_order = %s\0A\00"
@.str.15 = [29 x i8] c"red_mask = 0x%08lX\0A\00"
@.str.16 = [29 x i8] c"green_mask = 0x%08lX\0A\00"
@.str.17 = [29 x i8] c"blue_mask = 0x%08lX\0A\00"
@.str.18 = [24 x i8] c"bits_per_rgb = %d\0A\00"
@ZPixmap = global i32 0
@DoRed = global i32 0
@DoGreen = global i32 0
@DoBlue = global i32 0
@.str.19 = [29 x i8] c"alloc(#FFAA33) = 0x%08lX\0A\00"
@.str.20 = [20 x i8] c"image_bytes =\00"
@.str.21 = [6 x i8] c" %02X\00"
@.str.22 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca %struct.TYPE_12__*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.TYPE_10__*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca %union.anon
%18 = alloca %struct.TYPE_11__
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = call i32* @XOpenDisplay(i32* null)
store i32* %19, i32** %6
%20 = load i32*, i32** %6
%21 = call i32* @DefaultScreenOfDisplay(i32* %20)
store i32* %21, i32** %7
%22 = load i32*, i32** %7
%23 = call %struct.TYPE_12__* @DefaultVisualOfScreen(i32* %22)
store %struct.TYPE_12__* %23, %struct.TYPE_12__** %8
%24 = load i32*, i32** %7
%25 = call i32 @DefaultColormapOfScreen(i32* %24)
store i32 %25, i32* %9
%26 = load i32*, i32** %7
%27 = call i32 @DefaultDepthOfScreen(i32* %26)
store i32 %27, i32* %10
%28 = bitcast %union.anon* %17 to i16*
store volatile i16 258, i16* %28
%29 = bitcast %union.anon* %17 to [2 x i8]*
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %29, i64 0, i64 0
%31 = load volatile i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %36
34: ; preds = %2
%35 = load i32, i32* @LSBFirst
br label %38
36: ; preds = %2
%37 = load i32, i32* @MSBFirst
br label %38
38: ; preds = %36, %34
%39 = phi i32 [ %35, %34 ], [ %37, %36 ]
store i32 %39, i32* %16
%40 = load i32, i32* %10
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 %40)
%42 = load %struct.TYPE_12__*, %struct.TYPE_12__** %8
%43 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %42, i32 0, i32 0
%44 = load i64, i64* %43
%45 = getelementptr inbounds [6 x i8*], [6 x i8*]* @main.types, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %46)
%48 = load i32*, i32** %6
%49 = call i32 @BitmapUnit(i32* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %49)
%51 = load i32*, i32** %6
%52 = call i32 @BitmapPad(i32* %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %6
%55 = call i64 @BitmapBitOrder(i32* %54)
%56 = getelementptr inbounds [2 x i8*], [2 x i8*]* @main.orders, i64 0, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %57)
%59 = load i32*, i32** %6
%60 = call i64 @ImageByteOrder(i32* %59)
%61 = getelementptr inbounds [2 x i8*], [2 x i8*]* @main.orders, i64 0, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8* %62)
%64 = load i32, i32* %16
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [2 x i8*], [2 x i8*]* @main.orders, i64 0, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %67)
%69 = load %struct.TYPE_12__*, %struct.TYPE_12__** %8
%70 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %69, i32 0, i32 4
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0), i32 %71)
%73 = load %struct.TYPE_12__*, %struct.TYPE_12__** %8
%74 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %73, i32 0, i32 3
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0), i32 %75)
%77 = load %struct.TYPE_12__*, %struct.TYPE_12__** %8
%78 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %77, i32 0, i32 2
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i32 %79)
%81 = load %struct.TYPE_12__*, %struct.TYPE_12__** %8
%82 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %81, i32 0, i32 1
%83 = load i32, i32* %82
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0), i32 %83)
%85 = load i32, i32* @ZPixmap
store i32 %85, i32* %11
%86 = load i32, i32* %10
%87 = icmp ule i32 %86, 8
br i1 %87, label %88, label %89
88: ; preds = %38
store i32 8, i32* %13
br label %95
89: ; preds = %38
%90 = load i32, i32* %10
%91 = icmp ule i32 %90, 16
br i1 %91, label %92, label %93
92: ; preds = %89
store i32 16, i32* %13
br label %94
93: ; preds = %89
store i32 32, i32* %13
br label %94
94: ; preds = %93, %92
br label %95
95: ; preds = %94, %88
%96 = load i32*, i32** %6
%97 = load %struct.TYPE_12__*, %struct.TYPE_12__** %8
%98 = load i32, i32* %10
%99 = load i32, i32* %11
%100 = load i32, i32* %13
%101 = call %struct.TYPE_10__* @XCreateImage(i32* %96, %struct.TYPE_12__* %97, i32 %98, i32 %99, i32 0, i32 0, i32 2, i32 1, i32 %100, i32 0)
store %struct.TYPE_10__* %101, %struct.TYPE_10__** %14
%102 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%103 = icmp ne %struct.TYPE_10__* %102, null
br i1 %103, label %105, label %104
104: ; preds = %95
store i32 0, i32* %3
br label %171
105: ; preds = %95
%106 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%107 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %106, i32 0, i32 0
%108 = load i32, i32* %107
%109 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%110 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %109, i32 0, i32 1
%111 = load i32, i32* %110
%112 = mul nsw i32 %108, %111
%113 = call i64 @malloc(i32 %112)
%114 = inttoptr i64 %113 to i8*
store i8* %114, i8** %15
%115 = load i8*, i8** %15
%116 = icmp ne i8* %115, null
br i1 %116, label %120, label %117
117: ; preds = %105
%118 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%119 = call i32 @XDestroyImage(%struct.TYPE_10__* %118)
store i32 0, i32* %3
br label %171
120: ; preds = %105
%121 = load i8*, i8** %15
%122 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%123 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %122, i32 0, i32 2
store i8* %121, i8** %123
%124 = load i32, i32* @DoRed
%125 = load i32, i32* @DoGreen
%126 = or i32 %124, %125
%127 = load i32, i32* @DoBlue
%128 = or i32 %126, %127
%129 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 0
store i32 %128, i32* %129
%130 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 1
store i32 65280, i32* %130
%131 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 2
store i32 43520, i32* %131
%132 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 3
store i32 13056, i32* %132
%133 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 5
store i64 0, i64* %133
%134 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 4
store i32 0, i32* %134
%135 = load i32*, i32** %6
%136 = load i32, i32* %9
%137 = call i32 @XAllocColor(i32* %135, i32 %136, %struct.TYPE_11__* %18)
%138 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 4
%139 = load i32, i32* %138
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i32 %139)
%141 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%142 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 4
%143 = load i32, i32* %142
%144 = call i32 @XPutPixel(%struct.TYPE_10__* %141, i32 0, i32 0, i32 %143)
%145 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%146 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %18, i32 0, i32 4
%147 = load i32, i32* %146
%148 = call i32 @XPutPixel(%struct.TYPE_10__* %145, i32 1, i32 0, i32 %147)
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0))
store i32 0, i32* %12
br label %150
150: ; preds = %164, %120
%151 = load i32, i32* %12
%152 = load %struct.TYPE_10__*, %struct.TYPE_10__** %14
%153 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %152, i32 0, i32 0
%154 = load i32, i32* %153
%155 = icmp slt i32 %151, %154
br i1 %155, label %156, label %167
156: ; preds = %150
%157 = load i8*, i8** %15
%158 = load i32, i32* %12
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i8, i8* %157, i64 %159
%161 = load i8, i8* %160
%162 = zext i8 %161 to i32
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i32 %162)
br label %164
164: ; preds = %156
%165 = load i32, i32* %12
%166 = add nsw i32 %165, 1
store i32 %166, i32* %12
br label %150
167: ; preds = %150
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i64 0, i64 0))
%169 = load i32*, i32** %6
%170 = call i32 @XCloseDisplay(i32* %169)
store i32 0, i32* %3
br label %171
171: ; preds = %167, %117, %104
%172 = load i32, i32* %3
ret i32 %172
}

LLVM IR (-O2):
%struct.TYPE_11__ = type { i32, i32, i32, i32, i32, i64 }
%struct.TYPE_12__ = type { i64, i32, i32, i32, i32 }
%struct.TYPE_10__ = type { i32, i32, i8* }
@main.orders = internal unnamed_addr constant [2 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0)]
@.str = [9 x i8] c"LSBFirst\00"
@.str.1 = [9 x i8] c"MSBFirst\00"
@reltable.main = internal unnamed_addr constant [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.6 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
@.str.2 = [11 x i8] c"StaticGray\00"
@.str.3 = [10 x i8] c"GrayScale\00"
@.str.4 = [12 x i8] c"StaticColor\00"
@.str.5 = [12 x i8] c"PseudoColor\00"
@.str.6 = [10 x i8] c"TrueColor\00"
@.str.7 = [12 x i8] c"DirectColor\00"
@LSBFirst = global i32 0
@MSBFirst = global i32 0
@.str.8 = [24 x i8] c"depth = %d\0A\00"
@.str.9 = [24 x i8] c"class = %s\0A\00"
@.str.10 = [24 x i8] c"bitmap_unit = %d\0A\00"
@.str.11 = [24 x i8] c"bitmap_pad = %d\0A\00"
@.str.12 = [24 x i8] c"bit_order = %s\0A\00"
@.str.13 = [24 x i8] c"image_byte_order = %s\0A\00"
@.str.14 = [24 x i8] c"client_byte_order = %s\0A\00"
@.str.15 = [29 x i8] c"red_mask = 0x%08lX\0A\00"
@.str.16 = [29 x i8] c"green_mask = 0x%08lX\0A\00"
@.str.17 = [29 x i8] c"blue_mask = 0x%08lX\0A\00"
@.str.18 = [24 x i8] c"bits_per_rgb = %d\0A\00"
@ZPixmap = global i32 0
@DoRed = global i32 0
@DoGreen = global i32 0
@DoBlue = global i32 0
@.str.19 = [29 x i8] c"alloc(#FFAA33) = 0x%08lX\0A\00"
@.str.20 = [20 x i8] c"image_bytes =\00"
@.str.21 = [6 x i8] c" %02X\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i16
%4 = alloca %struct.TYPE_11__
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = tail call i32* @DefaultScreenOfDisplay(i32* %5)
%7 = tail call %struct.TYPE_12__* @DefaultVisualOfScreen(i32* %6)
%8 = tail call i32 @DefaultColormapOfScreen(i32* %6)
%9 = tail call i32 @DefaultDepthOfScreen(i32* %6)
%10 = bitcast i16* %3 to i8*
%11 = bitcast %struct.TYPE_11__* %4 to i8*
store volatile i16 258, i16* %3
%12 = load volatile i8, i8* %10
%13 = icmp eq i8 %12, 2
%14 = load i32, i32* @LSBFirst
%15 = load i32, i32* @MSBFirst
%16 = select i1 %13, i32 %14, i32 %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 %9)
%18 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %7, i64 0, i32 0
%19 = load i64, i64* %18
%20 = shl i64 %19, 2
%21 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %21)
%23 = tail call i32 @BitmapUnit(i32* %5)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %23)
%25 = tail call i32 @BitmapPad(i32* %5)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %25)
%27 = tail call i64 @BitmapBitOrder(i32* %5)
%28 = getelementptr inbounds [2 x i8*], [2 x i8*]* @main.orders, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %29)
%31 = tail call i64 @ImageByteOrder(i32* %5)
%32 = getelementptr inbounds [2 x i8*], [2 x i8*]* @main.orders, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8* %33)
%35 = sext i32 %16 to i64
%36 = getelementptr inbounds [2 x i8*], [2 x i8*]* @main.orders, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %7, i64 0, i32 4
%40 = load i32, i32* %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %7, i64 0, i32 3
%43 = load i32, i32* %42
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %7, i64 0, i32 2
%46 = load i32, i32* %45
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %7, i64 0, i32 1
%49 = load i32, i32* %48
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0), i32 %49)
%51 = load i32, i32* @ZPixmap
%52 = icmp ugt i32 %9, 16
%53 = select i1 %52, i32 32, i32 16
%54 = icmp ugt i32 %9, 8
%55 = select i1 %54, i32 %53, i32 8
%56 = tail call %struct.TYPE_10__* @XCreateImage(i32* %5, %struct.TYPE_12__* %7, i32 %9, i32 %51, i32 0, i32 0, i32 2, i32 1, i32 %55, i32 0)
%57 = icmp eq %struct.TYPE_10__* %56, null
br i1 %57, label %104, label %58
58: ; preds = %2
%59 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %56, i64 0, i32 0
%60 = load i32, i32* %59
%61 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %56, i64 0, i32 1
%62 = load i32, i32* %61
%63 = mul nsw i32 %62, %60
%64 = tail call i64 @malloc(i32 %63)
%65 = inttoptr i64 %64 to i8*
%66 = icmp eq i64 %64, 0
br i1 %66, label %67, label %69
67: ; preds = %58
%68 = tail call i32 @XDestroyImage(%struct.TYPE_10__* %56)
br label %104
69: ; preds = %58
%70 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %56, i64 0, i32 2
store i8* %65, i8** %70
%71 = load i32, i32* @DoRed
%72 = load i32, i32* @DoGreen
%73 = or i32 %72, %71
%74 = load i32, i32* @DoBlue
%75 = or i32 %73, %74
%76 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %4, i64 0, i32 0
store i32 %75, i32* %76
%77 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %4, i64 0, i32 1
%78 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %4, i64 0, i32 5
store i64 0, i64* %78
%79 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %4, i64 0, i32 4
%80 = bitcast i32* %77 to <4 x i32>*
store <4 x i32> <i32 65280, i32 43520, i32 13056, i32 0>, <4 x i32>* %80
%81 = call i32 @XAllocColor(i32* %5, i32 %8, %struct.TYPE_11__* %4)
%82 = load i32, i32* %79
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %79
%85 = call i32 @XPutPixel(%struct.TYPE_10__* %56, i32 0, i32 0, i32 %84)
%86 = load i32, i32* %79
%87 = call i32 @XPutPixel(%struct.TYPE_10__* %56, i32 1, i32 0, i32 %86)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0))
%89 = load i32, i32* %59
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %101
91: ; preds = %69, %91
%92 = phi i64 [ %97, %91 ], [ 0, %69 ]
%93 = getelementptr inbounds i8, i8* %65, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i32 %95)
%97 = add nuw nsw i64 %92, 1
%98 = load i32, i32* %59
%99 = sext i32 %98 to i64
%100 = icmp slt i64 %97, %99
br i1 %100, label %91, label %101
101: ; preds = %91, %69
%102 = call i32 @putchar(i32 10)
%103 = call i32 @XCloseDisplay(i32* %5)
br label %104
104: ; preds = %2, %101, %67
ret i32 0
}