#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ XColor;
typedef int /*<<< orphan*/ Visual;
typedef int /*<<< orphan*/ Screen;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;
typedef int Bool;

/* Variables and functions */
int /*<<< orphan*/ *DefaultScreenOfDisplay(int /*<<< orphan*/ *);
int False;
int /*<<< orphan*/ True;
int /*<<< orphan*/ complain(int, int, int, int);
int /*<<< orphan*/ has_writable_cells(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ make_color_ramp(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, float, float, int, float,
                                   float, int /*<<< orphan*/ *, int *, int,
                                   int /*<<< orphan*/, int);
int random();
void make_uniform_colormap(Display *dpy, Visual *visual, Colormap cmap,
                           XColor *colors, int *ncolorsP, Bool allocate_p,
                           Bool *writable_pP, Bool verbose_p) {
  int ncolors = *ncolorsP;
  Bool wanted_writable = (allocate_p && writable_pP && *writable_pP);
  Screen *screen = DefaultScreenOfDisplay(dpy);
  float S = ((float)(random() % 34) + 66) / 100.0;
  float V = ((float)(random() % 34) + 66) / 100.0;
  if (*ncolorsP <= 0)
    return;
  if (wanted_writable && !has_writable_cells(screen, visual))
    *writable_pP = False;
RETRY_NON_WRITABLE:
  make_color_ramp(dpy, cmap, 0, S, V, 359, S, V, colors, &ncolors, False, True,
                  wanted_writable);
  if (allocate_p && *ncolorsP == 0 && writable_pP && *writable_pP) {
    ncolors = *ncolorsP;
    *writable_pP = False;
    goto RETRY_NON_WRITABLE;
  }
  if (verbose_p)
    complain(*ncolorsP, ncolors, wanted_writable,
             wanted_writable && *writable_pP);
  *ncolorsP = ncolors;
}


x86 assembly (clang, -O0):
<make_uniform_colormap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x49(%rbp)
je     11ab <make_uniform_colormap+0x5b>
xor    %eax,%eax
cmpq   $0x0,0x10(%rbp)
mov    %al,-0x49(%rbp)
je     11ab <make_uniform_colormap+0x5b>
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <DefaultScreenOfDisplay@plt>
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    $0x22,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  0xe2a(%rip),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe12(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    $0x22,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  0xdf2(%rip),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdda(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1245 <make_uniform_colormap+0xf5>
jmp    1372 <make_uniform_colormap+0x222>
cmpl   $0x0,-0x34(%rbp)
je     1274 <make_uniform_colormap+0x124>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <has_writable_cells@plt>
cmp    $0x0,%eax
jne    1274 <make_uniform_colormap+0x124>
mov    0x2d7c(%rip),%rax
mov    (%rax),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1279 <make_uniform_colormap+0x129>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
movss  -0x44(%rbp),%xmm0
movss  -0x48(%rbp),%xmm1
movss  -0x44(%rbp),%xmm2
movss  -0x48(%rbp),%xmm3
mov    -0x20(%rbp),%r8
mov    0x2d49(%rip),%rax
mov    (%rax),%r11d
mov    0x2d37(%rip),%rax
mov    (%rax),%r10d
mov    -0x34(%rbp),%eax
xor    %edx,%edx
mov    $0x167,%ecx
lea    -0x30(%rbp),%r9
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <make_color_ramp@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1318 <make_uniform_colormap+0x1c8>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1318 <make_uniform_colormap+0x1c8>
cmpq   $0x0,0x10(%rbp)
je     1318 <make_uniform_colormap+0x1c8>
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     1318 <make_uniform_colormap+0x1c8>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2cdd(%rip),%rax
mov    (%rax),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1279 <make_uniform_colormap+0x129>
cmpl   $0x0,0x18(%rbp)
je     1369 <make_uniform_colormap+0x219>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x50(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x4a(%rbp)
je     1353 <make_uniform_colormap+0x203>
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
setne  %al
mov    %al,-0x4a(%rbp)
mov    -0x50(%rbp),%edx
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edi
mov    -0x4a(%rbp),%al
and    $0x1,%al
movzbl %al,%ecx
call   1060 <complain@plt>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_uniform_colormap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r12d
mov    %r8,%r13
mov    %rcx,0x20(%rsp)
mov    %edx,0x14(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x60(%rsp),%r14
mov    (%r8),%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
test   %r9d,%r9d
je     1192 <make_uniform_colormap+0x42>
test   %r14,%r14
je     1192 <make_uniform_colormap+0x42>
cmpl   $0x0,(%r14)
setne  %al
movzbl %al,%ebp
mov    %r15,%rdi
call   1040 <DefaultScreenOfDisplay@plt>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0x78787879,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
lea    (%rdx,%rcx,2),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
addss  0xe2b(%rip),%xmm0
divss  0xe27(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0x78787879,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
lea    (%rdx,%rcx,2),%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0xde7(%rip),%xmm0
divss  0xde3(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
cmpl   $0x0,0x0(%r13)
jle    12ee <make_uniform_colormap+0x19e>
test   %ebp,%ebp
je     1253 <make_uniform_colormap+0x103>
mov    0x18(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <has_writable_cells@plt>
test   %eax,%eax
jne    1253 <make_uniform_colormap+0x103>
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    0x2d7d(%rip),%rcx
mov    (%rcx),%ebx
sub    $0x8,%rsp
lea    0x10(%rsp),%r9
mov    %r15,%rdi
mov    0x1c(%rsp),%esi
xor    %edx,%edx
movss  0x18(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
mov    $0x167,%ecx
movaps %xmm0,%xmm2
movaps %xmm1,%xmm3
mov    0x28(%rsp),%r8
push   %rbp
push   %rbx
push   %rax
call   1030 <make_color_ramp@plt>
add    $0x20,%rsp
test   %r12d,%r12d
je     12c1 <make_uniform_colormap+0x171>
mov    0x0(%r13),%eax
test   %r14,%r14
je     12c1 <make_uniform_colormap+0x171>
test   %eax,%eax
jne    12c1 <make_uniform_colormap+0x171>
cmpl   $0x0,(%r14)
je     12c1 <make_uniform_colormap+0x171>
movl   $0x0,0x8(%rsp)
jmp    1247 <make_uniform_colormap+0xf7>
cmpl   $0x0,0x68(%rsp)
je     12e6 <make_uniform_colormap+0x196>
mov    0x0(%r13),%edi
xor    %ecx,%ecx
mov    0x8(%rsp),%esi
test   %ebp,%ebp
je     12df <make_uniform_colormap+0x18f>
xor    %ecx,%ecx
cmpl   $0x0,(%r14)
setne  %cl
mov    %ebp,%edx
call   1060 <complain@plt>
mov    0x8(%rsp),%eax
mov    %eax,0x0(%r13)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@False = global i32 0
@True = global i32 0
define void @make_uniform_colormap(i32* %0, i32* %1, i32 %2, i32* %3, i32* %4, i32 %5, i32* %6, i32 %7) {
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
%20 = alloca float
%21 = alloca float
store i32* %0, i32** %9
store i32* %1, i32** %10
store i32 %2, i32* %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store i32 %5, i32* %14
store i32* %6, i32** %15
store i32 %7, i32* %16
%22 = load i32*, i32** %13
%23 = load i32, i32* %22
store i32 %23, i32* %17
%24 = load i32, i32* %14
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %8
%27 = load i32*, i32** %15
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32*, i32** %15
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 0
br label %33
33: ; preds = %29, %26, %8
%34 = phi i1 [ false, %26 ], [ false, %8 ], [ %32, %29 ]
%35 = zext i1 %34 to i32
store i32 %35, i32* %18
%36 = load i32*, i32** %9
%37 = call i32* @DefaultScreenOfDisplay(i32* %36)
store i32* %37, i32** %19
%38 = call i32 (...) @random()
%39 = srem i32 %38, 34
%40 = sitofp i32 %39 to float
%41 = fadd float %40, 6.600000e+01
%42 = fpext float %41 to double
%43 = fdiv double %42, 1.000000e+02
%44 = fptrunc double %43 to float
store float %44, float* %20
%45 = call i32 (...) @random()
%46 = srem i32 %45, 34
%47 = sitofp i32 %46 to float
%48 = fadd float %47, 6.600000e+01
%49 = fpext float %48 to double
%50 = fdiv double %49, 1.000000e+02
%51 = fptrunc double %50 to float
store float %51, float* %21
%52 = load i32*, i32** %13
%53 = load i32, i32* %52
%54 = icmp sle i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %33
br label %119
56: ; preds = %33
%57 = load i32, i32* %18
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %67
59: ; preds = %56
%60 = load i32*, i32** %19
%61 = load i32*, i32** %10
%62 = call i32 @has_writable_cells(i32* %60, i32* %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %59
%65 = load i32, i32* @False
%66 = load i32*, i32** %15
store i32 %65, i32* %66
br label %67
67: ; preds = %64, %59, %56
br label %68
68: ; preds = %93, %67
%69 = load i32*, i32** %9
%70 = load i32, i32* %11
%71 = load float, float* %20
%72 = load float, float* %21
%73 = load float, float* %20
%74 = load float, float* %21
%75 = load i32*, i32** %12
%76 = load i32, i32* @False
%77 = load i32, i32* @True
%78 = load i32, i32* %18
%79 = call i32 @make_color_ramp(i32* %69, i32 %70, i32 0, float %71, float %72, i32 359, float %73, float %74, i32* %75, i32* %17, i32 %76, i32 %77, i32 %78)
%80 = load i32, i32* %14
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %98
82: ; preds = %68
%83 = load i32*, i32** %13
%84 = load i32, i32* %83
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %98
86: ; preds = %82
%87 = load i32*, i32** %15
%88 = icmp ne i32* %87, null
br i1 %88, label %89, label %98
89: ; preds = %86
%90 = load i32*, i32** %15
%91 = load i32, i32* %90
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %98
93: ; preds = %89
%94 = load i32*, i32** %13
%95 = load i32, i32* %94
store i32 %95, i32* %17
%96 = load i32, i32* @False
%97 = load i32*, i32** %15
store i32 %96, i32* %97
br label %68
98: ; preds = %89, %86, %82, %68
%99 = load i32, i32* %16
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %116
101: ; preds = %98
%102 = load i32*, i32** %13
%103 = load i32, i32* %102
%104 = load i32, i32* %17
%105 = load i32, i32* %18
%106 = load i32, i32* %18
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %112
108: ; preds = %101
%109 = load i32*, i32** %15
%110 = load i32, i32* %109
%111 = icmp ne i32 %110, 0
br label %112
112: ; preds = %108, %101
%113 = phi i1 [ false, %101 ], [ %111, %108 ]
%114 = zext i1 %113 to i32
%115 = call i32 @complain(i32 %103, i32 %104, i32 %105, i32 %114)
br label %116
116: ; preds = %112, %98
%117 = load i32, i32* %17
%118 = load i32*, i32** %13
store i32 %117, i32* %118
br label %119
119: ; preds = %116, %55
ret void
}

LLVM IR (-O2):
@False = global i32 0
@True = global i32 0
define void @make_uniform_colormap(i32* %0, i32* %1, i32 %2, i32* %3, i32* nocapture %4, i32 %5, i32* %6, i32 %7) {
%9 = alloca i32
%10 = bitcast i32* %9 to i8*
%11 = load i32, i32* %4
store i32 %11, i32* %9
%12 = icmp ne i32 %5, 0
%13 = icmp ne i32* %6, null
%14 = and i1 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %15, %8
%19 = phi i1 [ false, %8 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
%21 = tail call i32* @DefaultScreenOfDisplay(i32* %0)
%22 = tail call i32 (...) @random()
%23 = srem i32 %22, 34
%24 = sitofp i32 %23 to float
%25 = fadd float %24, 6.600000e+01
%26 = fdiv float %25, 1.000000e+02
%27 = tail call i32 (...) @random()
%28 = srem i32 %27, 34
%29 = sitofp i32 %28 to float
%30 = fadd float %29, 6.600000e+01
%31 = fdiv float %30, 1.000000e+02
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 1
br i1 %33, label %66, label %34
34: ; preds = %18
br i1 %19, label %35, label %40
35: ; preds = %34
%36 = tail call i32 @has_writable_cells(i32* %21, i32* %1)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35, %51
%39 = load i32, i32* @False
store i32 %39, i32* %6
br label %40
40: ; preds = %38, %34, %35
%41 = load i32, i32* @False
%42 = load i32, i32* @True
%43 = call i32 @make_color_ramp(i32* %0, i32 %2, i32 0, float %26, float %31, i32 359, float %26, float %31, i32* %3, i32* %9, i32 %41, i32 %42, i32 %20)
br i1 %12, label %44, label %52
44: ; preds = %40
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 0
%47 = and i1 %13, %46
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 0
br i1 %50, label %52, label %51
51: ; preds = %48
store i32 0, i32* %9
br label %38
52: ; preds = %48, %44, %40
%53 = icmp eq i32 %7, 0
br i1 %53, label %64, label %54
54: ; preds = %52
%55 = load i32, i32* %4
%56 = load i32, i32* %9
br i1 %19, label %57, label %61
57: ; preds = %54
%58 = load i32, i32* %6
%59 = icmp ne i32 %58, 0
%60 = zext i1 %59 to i32
br label %61
61: ; preds = %57, %54
%62 = phi i32 [ 0, %54 ], [ %60, %57 ]
%63 = call i32 @complain(i32 %55, i32 %56, i32 %20, i32 %62)
br label %64
64: ; preds = %61, %52
%65 = load i32, i32* %9
store i32 %65, i32* %4
br label %66
66: ; preds = %18, %64
ret void
}