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

/* Type definitions */
struct TYPE_5__ {
  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 *);
TYPE_1__ *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 = malloc(ncolors * sizeof *allocated);
  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    0xddc(%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)
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    12e1 <main+0x121>
cmpl   $0x10000,-0x50(%rbp)
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    12f1 <main+0x131>
jmp    146b <main+0x2ab>
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     1445 <main+0x285>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    13e7 <main+0x227>
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    13d4 <main+0x214>
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    13d4 <main+0x214>
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    13d4 <main+0x214>
jmp    13e7 <main+0x227>
jmp    13d9 <main+0x219>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1343 <main+0x183>
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    1440 <main+0x280>
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    0xbe5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1445 <main+0x285>
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    12c3 <main+0x103>
mov    0x2b5e(%rip),%rax
mov    (%rax),%edi
lea    0xbb0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xa,%edi
call   10e0 <sleep@plt>
jmp    1480 <main+0x2c0>

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    0xe0c(%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
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
test   %r13d,%r13d
jle    13a3 <main+0x1e3>
cmpl   $0xffff,0x10(%rsp)
jg     13a3 <main+0x1e3>
lea    0x10(%r14),%rax
mov    %rax,0x28(%rsp)
xor    %r12d,%r12d
xchg   %ax,%ax
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     1374 <main+0x1b4>
test   %r12d,%r12d
jle    1350 <main+0x190>
mov    (%rbx),%ecx
lea    (%r14,%r15,8),%rdx
add    $0x8,%rdx
mov    %r12d,%esi
mov    0x28(%rsp),%rdi
xor    %eax,%eax
jmp    132d <main+0x16d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
add    $0x18,%rdi
cmp    %rax,%rsi
je     1357 <main+0x197>
cmp    %ecx,-0x10(%rdi)
jne    1320 <main+0x160>
mov    -0x8(%rdi),%rbp
cmp    (%rdx),%rbp
jne    1320 <main+0x160>
mov    (%rdi),%rbp
cmp    0x8(%rdx),%rbp
jne    1320 <main+0x160>
jmp    1352 <main+0x192>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
cmp    %r12d,%eax
jne    1374 <main+0x1b4>
movslq (%rbx),%rsi
mov    0x8(%r14,%r15,8),%rdx
mov    0x10(%r14,%r15,8),%rcx
lea    0xcbc(%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  0xc73(%rip),%xmm0
movdqu %xmm0,0x18(%rsp)
cmp    %r13d,%r12d
jge    13a3 <main+0x1e3>
cmp    $0xffff,%eax
jl     12c0 <main+0x100>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
lea    0xc88(%rip),%rsi
call   1070 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   10e0 <sleep@plt>
jmp    13c0 <main+0x200>

LLVM IR (-O0):
%struct.TYPE_5__ = 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 = [20 x i8] c"allocated %d/%d/%d\0A\00"
@stderr = global i32 0
@.str.4 = [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_5__*
%11 = alloca i32
%12 = alloca %struct.TYPE_5__
%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 %struct.TYPE_5__* @malloc(i32 %51)
store %struct.TYPE_5__* %52, %struct.TYPE_5__** %10
store i32 0, i32* %11
%53 = call i32 @memset(%struct.TYPE_5__* %12, i32 0, i32 24)
br label %54
54: ; preds = %159, %45
%55 = load i32, i32* %11
%56 = load i32, i32* %8
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 0
%60 = load i32, i32* %59
%61 = icmp slt i32 %60, 65536
br label %62
62: ; preds = %58, %54
%63 = phi i1 [ false, %54 ], [ %61, %58 ]
br i1 %63, label %64, label %169
64: ; preds = %62
%65 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %65, i64 %67
%69 = bitcast %struct.TYPE_5__* %68 to i8*
%70 = bitcast %struct.TYPE_5__* %12 to i8*
%71 = load i32*, i32** %6
%72 = load i32, i32* %13
%73 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%74 = load i32, i32* %11
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %73, i64 %75
%77 = call i64 @XAllocColor(i32* %71, i32 %72, %struct.TYPE_5__* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %159
79: ; preds = %64
store i32 0, i32* %9
br label %80
80: ; preds = %128, %79
%81 = load i32, i32* %9
%82 = load i32, i32* %11
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %131
84: ; preds = %80
%85 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%86 = load i32, i32* %9
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %85, i64 %87
%89 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%92 = load i32, i32* %11
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %91, i64 %93
%95 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %94, i32 0, i32 0
%96 = load i32, i32* %95
%97 = icmp eq i32 %90, %96
br i1 %97, label %98, label %127
98: ; preds = %84
%99 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%100 = load i32, i32* %9
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %99, i64 %101
%103 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %102, i32 0, i32 1
%104 = load i64, i64* %103
%105 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%106 = load i32, i32* %11
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %105, i64 %107
%109 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %108, i32 0, i32 1
%110 = load i64, i64* %109
%111 = icmp eq i64 %104, %110
br i1 %111, label %112, label %127
112: ; preds = %98
%113 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%114 = load i32, i32* %9
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %113, i64 %115
%117 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %116, i32 0, i32 2
%118 = load i64, i64* %117
%119 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%120 = load i32, i32* %11
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %119, i64 %121
%123 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %122, i32 0, i32 2
%124 = load i64, i64* %123
%125 = icmp eq i64 %118, %124
br i1 %125, label %126, label %127
126: ; preds = %112
br label %131
127: ; preds = %112, %98, %84
br label %128
128: ; preds = %127
%129 = load i32, i32* %9
%130 = add nsw i32 %129, 1
store i32 %130, i32* %9
br label %80
131: ; preds = %126, %80
%132 = load i32, i32* %9
%133 = load i32, i32* %11
%134 = icmp eq i32 %132, %133
br i1 %134, label %135, label %158
135: ; preds = %131
%136 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%137 = load i32, i32* %11
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %136, i64 %138
%140 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %139, i32 0, i32 0
%141 = load i32, i32* %140
%142 = sext i32 %141 to i64
%143 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%144 = load i32, i32* %11
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %143, i64 %145
%147 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %146, i32 0, i32 1
%148 = load i64, i64* %147
%149 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%150 = load i32, i32* %11
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %149, i64 %151
%153 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %152, i32 0, i32 2
%154 = load i64, i64* %153
%155 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 %142, i64 %148, i64 %154)
%156 = load i32, i32* %11
%157 = add nsw i32 %156, 1
store i32 %157, i32* %11
br label %158
158: ; preds = %135, %131
br label %159
159: ; preds = %158, %64
%160 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 0
%161 = load i32, i32* %160
%162 = add nsw i32 %161, 1
store i32 %162, i32* %160
%163 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 1
%164 = load i64, i64* %163
%165 = add nsw i64 %164, 1
store i64 %165, i64* %163
%166 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 2
%167 = load i64, i64* %166
%168 = add nsw i64 %167, 1
store i64 %168, i64* %166
br label %54
169: ; preds = %62
%170 = load i32, i32* @stderr
%171 = call i32 @fprintf(i32 %170, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %172
172: ; preds = %169, %172
%173 = call i32 @sleep(i32 10)
br label %172
}

LLVM IR (-O2):
%struct.TYPE_5__ = 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 = [20 x i8] c"allocated %d/%d/%d\0A\00"
@stderr = global i32 0
@.str.4 = [29 x i8] c"Waiting. Press ^C to stop.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.TYPE_5__
%4 = bitcast %struct.TYPE_5__* %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 %struct.TYPE_5__* @malloc(i32 %35)
%37 = call i32 @memset(%struct.TYPE_5__* %3, i32 0, i32 24)
%38 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
%39 = icmp sgt i32 %28, 0
%40 = load i32, i32* %38
%41 = icmp slt i32 %40, 65536
%42 = select i1 %39, i1 %41, i1 false
br i1 %42, label %43, label %104
43: ; preds = %33
%44 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
%45 = bitcast i64* %44 to <2 x i64>*
%46 = bitcast i64* %44 to <2 x i64>*
br label %47
47: ; preds = %43, %95
%48 = phi i32 [ 0, %43 ], [ %96, %95 ]
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %49
%51 = bitcast %struct.TYPE_5__* %50 to i8*
%52 = call i64 @XAllocColor(i32* %29, i32 %34, %struct.TYPE_5__* %50)
%53 = icmp eq i64 %52, 0
br i1 %53, label %95, label %54
54: ; preds = %47
%55 = icmp sgt i32 %48, 0
br i1 %55, label %56, label %82
56: ; preds = %54
%57 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %50, i64 0, i32 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %49, i32 1
%60 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %49, i32 2
%61 = zext i32 %48 to i64
br label %62
62: ; preds = %56, %77
%63 = phi i64 [ 0, %56 ], [ %78, %77 ]
%64 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %63, i32 0
%65 = load i32, i32* %64
%66 = icmp eq i32 %65, %58
br i1 %66, label %67, label %77
67: ; preds = %62
%68 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %63, i32 1
%69 = load i64, i64* %68
%70 = load i64, i64* %59
%71 = icmp eq i64 %69, %70
br i1 %71, label %72, label %77
72: ; preds = %67
%73 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %63, i32 2
%74 = load i64, i64* %73
%75 = load i64, i64* %60
%76 = icmp eq i64 %74, %75
br i1 %76, label %80, label %77
77: ; preds = %62, %67, %72
%78 = add nuw nsw i64 %63, 1
%79 = icmp eq i64 %78, %61
br i1 %79, label %85, label %62
80: ; preds = %72
%81 = trunc i64 %63 to i32
br label %82
82: ; preds = %80, %54
%83 = phi i32 [ 0, %54 ], [ %81, %80 ]
%84 = icmp eq i32 %83, %48
br i1 %84, label %85, label %95
85: ; preds = %77, %82
%86 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %50, i64 0, i32 0
%87 = load i32, i32* %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %49, i32 1
%90 = load i64, i64* %89
%91 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %49, i32 2
%92 = load i64, i64* %91
%93 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 %88, i64 %90, i64 %92)
%94 = add nsw i32 %48, 1
br label %95
95: ; preds = %82, %85, %47
%96 = phi i32 [ %94, %85 ], [ %48, %82 ], [ %48, %47 ]
%97 = load i32, i32* %38
%98 = add nsw i32 %97, 1
store i32 %98, i32* %38
%99 = load <2 x i64>, <2 x i64>* %45
%100 = add nsw <2 x i64> %99, <i64 1, i64 1>
store <2 x i64> %100, <2 x i64>* %46
%101 = icmp slt i32 %96, %28
%102 = icmp slt i32 %97, 65535
%103 = select i1 %101, i1 %102, i1 false
br i1 %103, label %47, label %104
104: ; preds = %95, %33
%105 = load i32, i32* @stderr
%106 = call i32 @fprintf(i32 %105, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %107
107: ; preds = %107, %104
%108 = call i32 @sleep(i32 10)
br label %107
}