#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 GLX_RGBA_BIT;
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,
                          GLX_RGBA_BIT,
                          GLX_RED_SIZE,
                          1,
                          GLX_GREEN_SIZE,
                          1,
                          GLX_BLUE_SIZE,
                          1,
                          GLX_DOUBLEBUFFER,
                          False,
                          None};
  int fbAttribDouble[] = {GLX_RENDER_TYPE,
                          GLX_RGBA_BIT,
                          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    0x2eaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
movl   $0x1,-0x34(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
movl   $0x1,-0x64(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
movl   $0x1,-0x54(%rbp)
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2db9(%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    1247 <choose_fb_config+0x137>
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   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    0x2eac(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x44(%rsp)
mov    0x2e5f(%rip),%rdx
mov    (%rdx),%edx
mov    %edx,0x48(%rsp)
movl   $0x1,0x4c(%rsp)
mov    0x2e7a(%rip),%rsi
mov    (%rsi),%esi
mov    %esi,0x50(%rsp)
movl   $0x1,0x54(%rsp)
mov    0x2e5d(%rip),%rdi
mov    (%rdi),%edi
mov    %edi,0x58(%rsp)
movl   $0x1,0x5c(%rsp)
mov    0x2e28(%rip),%rbp
mov    0x0(%rbp),%ebp
mov    %ebp,0x60(%rsp)
mov    0x2e5a(%rip),%rbx
mov    (%rbx),%ebx
mov    %ebx,0x64(%rsp)
mov    0x2e25(%rip),%rbx
mov    (%rbx),%ebx
mov    %ebx,0x68(%rsp)
mov    %eax,0x10(%rsp)
mov    %ecx,0x14(%rsp)
mov    %edx,0x18(%rsp)
movl   $0x1,0x1c(%rsp)
mov    %esi,0x20(%rsp)
movl   $0x1,0x24(%rsp)
mov    %edi,0x28(%rsp)
movl   $0x1,0x2c(%rsp)
mov    %ebp,0x30(%rsp)
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    %ebx,0x38(%rsp)
lea    0x40(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <glXChooseFBConfig@plt>
test   %rax,%rax
jne    1211 <choose_fb_config+0x101>
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <glXChooseFBConfig@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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