#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_3__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ XPointer;
struct TYPE_3__ {
  scalar_t__ data;
};
typedef TYPE_1__ XExtDisplayInfo;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ XNVCTRLQueryVersion(int /*<<< orphan*/ *, int *, int *);
uintptr_t version_flags(Display *dpy, XExtDisplayInfo *info) {
  uintptr_t data = (uintptr_t)info->data;
  if (data & (1 << (sizeof(XPointer) - 1))) {
    int major, minor;
    data = 0;
    if (XNVCTRLQueryVersion(dpy, &major, &minor)) {
      data |= 1;
      if (major == 1 && (minor == 8 || minor == 9)) {
        data |= 2;
      }
      if ((major > 1) || ((major == 1) && (minor > 20))) {
        data |= 4;
      }
    }
    info->data = (XPointer)data;
  }
  return data;
}


x86 assembly (clang, -O0):
<version_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0x80,%rax
cmp    $0x0,%rax
je     11d2 <version_flags+0xc2>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <XNVCTRLQueryVersion@plt>
cmp    $0x0,%rax
je     11c7 <version_flags+0xb7>
mov    -0x18(%rbp),%rax
or     $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1198 <version_flags+0x88>
cmpl   $0x8,-0x20(%rbp)
je     118c <version_flags+0x7c>
cmpl   $0x9,-0x20(%rbp)
jne    1198 <version_flags+0x88>
mov    -0x18(%rbp),%rax
or     $0x2,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jg     11b6 <version_flags+0xa6>
cmpl   $0x1,-0x1c(%rbp)
jne    11c2 <version_flags+0xb2>
cmpl   $0x14,-0x20(%rbp)
jle    11c2 <version_flags+0xb2>
mov    -0x18(%rbp),%rax
or     $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    11c7 <version_flags+0xb7>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<version_flags>:
push   %rbx
sub    $0x10,%rsp
mov    (%rsi),%rax
test   $0x80,%al
je     116f <version_flags+0x5f>
mov    %rsi,%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <XNVCTRLQueryVersion@plt>
test   %rax,%rax
je     116a <version_flags+0x5a>
mov    0xc(%rsp),%edx
mov    %edx,%eax
xor    $0x1,%eax
mov    0x8(%rsp),%ecx
mov    %ecx,%esi
and    $0xfffffffe,%esi
xor    $0x8,%esi
xor    %edi,%edi
or     %eax,%esi
sete   %dil
lea    (%rdi,%rdi,1),%rax
add    $0x1,%rax
cmp    $0x1,%edx
jg     1164 <version_flags+0x54>
jne    116c <version_flags+0x5c>
cmp    $0x15,%ecx
jl     116c <version_flags+0x5c>
or     $0x4,%rax
jmp    116c <version_flags+0x5c>
xor    %eax,%eax
mov    %rax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64 }
define i64 @version_flags(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i64, i64* %9
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = and i64 %11, 128
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %49
14: ; preds = %2
store i64 0, i64* %5
%15 = load i32*, i32** %3
%16 = call i64 @XNVCTRLQueryVersion(i32* %15, i32* %6, i32* %7)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %45
18: ; preds = %14
%19 = load i64, i64* %5
%20 = or i64 %19, 1
store i64 %20, i64* %5
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 8
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 9
br i1 %28, label %29, label %32
29: ; preds = %26, %23
%30 = load i64, i64* %5
%31 = or i64 %30, 2
store i64 %31, i64* %5
br label %32
32: ; preds = %29, %26, %18
%33 = load i32, i32* %6
%34 = icmp sgt i32 %33, 1
br i1 %34, label %41, label %35
35: ; preds = %32
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %7
%40 = icmp sgt i32 %39, 20
br i1 %40, label %41, label %44
41: ; preds = %38, %32
%42 = load i64, i64* %5
%43 = or i64 %42, 4
store i64 %43, i64* %5
br label %44
44: ; preds = %41, %38, %35
br label %45
45: ; preds = %44, %14
%46 = load i64, i64* %5
%47 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %47, i32 0, i32 0
store i64 %46, i64* %48
br label %49
49: ; preds = %45, %2
%50 = load i64, i64* %5
ret i64 %50
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64 }
define i64 @version_flags(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%6 = load i64, i64* %5
%7 = and i64 %6, 128
%8 = icmp eq i64 %7, 0
br i1 %8, label %30, label %9
9: ; preds = %2
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = call i64 @XNVCTRLQueryVersion(i32* %0, i32* %3, i32* %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %28, label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
%17 = load i32, i32* %4
%18 = and i32 %17, -2
%19 = icmp eq i32 %18, 8
%20 = select i1 %16, i1 %19, i1 false
%21 = select i1 %20, i64 3, i64 1
%22 = icmp sgt i32 %15, 1
br i1 %22, label %26, label %23
23: ; preds = %14
%24 = icmp sgt i32 %17, 20
%25 = select i1 %16, i1 %24, i1 false
br i1 %25, label %26, label %28
26: ; preds = %23, %14
%27 = or i64 %21, 4
br label %28
28: ; preds = %23, %26, %9
%29 = phi i64 [ %27, %26 ], [ %21, %23 ], [ 0, %9 ]
store i64 %29, i64* %5
br label %30
30: ; preds = %28, %2
%31 = phi i64 [ %29, %28 ], [ %6, %2 ]
ret i64 %31
}