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

/* Variables and functions */
int False;
int GLX_BLUE_SIZE;
int GLX_DOUBLEBUFFER;
int GLX_GREEN_SIZE;
int GLX_RED_SIZE;
int GLX_RENDER_TYPE;
int None;
int True;
int /*<<< orphan*/ *glXChooseFBConfig(int /*<<< orphan*/ *, int, int *, int *);
GLXFBConfig *choose_fb_config(Display *dpy, int scrnum) {
  int fbAttribSingle[] = {GLX_RENDER_TYPE,  0x00000001, GLX_RED_SIZE,  1,
                          GLX_GREEN_SIZE,   1,          GLX_BLUE_SIZE, 1,
                          GLX_DOUBLEBUFFER, False,      None};
  int fbAttribDouble[] = {GLX_RENDER_TYPE,  0x00000001, GLX_RED_SIZE,  1,
                          GLX_GREEN_SIZE,   1,          GLX_BLUE_SIZE, 1,
                          GLX_DOUBLEBUFFER, True,       None};
  GLXFBConfig *configs;
  int nConfigs;
  configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
  if (!configs)
    configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs);
  return configs;
}


x86 assembly (clang, -O0):
<choose_fb_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2eb7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    0x2e6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
movl   $0x1,-0x34(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    0x2e6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
movl   $0x1,-0x6c(%rbp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
movl   $0x1,-0x64(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
movl   $0x1,-0x54(%rbp)
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    -0x7c(%rbp),%rcx
call   1030 <glXChooseFBConfig@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    123d <choose_fb_config+0x12d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x70(%rbp),%rdx
lea    -0x7c(%rbp),%rcx
call   1030 <glXChooseFBConfig@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose_fb_config>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2ebb(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
movl   $0x1,0x44(%rsp)
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x48(%rsp)
movl   $0x1,0x4c(%rsp)
mov    0x2e89(%rip),%rdx
mov    (%rdx),%edx
mov    %edx,0x50(%rsp)
movl   $0x1,0x54(%rsp)
mov    0x2e6c(%rip),%rsi
mov    (%rsi),%esi
mov    %esi,0x58(%rsp)
movl   $0x1,0x5c(%rsp)
mov    0x2e37(%rip),%rdi
mov    (%rdi),%edi
mov    %edi,0x60(%rsp)
mov    0x2e62(%rip),%rbp
mov    0x0(%rbp),%ebp
mov    %ebp,0x64(%rsp)
mov    0x2e34(%rip),%rbp
mov    0x0(%rbp),%ebp
mov    %ebp,0x68(%rsp)
mov    %eax,0x10(%rsp)
movl   $0x1,0x14(%rsp)
mov    %ecx,0x18(%rsp)
movl   $0x1,0x1c(%rsp)
mov    %edx,0x20(%rsp)
movl   $0x1,0x24(%rsp)
mov    %esi,0x28(%rsp)
movl   $0x1,0x2c(%rsp)
mov    %edi,0x30(%rsp)
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    %ebp,0x38(%rsp)
lea    0x40(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <glXChooseFBConfig@plt>
test   %rax,%rax
jne    120f <choose_fb_config+0xff>
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <glXChooseFBConfig@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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