#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 GLX_BLUE_SIZE;
int GLX_DOUBLEBUFFER;
int GLX_GREEN_SIZE;
int GLX_RED_SIZE;
int GLX_RGBA;
int None;
int /*<<< orphan*/ *glXChooseVisual(int /*<<< orphan*/ *, int, int *);
XVisualInfo *choose_xvisinfo(Display *dpy, int scrnum) {
  int attribSingle[] = {GLX_RGBA, GLX_RED_SIZE,  1, GLX_GREEN_SIZE,
                        1,        GLX_BLUE_SIZE, 1, None};
  int attribDouble[] = {GLX_RGBA, GLX_RED_SIZE,  1, GLX_GREEN_SIZE,
                        1,        GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER,
                        None};
  XVisualInfo *visinfo;
  visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
  if (!visinfo)
    visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
  return visinfo;
}


x86 assembly (clang, -O0):
<choose_xvisinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x1,-0x28(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
movl   $0x1,-0x58(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
movl   $0x1,-0x50(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x1,-0x48(%rbp)
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1030 <glXChooseVisual@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1200 <choose_xvisinfo+0xf0>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x60(%rbp),%rdx
call   1030 <glXChooseVisual@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose_xvisinfo>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2ec6(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e8a(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x4(%rsp)
movl   $0x1,0x8(%rsp)
mov    0x2e9d(%rip),%rdx
mov    (%rdx),%edx
mov    %edx,0xc(%rsp)
movl   $0x1,0x10(%rsp)
mov    0x2e80(%rip),%rsi
mov    (%rsi),%esi
mov    %esi,0x14(%rsp)
movl   $0x1,0x18(%rsp)
mov    0x2e63(%rip),%rdi
mov    (%rdi),%edi
mov    %edi,0x1c(%rsp)
mov    %eax,0x20(%rsp)
mov    %ecx,0x24(%rsp)
movl   $0x1,0x28(%rsp)
mov    %edx,0x2c(%rsp)
movl   $0x1,0x30(%rsp)
mov    %esi,0x34(%rsp)
movl   $0x1,0x38(%rsp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x3c(%rsp)
mov    %edi,0x40(%rsp)
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <glXChooseVisual@plt>
test   %rax,%rax
jne    11cd <choose_xvisinfo+0xbd>
lea    0x20(%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <glXChooseVisual@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@GLX_RGBA = global i32 0
@GLX_RED_SIZE = global i32 0
@GLX_GREEN_SIZE = global i32 0
@GLX_BLUE_SIZE = global i32 0
@None = global i32 0
@GLX_DOUBLEBUFFER = global i32 0
define i32* @choose_xvisinfo(i32* %0, i32 %1) {
%3 = alloca [8 x i32]
%4 = alloca [9 x i32]
%5 = bitcast [8 x i32]* %3 to i8*
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%7 = load i32, i32* @GLX_RGBA
store i32 %7, i32* %6
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%9 = load i32, i32* @GLX_RED_SIZE
store i32 %9, i32* %8
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
store i32 1, i32* %10
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%12 = load i32, i32* @GLX_GREEN_SIZE
store i32 %12, i32* %11
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
store i32 1, i32* %13
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%15 = load i32, i32* @GLX_BLUE_SIZE
store i32 %15, i32* %14
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
store i32 1, i32* %16
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%18 = load i32, i32* @None
store i32 %18, i32* %17
%19 = bitcast [9 x i32]* %4 to i8*
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 0
store i32 %7, i32* %20
%21 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 1
store i32 %9, i32* %21
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 2
store i32 1, i32* %22
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 3
store i32 %12, i32* %23
%24 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 4
store i32 1, i32* %24
%25 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 5
store i32 %15, i32* %25
%26 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 6
store i32 1, i32* %26
%27 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 7
%28 = load i32, i32* @GLX_DOUBLEBUFFER
store i32 %28, i32* %27
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 8
store i32 %18, i32* %29
%30 = call i32* @glXChooseVisual(i32* %0, i32 %1, i32* %6)
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %2
%33 = call i32* @glXChooseVisual(i32* %0, i32 %1, i32* %20)
br label %34
34: ; preds = %32, %2
%35 = phi i32* [ %30, %2 ], [ %33, %32 ]
ret i32* %35
}