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

/* Type definitions */
struct TYPE_6__ {
  int screen;
  int colormap_size;
  int red_mask;
  int green_mask;
  int blue_mask;
  scalar_t__ depth;
  int /*<<< orphan*/ visualid;
};
typedef TYPE_1__ XVisualInfo;
typedef scalar_t__ Status;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ DirectColor;
int /*<<< orphan*/ GrayScale;
int /*<<< orphan*/ PseudoColor;
int ScreenCount(int /*<<< orphan*/ *);
int /*<<< orphan*/ StaticColor;
int /*<<< orphan*/ StaticGray;
int /*<<< orphan*/ TrueColor;
long VisualScreenMask;
int /*<<< orphan*/ XFree(char *);
TYPE_1__ *XGetVisualInfo(int /*<<< orphan*/ *, long, TYPE_1__ *, int *);
scalar_t__ XmuVisualStandardColormaps(int /*<<< orphan*/ *, int,
                                      int /*<<< orphan*/, unsigned int, int,
                                      int);
TYPE_1__ *getDeepestVisual(int /*<<< orphan*/, TYPE_1__ *, int);
Status XmuAllStandardColormaps(Display *dpy) {
  int nvisuals, scr;
  Status status;
  long vinfo_mask;
  XVisualInfo template, *vinfo, *v1, *v2;
  status = 0;
  for (scr = 0; scr < ScreenCount(dpy); scr++) {
    template.screen = scr;
    vinfo_mask = VisualScreenMask;
    vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
    if (vinfo == NULL)
      continue;
    v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
    v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
    if (v2 && (!v1 || (v2->colormap_size >=
                       ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
      status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
                                          (unsigned)v2->depth, 1, 1);
    else if (v1)
      status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
                                          (unsigned)v1->depth, 1, 1);
    else {
      if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL) ||
          ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) != NULL))
        status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
                                            (unsigned)v1->depth, 1, 1);
      if (status &&
          (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL) ||
           ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) != NULL)))
        status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
                                            (unsigned)v1->depth, 1, 1);
    }
    XFree((char *)vinfo);
    if (!status)
      break;
  }
  return status;
}


