#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  TYPE_1__ *codes;
};
typedef TYPE_2__ XExtDisplayInfo;
struct TYPE_5__ {
  int first_event;
  int first_error;
};
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Bool;

/* Variables and functions */
int /*<<< orphan*/ False;
int /*<<< orphan*/ True;
scalar_t__ XextHasExtension(TYPE_2__ *);
TYPE_2__ *find_display(int /*<<< orphan*/ *);
Bool XNVCTRLQueryExtension(Display *dpy, int *event_basep, int *error_basep) {
  XExtDisplayInfo *info = find_display(dpy);
  if (XextHasExtension(info)) {
    if (event_basep)
      *event_basep = info->codes->first_event;
    if (error_basep)
      *error_basep = info->codes->first_error;
    return True;
  } else {
    return False;
  }
}


x86 assembly (clang, -O0):
<XNVCTRLQueryExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <find_display@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <XextHasExtension@plt>
cmp    $0x0,%rax
je     119a <XNVCTRLQueryExtension+0x7a>
cmpq   $0x0,-0x18(%rbp)
je     116e <XNVCTRLQueryExtension+0x4e>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     1189 <XNVCTRLQueryExtension+0x69>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a6 <XNVCTRLQueryExtension+0x86>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XNVCTRLQueryExtension>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
call   1040 <find_display@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <XextHasExtension@plt>
test   %rax,%rax
je     1164 <XNVCTRLQueryExtension+0x44>
test   %r15,%r15
je     114d <XNVCTRLQueryExtension+0x2d>
mov    (%rbx),%rax
mov    (%rax),%eax
mov    %eax,(%r15)
mov    0x2e8c(%rip),%rax
test   %r14,%r14
je     116b <XNVCTRLQueryExtension+0x4b>
mov    (%rbx),%rcx
mov    0x4(%rcx),%ecx
mov    %ecx,(%r14)
jmp    116b <XNVCTRLQueryExtension+0x4b>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32, i32 }
@True = global i32 0
@False = global i32 0
define i32 @XNVCTRLQueryExtension(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca %struct.TYPE_6__*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%9 = load i32*, i32** %5
%10 = call %struct.TYPE_6__* @find_display(i32* %9)
store %struct.TYPE_6__* %10, %struct.TYPE_6__** %8
%11 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%12 = call i64 @XextHasExtension(%struct.TYPE_6__* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %36
14: ; preds = %3
%15 = load i32*, i32** %6
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%19 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %18, i32 0, i32 0
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %19
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load i32*, i32** %6
store i32 %22, i32* %23
br label %24
24: ; preds = %17, %14
%25 = load i32*, i32** %7
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load %struct.TYPE_6__*, %struct.TYPE_6__** %8
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %28, i32 0, i32 0
%30 = load %struct.TYPE_5__*, %struct.TYPE_5__** %29
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = load i32*, i32** %7
store i32 %32, i32* %33
br label %34
34: ; preds = %27, %24
%35 = load i32, i32* @True
store i32 %35, i32* %4
br label %38
36: ; preds = %3
%37 = load i32, i32* @False
store i32 %37, i32* %4
br label %38
38: ; preds = %36, %34
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32, i32 }
@True = global i32 0
@False = global i32 0
define i32 @XNVCTRLQueryExtension(i32* %0, i32* writeonly %1, i32* writeonly %2) {
%4 = tail call %struct.TYPE_6__* @find_display(i32* %0)
%5 = tail call i64 @XextHasExtension(%struct.TYPE_6__* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %3
%8 = icmp eq i32* %1, null
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 0
%11 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i64 0, i32 0
%13 = load i32, i32* %12
store i32 %13, i32* %1
br label %14
14: ; preds = %9, %7
%15 = icmp eq i32* %2, null
br i1 %15, label %21, label %16
16: ; preds = %14
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 0
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %17
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i64 0, i32 1
%20 = load i32, i32* %19
store i32 %20, i32* %2
br label %21
21: ; preds = %3, %14, %16
%22 = phi i32* [ @True, %16 ], [ @True, %14 ], [ @False, %3 ]
%23 = load i32, i32* %22
ret i32 %23
}