#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*/ GLX_BLUE_SIZE;
int /*<<< orphan*/ GLX_DEPTH_SIZE;
int /*<<< orphan*/ GLX_DOUBLEBUFFER;
int /*<<< orphan*/ GLX_GREEN_SIZE;
int /*<<< orphan*/ GLX_RED_SIZE;
int /*<<< orphan*/ GLX_RGBA;
int /*<<< orphan*/ None;
int /*<<< orphan*/ *glXChooseVisual(int /*<<< orphan*/ *, int, int *);
XVisualInfo *chooseVisual(Display *dpy, int screen) {
  int att[64];
  int *p = att;
  *p++ = GLX_RGBA;
  *p++ = GLX_DOUBLEBUFFER;
  *p++ = GLX_RED_SIZE;
  *p++ = 1;
  *p++ = GLX_GREEN_SIZE;
  *p++ = 1;
  *p++ = GLX_BLUE_SIZE;
  *p++ = 1;
  *p++ = GLX_DEPTH_SIZE;
  *p++ = 1;
  *p++ = None;
  return glXChooseVisual(dpy, screen, att);
}


x86 assembly (clang, -O0):
<chooseVisual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    0x2e61(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    0x2e39(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    -0x118(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x118(%rbp)
movl   $0x1,(%rax)
mov    0x2e26(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    -0x118(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x118(%rbp)
movl   $0x1,(%rax)
mov    0x2de3(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    -0x118(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x118(%rbp)
movl   $0x1,(%rax)
mov    0x2dc0(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    -0x118(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x118(%rbp)
movl   $0x1,(%rax)
mov    0x2d65(%rip),%rax
mov    (%rax),%ecx
mov    -0x118(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x118(%rbp)
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x110(%rbp),%rdx
call   1030 <glXChooseVisual@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chooseVisual>:
sub    $0x108,%rsp
mov    0x2ec2(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
movl   $0x1,0xc(%rsp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movl   $0x1,0x14(%rsp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
movl   $0x1,0x1c(%rsp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
movl   $0x1,0x24(%rsp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    %rsp,%rdx
call   1030 <glXChooseVisual@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
@GLX_RGBA = global i32 0
@GLX_DOUBLEBUFFER = global i32 0
@GLX_RED_SIZE = global i32 0
@GLX_GREEN_SIZE = global i32 0
@GLX_BLUE_SIZE = global i32 0
@GLX_DEPTH_SIZE = global i32 0
@None = global i32 0
define i32* @chooseVisual(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [64 x i32]
%6 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
store i32* %7, i32** %6
%8 = load i32, i32* @GLX_RGBA
%9 = load i32*, i32** %6
%10 = getelementptr inbounds i32, i32* %9, i32 1
store i32* %10, i32** %6
store i32 %8, i32* %9
%11 = load i32, i32* @GLX_DOUBLEBUFFER
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %6
store i32 %11, i32* %12
%14 = load i32, i32* @GLX_RED_SIZE
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i32 1
store i32* %16, i32** %6
store i32 %14, i32* %15
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i32 1
store i32* %18, i32** %6
store i32 1, i32* %17
%19 = load i32, i32* @GLX_GREEN_SIZE
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %6
store i32 %19, i32* %20
%22 = load i32*, i32** %6
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %6
store i32 1, i32* %22
%24 = load i32, i32* @GLX_BLUE_SIZE
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %6
store i32 %24, i32* %25
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %6
store i32 1, i32* %27
%29 = load i32, i32* @GLX_DEPTH_SIZE
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i32 1
store i32* %31, i32** %6
store i32 %29, i32* %30
%32 = load i32*, i32** %6
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %6
store i32 1, i32* %32
%34 = load i32, i32* @None
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i32 1
store i32* %36, i32** %6
store i32 %34, i32* %35
%37 = load i32*, i32** %3
%38 = load i32, i32* %4
%39 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%40 = call i32* @glXChooseVisual(i32* %37, i32 %38, i32* %39)
ret i32* %40
}

LLVM IR (-O2):
@GLX_RGBA = global i32 0
@GLX_DOUBLEBUFFER = global i32 0
@GLX_RED_SIZE = global i32 0
@GLX_GREEN_SIZE = global i32 0
@GLX_BLUE_SIZE = global i32 0
@GLX_DEPTH_SIZE = global i32 0
@None = global i32 0
define i32* @chooseVisual(i32* %0, i32 %1) {
%3 = alloca [64 x i32]
%4 = bitcast [64 x i32]* %3 to i8*
%5 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 0
%6 = load i32, i32* @GLX_RGBA
%7 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 1
store i32 %6, i32* %5
%8 = load i32, i32* @GLX_DOUBLEBUFFER
%9 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 2
store i32 %8, i32* %7
%10 = load i32, i32* @GLX_RED_SIZE
%11 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 3
store i32 %10, i32* %9
%12 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 4
store i32 1, i32* %11
%13 = load i32, i32* @GLX_GREEN_SIZE
%14 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 5
store i32 %13, i32* %12
%15 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 6
store i32 1, i32* %14
%16 = load i32, i32* @GLX_BLUE_SIZE
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 7
store i32 %16, i32* %15
%18 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 8
store i32 1, i32* %17
%19 = load i32, i32* @GLX_DEPTH_SIZE
%20 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 9
store i32 %19, i32* %18
%21 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 10
store i32 1, i32* %20
%22 = load i32, i32* @None
store i32 %22, i32* %21
%23 = call i32* @glXChooseVisual(i32* %0, i32 %1, i32* %5)
ret i32* %23
}