x86 assembly (clang, -O0):
<XmuAllStandardColormaps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ScreenCount@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
cmp    %ecx,%eax
jge    13bd <XmuAllStandardColormaps+0x26d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0x2e54(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1040 <XGetVisualInfo@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    11c4 <XmuAllStandardColormaps+0x74>
jmp    13af <XmuAllStandardColormaps+0x25f>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <getDeepestVisual@plt>
mov    %rax,-0x58(%rbp)
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <getDeepestVisual@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1262 <XmuAllStandardColormaps+0x112>
cmpq   $0x0,-0x58(%rbp)
je     1233 <XmuAllStandardColormaps+0xe3>
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x58(%rbp),%rcx
mov    0x8(%rcx),%ecx
mov    -0x58(%rbp),%rdx
or     0xc(%rdx),%ecx
mov    -0x58(%rbp),%rdx
or     0x10(%rdx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jl     1262 <XmuAllStandardColormaps+0x112>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x60(%rbp),%rax
mov    0x20(%rax),%edx
mov    -0x60(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%ecx
mov    $0x1,%r9d
mov    %r9d,%r8d
call   1070 <XmuVisualStandardColormaps@plt>
mov    %rax,-0x18(%rbp)
jmp    1391 <XmuAllStandardColormaps+0x241>
cmpq   $0x0,-0x58(%rbp)
je     129c <XmuAllStandardColormaps+0x14c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x58(%rbp),%rax
mov    0x20(%rax),%edx
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%ecx
mov    $0x1,%r9d
mov    %r9d,%r8d
call   1070 <XmuVisualStandardColormaps@plt>
mov    %rax,-0x18(%rbp)
jmp    138c <XmuAllStandardColormaps+0x23c>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <getDeepestVisual@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    12e2 <XmuAllStandardColormaps+0x192>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <getDeepestVisual@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     130c <XmuAllStandardColormaps+0x1bc>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x58(%rbp),%rax
mov    0x20(%rax),%edx
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%ecx
mov    $0x1,%r9d
mov    %r9d,%r8d
call   1070 <XmuVisualStandardColormaps@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1387 <XmuAllStandardColormaps+0x237>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <getDeepestVisual@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    135d <XmuAllStandardColormaps+0x20d>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <getDeepestVisual@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     1387 <XmuAllStandardColormaps+0x237>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x58(%rbp),%rax
mov    0x20(%rax),%edx
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%ecx
mov    $0x1,%r9d
mov    %r9d,%r8d
call   1070 <XmuVisualStandardColormaps@plt>
mov    %rax,-0x18(%rbp)
jmp    138c <XmuAllStandardColormaps+0x23c>
jmp    1391 <XmuAllStandardColormaps+0x241>
mov    -0x50(%rbp),%rdi
call   1030 <XFree@plt>
cmpq   $0x0,-0x18(%rbp)
jne    13aa <XmuAllStandardColormaps+0x25a>
jmp    13bd <XmuAllStandardColormaps+0x26d>
jmp    13af <XmuAllStandardColormaps+0x25f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116b <XmuAllStandardColormaps+0x1b>
mov    -0x18(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XmuAllStandardColormaps>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r12
call   1050 <ScreenCount@plt>
test   %eax,%eax
jle    12fa <XmuAllStandardColormaps+0x1aa>
lea    0xc(%rsp),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    11cf <XmuAllStandardColormaps+0x7f>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rax
test   %r14,%r14
je     1251 <XmuAllStandardColormaps+0x101>
mov    0x18(%rax),%ecx
mov    0x20(%rax),%edx
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%r8d
mov    $0x1,%r9d
call   1070 <XmuVisualStandardColormaps@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1030 <XFree@plt>
test   %r13,%r13
je     12fa <XmuAllStandardColormaps+0x1aa>
add    $0x1,%ebp
mov    %r12,%rdi
call   1050 <ScreenCount@plt>
cmp    %eax,%ebp
jge    12fd <XmuAllStandardColormaps+0x1ad>
mov    %ebp,0x10(%rsp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%rsi
mov    %r12,%rdi
lea    0x10(%rsp),%rdx
mov    %r15,%rcx
call   1040 <XGetVisualInfo@plt>
test   %rax,%rax
je     11bc <XmuAllStandardColormaps+0x6c>
mov    %rax,%rbx
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
call   1060 <getDeepestVisual@plt>
mov    %rax,%r14
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
call   1060 <getDeepestVisual@plt>
test   %rax,%rax
je     1180 <XmuAllStandardColormaps+0x30>
test   %r14,%r14
je     118c <XmuAllStandardColormaps+0x3c>
mov    0xc(%r14),%ecx
or     0x8(%r14),%ecx
or     0x10(%r14),%ecx
cmp    %ecx,0x4(%rax)
jg     118c <XmuAllStandardColormaps+0x3c>
mov    %r14,%rax
jmp    118c <XmuAllStandardColormaps+0x3c>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
call   1060 <getDeepestVisual@plt>
test   %rax,%rax
jne    1285 <XmuAllStandardColormaps+0x135>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
call   1060 <getDeepestVisual@plt>
test   %rax,%rax
je     12a4 <XmuAllStandardColormaps+0x154>
mov    0x18(%rax),%ecx
mov    0x20(%rax),%edx
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%r8d
mov    $0x1,%r9d
call   1070 <XmuVisualStandardColormaps@plt>
mov    %rax,%r13
test   %r13,%r13
je     12f2 <XmuAllStandardColormaps+0x1a2>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
call   1060 <getDeepestVisual@plt>
test   %rax,%rax
jne    118c <XmuAllStandardColormaps+0x3c>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
mov    %rbx,%rsi
call   1060 <getDeepestVisual@plt>
test   %rax,%rax
jne    118c <XmuAllStandardColormaps+0x3c>
mov    %rbx,%rdi
call   1030 <XFree@plt>
jmp    11bc <XmuAllStandardColormaps+0x6c>
mov    %rbx,%rdi
call   1030 <XFree@plt>
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, i32, i32, i32, i32, i64, i32 }
@VisualScreenMask = global i64 0
@DirectColor = global i32 0
@PseudoColor = global i32 0
@TrueColor = global i32 0
@StaticColor = global i32 0
@GrayScale = global i32 0
@StaticGray = global i32 0
define i64 @XmuAllStandardColormaps(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca %struct.TYPE_6__
%8 = alloca %struct.TYPE_6__*
%9 = alloca %struct.TYPE_6__*
%10 = alloca %struct.TYPE_6__*
store i32* %0, i32** %2
store i64 0, i64* %5
store i32 0, i32* %4
br label %11
11: ; preds = %141, %1
%12 = load i32, i32* %4
%13 = load i32*, i32** %2
%14 = call i32 @ScreenCount(i32* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %144
16: ; preds = %11
%17 = load i32, i32* %4
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 0
store i32 %17, i32* %18
%19 = load i64, i64* @VisualScreenMask
store i64 %19, i64* %6
%20 = load i32*, i32** %2
%21 = load i64, i64* %6
%22 = call %struct.TYPE_6__* @XGetVisualInfo(i32* %20, i64 %21, %struct.TYPE_6__* %7, i32* %3)
store %struct.TYPE_6__* %22, %struct.TYPE_6__** %8
%23 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%24 = icmp eq %struct.TYPE_6__* %23, null
br i1 %24, label %25, label %26
25: ; preds = %16
br label %141
26: ; preds = %16
%27 = load i32, i32* @DirectColor
%28 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%29 = load i32, i32* %3
%30 = call %struct.TYPE_6__* @getDeepestVisual(i32 %27, %struct.TYPE_6__* %28, i32 %29)
store %struct.TYPE_6__* %30, %struct.TYPE_6__** %9
%31 = load i32, i32* @PseudoColor
%32 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%33 = load i32, i32* %3
%34 = call %struct.TYPE_6__* @getDeepestVisual(i32 %31, %struct.TYPE_6__* %32, i32 %33)
store %struct.TYPE_6__* %34, %struct.TYPE_6__** %10
%35 = load %struct.TYPE_6__*, %struct.TYPE_6__** %10
%36 = icmp ne %struct.TYPE_6__* %35, null
br i1 %36, label %37, label %68
37: ; preds = %26
%38 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%39 = icmp ne %struct.TYPE_6__* %38, null
br i1 %39, label %40, label %57
40: ; preds = %37
%41 = load %struct.TYPE_6__*, %struct.TYPE_6__** %10
%42 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%45 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %44, i32 0, i32 2
%46 = load i32, i32* %45
%47 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%48 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %47, i32 0, i32 3
%49 = load i32, i32* %48
%50 = or i32 %46, %49
%51 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%52 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %51, i32 0, i32 4
%53 = load i32, i32* %52
%54 = or i32 %50, %53
%55 = add nsw i32 %54, 1
%56 = icmp sge i32 %43, %55
br i1 %56, label %57, label %68
57: ; preds = %40, %37
%58 = load i32*, i32** %2
%59 = load i32, i32* %4
%60 = load %struct.TYPE_6__*, %struct.TYPE_6__** %10
%61 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %60, i32 0, i32 6
%62 = load i32, i32* %61
%63 = load %struct.TYPE_6__*, %struct.TYPE_6__** %10
%64 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %63, i32 0, i32 5
%65 = load i64, i64* %64
%66 = trunc i64 %65 to i32
%67 = call i64 @XmuVisualStandardColormaps(i32* %58, i32 %59, i32 %62, i32 %66, i32 1, i32 1)
store i64 %67, i64* %5
br label %133
68: ; preds = %40, %26
%69 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%70 = icmp ne %struct.TYPE_6__* %69, null
br i1 %70, label %71, label %82
71: ; preds = %68
%72 = load i32*, i32** %2
%73 = load i32, i32* %4
%74 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%75 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %74, i32 0, i32 6
%76 = load i32, i32* %75
%77 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%78 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %77, i32 0, i32 5
%79 = load i64, i64* %78
%80 = trunc i64 %79 to i32
%81 = call i64 @XmuVisualStandardColormaps(i32* %72, i32 %73, i32 %76, i32 %80, i32 1, i32 1)
store i64 %81, i64* %5
br label %132
82: ; preds = %68
%83 = load i32, i32* @TrueColor
%84 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%85 = load i32, i32* %3
%86 = call %struct.TYPE_6__* @getDeepestVisual(i32 %83, %struct.TYPE_6__* %84, i32 %85)
store %struct.TYPE_6__* %86, %struct.TYPE_6__** %9
%87 = icmp ne %struct.TYPE_6__* %86, null
br i1 %87, label %94, label %88
88: ; preds = %82
%89 = load i32, i32* @StaticColor
%90 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%91 = load i32, i32* %3
%92 = call %struct.TYPE_6__* @getDeepestVisual(i32 %89, %struct.TYPE_6__* %90, i32 %91)
store %struct.TYPE_6__* %92, %struct.TYPE_6__** %9
%93 = icmp ne %struct.TYPE_6__* %92, null
br i1 %93, label %94, label %105
94: ; preds = %88, %82
%95 = load i32*, i32** %2
%96 = load i32, i32* %4
%97 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%98 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %97, i32 0, i32 6
%99 = load i32, i32* %98
%100 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%101 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %100, i32 0, i32 5
%102 = load i64, i64* %101
%103 = trunc i64 %102 to i32
%104 = call i64 @XmuVisualStandardColormaps(i32* %95, i32 %96, i32 %99, i32 %103, i32 1, i32 1)
store i64 %104, i64* %5
br label %105
105: ; preds = %94, %88
%106 = load i64, i64* %5
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %131
108: ; preds = %105
%109 = load i32, i32* @GrayScale
%110 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%111 = load i32, i32* %3
%112 = call %struct.TYPE_6__* @getDeepestVisual(i32 %109, %struct.TYPE_6__* %110, i32 %111)
store %struct.TYPE_6__* %112, %struct.TYPE_6__** %9
%113 = icmp ne %struct.TYPE_6__* %112, null
br i1 %113, label %120, label %114
114: ; preds = %108
%115 = load i32, i32* @StaticGray
%116 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%117 = load i32, i32* %3
%118 = call %struct.TYPE_6__* @getDeepestVisual(i32 %115, %struct.TYPE_6__* %116, i32 %117)
store %struct.TYPE_6__* %118, %struct.TYPE_6__** %9
%119 = icmp ne %struct.TYPE_6__* %118, null
br i1 %119, label %120, label %131
120: ; preds = %114, %108
%121 = load i32*, i32** %2
%122 = load i32, i32* %4
%123 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%124 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %123, i32 0, i32 6
%125 = load i32, i32* %124
%126 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%127 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %126, i32 0, i32 5
%128 = load i64, i64* %127
%129 = trunc i64 %128 to i32
%130 = call i64 @XmuVisualStandardColormaps(i32* %121, i32 %122, i32 %125, i32 %129, i32 1, i32 1)
store i64 %130, i64* %5
br label %131
131: ; preds = %120, %114, %105
br label %132
132: ; preds = %131, %71
br label %133
133: ; preds = %132, %57
%134 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%135 = bitcast %struct.TYPE_6__* %134 to i8*
%136 = call i32 @XFree(i8* %135)
%137 = load i64, i64* %5
%138 = icmp ne i64 %137, 0
br i1 %138, label %140, label %139
139: ; preds = %133
br label %144
140: ; preds = %133
br label %141
141: ; preds = %140, %25
%142 = load i32, i32* %4
%143 = add nsw i32 %142, 1
store i32 %143, i32* %4
br label %11
144: ; preds = %139, %11
%145 = load i64, i64* %5
ret i64 %145
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, i32, i32, i32, i32, i64, i32 }
@VisualScreenMask = global i64 0
@DirectColor = global i32 0
@PseudoColor = global i32 0
@TrueColor = global i32 0
@StaticColor = global i32 0
@GrayScale = global i32 0
@StaticGray = global i32 0
define i64 @XmuAllStandardColormaps(i32* %0) {
%2 = alloca i32
%3 = alloca %struct.TYPE_6__
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.TYPE_6__* %3 to i8*
%6 = call i32 @ScreenCount(i32* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %93
8: ; preds = %1
%9 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 0
br label %10
10: ; preds = %8, %88
%11 = phi i32 [ 0, %8 ], [ %90, %88 ]
%12 = phi i64 [ 0, %8 ], [ %89, %88 ]
store i32 %11, i32* %9
%13 = load i64, i64* @VisualScreenMask
%14 = call %struct.TYPE_6__* @XGetVisualInfo(i32* %0, i64 %13, %struct.TYPE_6__* %3, i32* %2)
%15 = icmp eq %struct.TYPE_6__* %14, null
br i1 %15, label %88, label %16
16: ; preds = %10
%17 = load i32, i32* @DirectColor
%18 = load i32, i32* %2
%19 = call %struct.TYPE_6__* @getDeepestVisual(i32 %17, %struct.TYPE_6__* %14, i32 %18)
%20 = load i32, i32* @PseudoColor
%21 = load i32, i32* %2
%22 = call %struct.TYPE_6__* @getDeepestVisual(i32 %20, %struct.TYPE_6__* %14, i32 %21)
%23 = icmp eq %struct.TYPE_6__* %22, null
%24 = icmp eq %struct.TYPE_6__* %19, null
br i1 %23, label %38, label %25
25: ; preds = %16
br i1 %24, label %77, label %26
26: ; preds = %25
%27 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %22, i64 0, i32 1
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %19, i64 0, i32 2
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %19, i64 0, i32 3
%32 = load i32, i32* %31
%33 = or i32 %32, %30
%34 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %19, i64 0, i32 4
%35 = load i32, i32* %34
%36 = or i32 %33, %35
%37 = icmp sgt i32 %28, %36
br i1 %37, label %77, label %39
38: ; preds = %16
br i1 %24, label %40, label %39
39: ; preds = %26, %38
br label %77
40: ; preds = %38
%41 = load i32, i32* @TrueColor
%42 = load i32, i32* %2
%43 = call %struct.TYPE_6__* @getDeepestVisual(i32 %41, %struct.TYPE_6__* %14, i32 %42)
%44 = icmp eq %struct.TYPE_6__* %43, null
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i32, i32* @StaticColor
%47 = load i32, i32* %2
%48 = call %struct.TYPE_6__* @getDeepestVisual(i32 %46, %struct.TYPE_6__* %14, i32 %47)
%49 = icmp eq %struct.TYPE_6__* %48, null
br i1 %49, label %58, label %50
50: ; preds = %45, %40
%51 = phi %struct.TYPE_6__* [ %43, %40 ], [ %48, %45 ]
%52 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %51, i64 0, i32 6
%53 = load i32, i32* %52
%54 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %51, i64 0, i32 5
%55 = load i64, i64* %54
%56 = trunc i64 %55 to i32
%57 = call i64 @XmuVisualStandardColormaps(i32* %0, i32 %11, i32 %53, i32 %56, i32 1, i32 1)
br label %58
58: ; preds = %50, %45
%59 = phi i64 [ %57, %50 ], [ %12, %45 ]
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = bitcast %struct.TYPE_6__* %14 to i8*
%63 = call i32 @XFree(i8* %62)
br label %93
64: ; preds = %58
%65 = load i32, i32* @GrayScale
%66 = load i32, i32* %2
%67 = call %struct.TYPE_6__* @getDeepestVisual(i32 %65, %struct.TYPE_6__* %14, i32 %66)
%68 = icmp eq %struct.TYPE_6__* %67, null
br i1 %68, label %69, label %77
69: ; preds = %64
%70 = load i32, i32* @StaticGray
%71 = load i32, i32* %2
%72 = call %struct.TYPE_6__* @getDeepestVisual(i32 %70, %struct.TYPE_6__* %14, i32 %71)
%73 = icmp eq %struct.TYPE_6__* %72, null
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = bitcast %struct.TYPE_6__* %14 to i8*
%76 = call i32 @XFree(i8* %75)
br label %88
77: ; preds = %64, %69, %25, %26, %39
%78 = phi %struct.TYPE_6__* [ %19, %39 ], [ %22, %26 ], [ %22, %25 ], [ %67, %64 ], [ %72, %69 ]
%79 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %78, i64 0, i32 6
%80 = load i32, i32* %79
%81 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %78, i64 0, i32 5
%82 = load i64, i64* %81
%83 = trunc i64 %82 to i32
%84 = call i64 @XmuVisualStandardColormaps(i32* %0, i32 %11, i32 %80, i32 %83, i32 1, i32 1)
%85 = bitcast %struct.TYPE_6__* %14 to i8*
%86 = call i32 @XFree(i8* %85)
%87 = icmp eq i64 %84, 0
br i1 %87, label %93, label %88
88: ; preds = %74, %77, %10
%89 = phi i64 [ %12, %10 ], [ %84, %77 ], [ %59, %74 ]
%90 = add nuw nsw i32 %11, 1
%91 = call i32 @ScreenCount(i32* %0)
%92 = icmp slt i32 %90, %91
br i1 %92, label %10, label %93
93: ; preds = %88, %77, %1, %61
%94 = phi i64 [ 0, %61 ], [ 0, %1 ], [ %89, %88 ], [ 0, %77 ]
ret i64 %94
}