#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*/ XVisualInfo;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ PseudoColor;
int /*<<< orphan*/ TrueColor;
int /*<<< orphan*/ VisualAllMask;
int /*<<< orphan*/ *XGetVisualInfo(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/ *, int *);
scalar_t__ XMatchVisualInfo(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/,
                            int /*<<< orphan*/ *);
XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList) {
  XVisualInfo vinfo;
  int n;
  if (XMatchVisualInfo(dpy, screen, 16, TrueColor, &vinfo)) {
  } else if (XMatchVisualInfo(dpy, screen, 24, TrueColor, &vinfo)) {
  } else if (XMatchVisualInfo(dpy, screen, 32, TrueColor, &vinfo)) {
  } else if (XMatchVisualInfo(dpy, screen, 8, PseudoColor, &vinfo)) {
  } else {
    return NULL;
  }
  return XGetVisualInfo(dpy, VisualAllMask, &vinfo, &n);
}


x86 assembly (clang, -O0):
<glXChooseVisual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2ea7(%rip),%rax
mov    (%rax),%ecx
mov    $0x10,%edx
lea    -0x24(%rbp),%r8
call   1040 <XMatchVisualInfo@plt>
cmp    $0x0,%rax
je     1160 <glXChooseVisual+0x40>
jmp    1203 <glXChooseVisual+0xe3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e7a(%rip),%rax
mov    (%rax),%ecx
mov    $0x18,%edx
lea    -0x24(%rbp),%r8
call   1040 <XMatchVisualInfo@plt>
cmp    $0x0,%rax
je     118d <glXChooseVisual+0x6d>
jmp    11fe <glXChooseVisual+0xde>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e4d(%rip),%rax
mov    (%rax),%ecx
mov    $0x20,%edx
lea    -0x24(%rbp),%r8
call   1040 <XMatchVisualInfo@plt>
cmp    $0x0,%rax
je     11ba <glXChooseVisual+0x9a>
jmp    11f9 <glXChooseVisual+0xd9>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e00(%rip),%rax
mov    (%rax),%ecx
mov    $0x8,%edx
lea    -0x24(%rbp),%r8
call   1040 <XMatchVisualInfo@plt>
cmp    $0x0,%rax
je     11e7 <glXChooseVisual+0xc7>
jmp    11f4 <glXChooseVisual+0xd4>
movq   $0x0,-0x8(%rbp)
jmp    1221 <glXChooseVisual+0x101>
jmp    11f9 <glXChooseVisual+0xd9>
jmp    11fe <glXChooseVisual+0xde>
jmp    1203 <glXChooseVisual+0xe3>
mov    -0x10(%rbp),%rdi
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <XGetVisualInfo@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glXChooseVisual>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2eb4(%rip),%r14
mov    (%r14),%ecx
lea    0x8(%rsp),%r8
mov    $0x10,%edx
call   1040 <XMatchVisualInfo@plt>
test   %rax,%rax
jne    11a5 <glXChooseVisual+0x85>
mov    (%r14),%ecx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x18,%edx
call   1040 <XMatchVisualInfo@plt>
test   %rax,%rax
jne    11a5 <glXChooseVisual+0x85>
mov    (%r14),%ecx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x20,%edx
call   1040 <XMatchVisualInfo@plt>
test   %rax,%rax
jne    11a5 <glXChooseVisual+0x85>
mov    0x2e3e(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x8,%edx
call   1040 <XMatchVisualInfo@plt>
test   %rax,%rax
je     11c9 <glXChooseVisual+0xa9>
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1030 <XGetVisualInfo@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
jmp    11c0 <glXChooseVisual+0xa0>

LLVM IR (-O0):
@TrueColor = global i32 0
@PseudoColor = global i32 0
@VisualAllMask = global i32 0
define i32* @glXChooseVisual(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%10 = load i32*, i32** %5
%11 = load i32, i32* %6
%12 = load i32, i32* @TrueColor
%13 = call i64 @XMatchVisualInfo(i32* %10, i32 %11, i32 16, i32 %12, i32* %8)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %3
br label %41
16: ; preds = %3
%17 = load i32*, i32** %5
%18 = load i32, i32* %6
%19 = load i32, i32* @TrueColor
%20 = call i64 @XMatchVisualInfo(i32* %17, i32 %18, i32 24, i32 %19, i32* %8)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
br label %40
23: ; preds = %16
%24 = load i32*, i32** %5
%25 = load i32, i32* %6
%26 = load i32, i32* @TrueColor
%27 = call i64 @XMatchVisualInfo(i32* %24, i32 %25, i32 32, i32 %26, i32* %8)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23
br label %39
30: ; preds = %23
%31 = load i32*, i32** %5
%32 = load i32, i32* %6
%33 = load i32, i32* @PseudoColor
%34 = call i64 @XMatchVisualInfo(i32* %31, i32 %32, i32 8, i32 %33, i32* %8)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
br label %38
37: ; preds = %30
store i32* null, i32** %4
br label %45
38: ; preds = %36
br label %39
39: ; preds = %38, %29
br label %40
40: ; preds = %39, %22
br label %41
41: ; preds = %40, %15
%42 = load i32*, i32** %5
%43 = load i32, i32* @VisualAllMask
%44 = call i32* @XGetVisualInfo(i32* %42, i32 %43, i32* %8, i32* %9)
store i32* %44, i32** %4
br label %45
45: ; preds = %41, %37
%46 = load i32*, i32** %4
ret i32* %46
}

LLVM IR (-O2):
@TrueColor = global i32 0
@PseudoColor = global i32 0
@VisualAllMask = global i32 0
define i32* @glXChooseVisual(i32* %0, i32 %1, i32* nocapture readnone %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = load i32, i32* @TrueColor
%9 = call i64 @XMatchVisualInfo(i32* %0, i32 %1, i32 16, i32 %8, i32* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %3
%12 = load i32, i32* @TrueColor
%13 = call i64 @XMatchVisualInfo(i32* %0, i32 %1, i32 24, i32 %12, i32* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* @TrueColor
%17 = call i64 @XMatchVisualInfo(i32* %0, i32 %1, i32 32, i32 %16, i32* %4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* @PseudoColor
%21 = call i64 @XMatchVisualInfo(i32* %0, i32 %1, i32 8, i32 %20, i32* %4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %11, %19, %15, %3
%24 = load i32, i32* @VisualAllMask
%25 = call i32* @XGetVisualInfo(i32* %0, i32 %24, i32* %4, i32* %5)
br label %26
26: ; preds = %19, %23
%27 = phi i32* [ %25, %23 ], [ null, %19 ]
ret i32* %27
}