#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_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ color;
struct TYPE_4__ {
  int red;
  scalar_t__ green;
  scalar_t__ blue;
};
typedef TYPE_1__ XColor;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
int /*<<< orphan*/ DefaultColormap(int /*<<< orphan*/ *, int /*<<< orphan*/);
int EOF;
scalar_t__ XAllocColor(int /*<<< orphan*/ *, int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(char *);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ fatal(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, scalar_t__, scalar_t__, scalar_t__);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  Display *dpy;
  int opt, ncolors = 0, i;
  XColor *allocated;
  int nallocated;
  XColor color;
  Colormap cmap;
  while ((opt = getopt(argc, argv, "n:")) != EOF)
    switch (opt) {
    case 'n':
      ncolors = atoi(optarg);
      break;
    case '?':
      usage(argv[0]);
    }
  if (ncolors == 0)
    usage(argv[0]);
  dpy = XOpenDisplay("");
  if (dpy == NULL)
    fatal("Cannot open display");
  cmap = DefaultColormap(dpy, 0);
  allocated = (XColor *)malloc(ncolors * sizeof(*allocated));
  if (allocated == NULL) {
    fatal("Out of memory");
  }
  nallocated = 0;
  memset(&color, 0, sizeof(color));
  while ((nallocated < ncolors) && (color.red < 65536)) {
    allocated[nallocated] = color;
    if (XAllocColor(dpy, cmap, &allocated[nallocated])) {
      for (i = 0; i < nallocated; ++i)
        if ((allocated[i].red == allocated[nallocated].red) &&
            (allocated[i].green == allocated[nallocated].green) &&
            (allocated[i].blue == allocated[nallocated].blue))
          break;
      if (i == nallocated) {
        printf("allocated %d/%d/%d\n", allocated[nallocated].red,
               allocated[nallocated].green, allocated[nallocated].blue);
        ++nallocated;
      }
    }
    ++color.red;
    ++color.green;
    ++color.blue;
  }
  fprintf(stderr, "Waiting.  Press ^C to stop.\n");
  while (1)
    sleep(10);
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe15(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2de6(%rip),%rcx
cmp    (%rcx),%eax
je     124e <main+0x8e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x58(%rbp)
sub    $0x3f,%eax
je     123d <main+0x7d>
jmp    1216 <main+0x56>
mov    -0x58(%rbp),%eax
sub    $0x6e,%eax
jne    1249 <main+0x89>
jmp    1227 <main+0x67>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   10c0 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1249 <main+0x89>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
jmp    11dd <main+0x1d>
cmpl   $0x0,-0x20(%rbp)
jne    1264 <main+0xa4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
lea    0xdea(%rip),%rdi
call   1060 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    128b <main+0xcb>
lea    0xd7d(%rip),%rdi
call   10d0 <fatal@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10a0 <DefaultColormap@plt>
mov    %eax,-0x54(%rbp)
movslq -0x20(%rbp),%rax
imul   $0x18,%rax,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12c3 <main+0x103>
lea    0xd59(%rip),%rdi
call   10d0 <fatal@plt>
movl   $0x0,-0x34(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x34(%rbp),%ecx
xor    %eax,%eax
cmp    -0x20(%rbp),%ecx
mov    %al,-0x59(%rbp)
jge    12f8 <main+0x138>
cmpl   $0x10000,-0x50(%rbp)
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    1308 <main+0x148>
jmp    1482 <main+0x2c2>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    -0x50(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rcx
mov    %rcx,0x8(%rax)
mov    -0x40(%rbp),%rcx
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x30(%rbp),%rdx
movslq -0x34(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
call   1030 <XAllocColor@plt>
cmp    $0x0,%rax
je     145c <main+0x29c>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    13fe <main+0x23e>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%eax
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rdx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
cmp    (%rcx),%eax
jne    13eb <main+0x22b>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rdx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
cmp    0x8(%rcx),%rax
jne    13eb <main+0x22b>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rax
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rdx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
cmp    0x10(%rcx),%rax
jne    13eb <main+0x22b>
jmp    13fe <main+0x23e>
jmp    13f0 <main+0x230>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    135a <main+0x19a>
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    1457 <main+0x297>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq (%rax),%rsi
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rcx
lea    0xbdc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    145c <main+0x29c>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    12da <main+0x11a>
mov    0x2b47(%rip),%rax
mov    (%rax),%edi
lea    0xba7(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xa,%edi
call   10e0 <sleep@plt>
jmp    1497 <main+0x2d7>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xe36(%rip),%rdx
call   10b0 <getopt@plt>
mov    0x2dfa(%rip),%r15
cmp    (%r15),%eax
je     1238 <main+0x78>
xor    %r13d,%r13d
lea    0xe1b(%rip),%r14
mov    0x2dfc(%rip),%r12
jmp    121b <main+0x5b>
xchg   %ax,%ax
mov    0x0(%rbp),%rdi
call   1090 <usage@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
call   10b0 <getopt@plt>
cmp    (%r15),%eax
je     1233 <main+0x73>
cmp    $0x3f,%eax
je     1200 <main+0x40>
cmp    $0x6e,%eax
jne    1209 <main+0x49>
mov    (%r12),%edi
call   10c0 <atoi@plt>
mov    %eax,%r13d
jmp    1209 <main+0x49>
test   %r13d,%r13d
jne    1244 <main+0x84>
mov    0x0(%rbp),%rdi
call   1090 <usage@plt>
xor    %r13d,%r13d
lea    0xe1a(%rip),%rdi
call   1060 <XOpenDisplay@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1264 <main+0xa4>
lea    0xdb4(%rip),%rdi
call   10d0 <fatal@plt>
mov    %rbx,0x30(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <DefaultColormap@plt>
mov    %eax,0xc(%rsp)
lea    0x0(,%r13,8),%eax
lea    (%rax,%rax,2),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    129b <main+0xdb>
lea    0xd91(%rip),%rdi
call   10d0 <fatal@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
test   %r13d,%r13d
jle    13b3 <main+0x1f3>
cmpl   $0xffff,0x10(%rsp)
jg     13b3 <main+0x1f3>
lea    0x10(%r14),%rax
mov    %rax,0x28(%rsp)
xor    %r12d,%r12d
nop
movslq %r12d,%rax
lea    (%rax,%rax,2),%r15
lea    (%r14,%r15,8),%rbx
mov    0x20(%rsp),%rax
mov    %rax,0x10(%r14,%r15,8)
movdqu 0x10(%rsp),%xmm0
movdqu %xmm0,(%r14,%r15,8)
mov    0x30(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %rbx,%rdx
call   1030 <XAllocColor@plt>
test   %rax,%rax
je     1384 <main+0x1c4>
test   %r12d,%r12d
jle    1360 <main+0x1a0>
mov    (%rbx),%ecx
lea    (%r14,%r15,8),%rdx
add    $0x8,%rdx
mov    %r12d,%esi
mov    0x28(%rsp),%rdi
xor    %eax,%eax
jmp    133d <main+0x17d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
add    $0x18,%rdi
cmp    %rax,%rsi
je     1367 <main+0x1a7>
cmp    %ecx,-0x10(%rdi)
jne    1330 <main+0x170>
mov    -0x8(%rdi),%rbp
cmp    (%rdx),%rbp
jne    1330 <main+0x170>
mov    (%rdi),%rbp
cmp    0x8(%rdx),%rbp
jne    1330 <main+0x170>
jmp    1362 <main+0x1a2>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
cmp    %r12d,%eax
jne    1384 <main+0x1c4>
movslq (%rbx),%rsi
mov    0x8(%r14,%r15,8),%rdx
mov    0x10(%r14,%r15,8),%rcx
lea    0xcba(%rip),%rdi
call   1040 <printf@plt>
add    $0x1,%r12d
mov    0x10(%rsp),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x10(%rsp)
movdqu 0x18(%rsp),%xmm0
psubq  0xc63(%rip),%xmm0
movdqu %xmm0,0x18(%rsp)
cmp    %r13d,%r12d
jge    13b3 <main+0x1f3>
cmp    $0xffff,%eax
jl     12d0 <main+0x110>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
lea    0xc86(%rip),%rsi
call   1070 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   10e0 <sleep@plt>
jmp    13d0 <main+0x210>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i64, i64 }
@.str = [3 x i8] c"n:\00"
@EOF = global i32 0
@optarg = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [20 x i8] c"Cannot open display\00"
@.str.3 = [14 x i8] c"Out of memory\00"
@.str.4 = [20 x i8] c"allocated %d/%d/%d\0A\00"
@stderr = global i32 0
@.str.5 = [29 x i8] c"Waiting. Press ^C to stop.\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 i32
%9 = alloca i32
%10 = alloca %struct.TYPE_4__*
%11 = alloca i32
%12 = alloca %struct.TYPE_4__
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
br label %14
14: ; preds = %30, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %7
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %14
%21 = load i32, i32* %7
switch i32 %21, label %30 [
i32 110, label %22
i32 63, label %25
]
22: ; preds = %20
%23 = load i32, i32* @optarg
%24 = call i32 @atoi(i32 %23)
store i32 %24, i32* %8
br label %30
25: ; preds = %20
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @usage(i8* %28)
br label %30
30: ; preds = %25, %20, %22
br label %14
31: ; preds = %14
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @usage(i8* %37)
br label %39
39: ; preds = %34, %31
%40 = call i32* @XOpenDisplay(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32* %40, i32** %6
%41 = load i32*, i32** %6
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @fatal(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
%46 = load i32*, i32** %6
%47 = call i32 @DefaultColormap(i32* %46, i32 0)
store i32 %47, i32* %13
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = mul i64 %49, 24
%51 = trunc i64 %50 to i32
%52 = call i64 @malloc(i32 %51)
%53 = inttoptr i64 %52 to %struct.TYPE_4__*
store %struct.TYPE_4__* %53, %struct.TYPE_4__** %10
%54 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%55 = icmp eq %struct.TYPE_4__* %54, null
br i1 %55, label %56, label %58
56: ; preds = %45
%57 = call i32 @fatal(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %45
store i32 0, i32* %11
%59 = call i32 @memset(%struct.TYPE_4__* %12, i32 0, i32 24)
br label %60
60: ; preds = %165, %58
%61 = load i32, i32* %11
%62 = load i32, i32* %8
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
%66 = load i32, i32* %65
%67 = icmp slt i32 %66, 65536
br label %68
68: ; preds = %64, %60
%69 = phi i1 [ false, %60 ], [ %67, %64 ]
br i1 %69, label %70, label %175
70: ; preds = %68
%71 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%72 = load i32, i32* %11
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %71, i64 %73
%75 = bitcast %struct.TYPE_4__* %74 to i8*
%76 = bitcast %struct.TYPE_4__* %12 to i8*
%77 = load i32*, i32** %6
%78 = load i32, i32* %13
%79 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%80 = load i32, i32* %11
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %79, i64 %81
%83 = call i64 @XAllocColor(i32* %77, i32 %78, %struct.TYPE_4__* %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %165
85: ; preds = %70
store i32 0, i32* %9
br label %86
86: ; preds = %134, %85
%87 = load i32, i32* %9
%88 = load i32, i32* %11
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %137
90: ; preds = %86
%91 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%92 = load i32, i32* %9
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %91, i64 %93
%95 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %94, i32 0, i32 0
%96 = load i32, i32* %95
%97 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%98 = load i32, i32* %11
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %97, i64 %99
%101 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %100, i32 0, i32 0
%102 = load i32, i32* %101
%103 = icmp eq i32 %96, %102
br i1 %103, label %104, label %133
104: ; preds = %90
%105 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%106 = load i32, i32* %9
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %105, i64 %107
%109 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %108, i32 0, i32 1
%110 = load i64, i64* %109
%111 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%112 = load i32, i32* %11
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %111, i64 %113
%115 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %114, i32 0, i32 1
%116 = load i64, i64* %115
%117 = icmp eq i64 %110, %116
br i1 %117, label %118, label %133
118: ; preds = %104
%119 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%120 = load i32, i32* %9
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %119, i64 %121
%123 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %122, i32 0, i32 2
%124 = load i64, i64* %123
%125 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%126 = load i32, i32* %11
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %125, i64 %127
%129 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %128, i32 0, i32 2
%130 = load i64, i64* %129
%131 = icmp eq i64 %124, %130
br i1 %131, label %132, label %133
132: ; preds = %118
br label %137
133: ; preds = %118, %104, %90
br label %134
134: ; preds = %133
%135 = load i32, i32* %9
%136 = add nsw i32 %135, 1
store i32 %136, i32* %9
br label %86
137: ; preds = %132, %86
%138 = load i32, i32* %9
%139 = load i32, i32* %11
%140 = icmp eq i32 %138, %139
br i1 %140, label %141, label %164
141: ; preds = %137
%142 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%143 = load i32, i32* %11
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %142, i64 %144
%146 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %145, i32 0, i32 0
%147 = load i32, i32* %146
%148 = sext i32 %147 to i64
%149 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%150 = load i32, i32* %11
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %149, i64 %151
%153 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %152, i32 0, i32 1
%154 = load i64, i64* %153
%155 = load %struct.TYPE_4__*, %struct.TYPE_4__** %10
%156 = load i32, i32* %11
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %155, i64 %157
%159 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %158, i32 0, i32 2
%160 = load i64, i64* %159
%161 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 %148, i64 %154, i64 %160)
%162 = load i32, i32* %11
%163 = add nsw i32 %162, 1
store i32 %163, i32* %11
br label %164
164: ; preds = %141, %137
br label %165
165: ; preds = %164, %70
%166 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
%167 = load i32, i32* %166
%168 = add nsw i32 %167, 1
store i32 %168, i32* %166
%169 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 1
%170 = load i64, i64* %169
%171 = add nsw i64 %170, 1
store i64 %171, i64* %169
%172 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 2
%173 = load i64, i64* %172
%174 = add nsw i64 %173, 1
store i64 %174, i64* %172
br label %60
175: ; preds = %68
%176 = load i32, i32* @stderr
%177 = call i32 @fprintf(i32 %176, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %178
178: ; preds = %175, %178
%179 = call i32 @sleep(i32 10)
br label %178
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i64, i64 }
@.str = [3 x i8] c"n:\00"
@EOF = global i32 0
@optarg = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [20 x i8] c"Cannot open display\00"
@.str.3 = [14 x i8] c"Out of memory\00"
@.str.4 = [20 x i8] c"allocated %d/%d/%d\0A\00"
@stderr = global i32 0
@.str.5 = [29 x i8] c"Waiting. Press ^C to stop.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.TYPE_4__
%4 = bitcast %struct.TYPE_4__* %3 to i8*
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %24, label %8
8: ; preds = %2, %17
%9 = phi i32 [ %19, %17 ], [ %5, %2 ]
%10 = phi i32 [ %18, %17 ], [ 0, %2 ]
switch i32 %9, label %17 [
i32 110, label %11
i32 63, label %14
]
11: ; preds = %8
%12 = load i32, i32* @optarg
%13 = tail call i32 @atoi(i32 %12)
br label %17
14: ; preds = %8
%15 = load i8*, i8** %1
%16 = tail call i32 @usage(i8* %15)
br label %17
17: ; preds = %14, %8, %11
%18 = phi i32 [ %10, %8 ], [ %10, %14 ], [ %13, %11 ]
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %8
22: ; preds = %17
%23 = icmp eq i32 %18, 0
br i1 %23, label %24, label %27
24: ; preds = %2, %22
%25 = load i8*, i8** %1
%26 = tail call i32 @usage(i8* %25)
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ 0, %24 ], [ %18, %22 ]
%29 = tail call i32* @XOpenDisplay(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 @fatal(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = tail call i32 @DefaultColormap(i32* %29, i32 0)
%35 = mul i32 %28, 24
%36 = tail call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to %struct.TYPE_4__*
%38 = icmp eq i64 %36, 0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = tail call i32 @fatal(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %33
%42 = call i32 @memset(%struct.TYPE_4__* %3, i32 0, i32 24)
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%44 = icmp sgt i32 %28, 0
%45 = load i32, i32* %43
%46 = icmp slt i32 %45, 65536
%47 = select i1 %44, i1 %46, i1 false
br i1 %47, label %48, label %109
48: ; preds = %41
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 1
%50 = bitcast i64* %49 to <2 x i64>*
%51 = bitcast i64* %49 to <2 x i64>*
br label %52
52: ; preds = %48, %100
%53 = phi i32 [ 0, %48 ], [ %101, %100 ]
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %54
%56 = bitcast %struct.TYPE_4__* %55 to i8*
%57 = call i64 @XAllocColor(i32* %29, i32 %34, %struct.TYPE_4__* %55)
%58 = icmp eq i64 %57, 0
br i1 %58, label %100, label %59
59: ; preds = %52
%60 = icmp sgt i32 %53, 0
br i1 %60, label %61, label %87
61: ; preds = %59
%62 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %55, i64 0, i32 0
%63 = load i32, i32* %62
%64 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %54, i32 1
%65 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %54, i32 2
%66 = zext i32 %53 to i64
br label %67
67: ; preds = %61, %82
%68 = phi i64 [ 0, %61 ], [ %83, %82 ]
%69 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %68, i32 0
%70 = load i32, i32* %69
%71 = icmp eq i32 %70, %63
br i1 %71, label %72, label %82
72: ; preds = %67
%73 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %68, i32 1
%74 = load i64, i64* %73
%75 = load i64, i64* %64
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %82
77: ; preds = %72
%78 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %68, i32 2
%79 = load i64, i64* %78
%80 = load i64, i64* %65
%81 = icmp eq i64 %79, %80
br i1 %81, label %85, label %82
82: ; preds = %67, %72, %77
%83 = add nuw nsw i64 %68, 1
%84 = icmp eq i64 %83, %66
br i1 %84, label %90, label %67
85: ; preds = %77
%86 = trunc i64 %68 to i32
br label %87
87: ; preds = %85, %59
%88 = phi i32 [ 0, %59 ], [ %86, %85 ]
%89 = icmp eq i32 %88, %53
br i1 %89, label %90, label %100
90: ; preds = %82, %87
%91 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %55, i64 0, i32 0
%92 = load i32, i32* %91
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %54, i32 1
%95 = load i64, i64* %94
%96 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 %54, i32 2
%97 = load i64, i64* %96
%98 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 %93, i64 %95, i64 %97)
%99 = add nsw i32 %53, 1
br label %100
100: ; preds = %87, %90, %52
%101 = phi i32 [ %99, %90 ], [ %53, %87 ], [ %53, %52 ]
%102 = load i32, i32* %43
%103 = add nsw i32 %102, 1
store i32 %103, i32* %43
%104 = load <2 x i64>, <2 x i64>* %50
%105 = add nsw <2 x i64> %104, <i64 1, i64 1>
store <2 x i64> %105, <2 x i64>* %51
%106 = icmp slt i32 %101, %28
%107 = icmp slt i32 %102, 65535
%108 = select i1 %106, i1 %107, i1 false
br i1 %108, label %52, label %109
109: ; preds = %100, %41
%110 = load i32, i32* @stderr
%111 = call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %112
112: ; preds = %112, %109
%113 = call i32 @sleep(i32 10)
br label %112
}