#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int depth;
};
typedef TYPE_1__ XVisualInfo;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ VisualDepthMask;
int /*<<< orphan*/ XFree(TYPE_1__ *);
TYPE_1__ *XGetVisualInfo(int /*<<< orphan*/ *, int /*<<< orphan*/, TYPE_1__ *,
                         int *);
int xCheckVisualInfo(Display *drv_display, int bpp) {
  int nitems;
  XVisualInfo info, *ret_info;
  info.depth = bpp;
  ret_info = XGetVisualInfo(drv_display, VisualDepthMask, &info, &nitems);
  if (ret_info != NULL) {
    XFree(ret_info);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<xCheckVisualInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <XGetVisualInfo@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1173 <xCheckVisualInfo+0x53>
mov    -0x28(%rbp),%rdi
call   1030 <XFree@plt>
movl   $0x1,-0x4(%rbp)
jmp    117a <xCheckVisualInfo+0x5a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xCheckVisualInfo>:
push   %rax
mov    %esi,(%rsp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
call   1040 <XGetVisualInfo@plt>
test   %rax,%rax
je     114e <xCheckVisualInfo+0x2e>
mov    %rax,%rdi
call   1030 <XFree@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32 }
@VisualDepthMask = global i32 0
define i32 @xCheckVisualInfo(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_5__
%8 = alloca %struct.TYPE_5__*
store i32* %0, i32** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
store i32 %9, i32* %10
%11 = load i32*, i32** %4
%12 = load i32, i32* @VisualDepthMask
%13 = call %struct.TYPE_5__* @XGetVisualInfo(i32* %11, i32 %12, %struct.TYPE_5__* %7, i32* %6)
store %struct.TYPE_5__* %13, %struct.TYPE_5__** %8
%14 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%15 = icmp ne %struct.TYPE_5__* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%18 = call i32 @XFree(%struct.TYPE_5__* %17)
store i32 1, i32* %3
br label %20
19: ; preds = %2
store i32 0, i32* %3
br label %20
20: ; preds = %19, %16
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32 }
@VisualDepthMask = global i32 0
define i32 @xCheckVisualInfo(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_5__
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.TYPE_5__* %4 to i8*
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 0
store i32 %1, i32* %7
%8 = load i32, i32* @VisualDepthMask
%9 = call %struct.TYPE_5__* @XGetVisualInfo(i32* %0, i32 %8, %struct.TYPE_5__* %4, i32* %3)
%10 = icmp eq %struct.TYPE_5__* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @XFree(%struct.TYPE_5__* %9)
br label %13
13: ; preds = %2, %11
%14 = phi i32 [ 1, %11 ], [ 0, %2 ]
ret i32 %14
}