#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*/ Display;
typedef scalar_t__ Bool;

/* Variables and functions */
scalar_t__ True;
char *XDisplayName(int /*<<< orphan*/ *);
scalar_t__ XNVCTRLQueryVersion(int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ do_disable(int /*<<< orphan*/ *);
int /*<<< orphan*/ do_enable(int /*<<< orphan*/ *);
int /*<<< orphan*/ do_help();
int /*<<< orphan*/ do_query(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  Display *dpy;
  Bool ret;
  int major, minor;
  dpy = XOpenDisplay(NULL);
  if (!dpy) {
    printf("Cannot open display '%s'.\n", XDisplayName(NULL));
    return 1;
  }
  ret = XNVCTRLQueryVersion(dpy, &major, &minor);
  if (ret != True) {
    printf("The NV-CONTROL X extension does not exist on '%s'.\n",
           XDisplayName(NULL));
    return 1;
  }
  printf("Using NV-CONTROL extension %d.%d on %s\n\n", major, minor,
         XDisplayName(NULL));
  if ((major < 1) || (major == 1 && minor < 9)) {
    printf("The NV-CONTROL X extension is too old.  Version 1.9 or above "
           " is required for configuring Frame Lock via target types.\n");
    return 1;
  }
  if (argc <= 1 || (strcmp(argv[1], "-q") == 0)) {
    do_query(dpy);
  } else if (strcmp(argv[1], "-e") == 0) {
    do_enable(dpy);
  } else if (strcmp(argv[1], "-d") == 0) {
    do_disable(dpy);
  } else {
    do_help();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e4 <main+0x54>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <XDisplayName@plt>
mov    %rax,%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    133d <main+0x1ad>
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1090 <XNVCTRLQueryVersion@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%rax
je     1233 <main+0xa3>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <XDisplayName@plt>
mov    %rax,%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    133d <main+0x1ad>
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <XDisplayName@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    %rax,%rcx
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x24(%rbp)
jl     127d <main+0xed>
cmpl   $0x1,-0x24(%rbp)
jne    1297 <main+0x107>
cmpl   $0x9,-0x28(%rbp)
jge    1297 <main+0x107>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    133d <main+0x1ad>
cmpl   $0x1,-0x8(%rbp)
jle    12bf <main+0x12f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12cd <main+0x13d>
mov    -0x18(%rbp),%rdi
call   1040 <do_query@plt>
jmp    1336 <main+0x1a6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe17(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12f9 <main+0x169>
mov    -0x18(%rbp),%rdi
call   1030 <do_enable@plt>
jmp    1331 <main+0x1a1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdee(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1325 <main+0x195>
mov    -0x18(%rbp),%rdi
call   1060 <do_disable@plt>
jmp    132c <main+0x19c>
mov    $0x0,%al
call   10b0 <do_help@plt>
jmp    1331 <main+0x1a1>
jmp    1336 <main+0x1a6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
xor    %edi,%edi
call   1090 <XOpenDisplay@plt>
test   %rax,%rax
je     1227 <main+0x87>
mov    %rax,%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   10a0 <XNVCTRLQueryVersion@plt>
mov    0x2e0e(%rip),%rcx
cmp    (%rcx),%rax
jne    1237 <main+0x97>
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%r12d
xor    %edi,%edi
call   10b0 <XDisplayName@plt>
lea    0xe59(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1219 <main+0x79>
cmp    $0x1,%eax
jne    1263 <main+0xc3>
cmpl   $0x8,0x8(%rsp)
jg     1263 <main+0xc3>
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
jmp    124f <main+0xaf>
xor    %edi,%edi
call   10b0 <XDisplayName@plt>
lea    0xdcb(%rip),%rdi
jmp    1245 <main+0xa5>
xor    %edi,%edi
call   10b0 <XDisplayName@plt>
lea    0xdd6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x2,%r15d
jl     12b3 <main+0x113>
mov    0x8(%r14),%rdi
lea    0xe04(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12b3 <main+0x113>
mov    0x8(%r14),%rdi
lea    0xdf2(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12bf <main+0x11f>
mov    0x8(%r14),%rdi
lea    0xde0(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12cb <main+0x12b>
xor    %ebx,%ebx
xor    %eax,%eax
call   10c0 <do_help@plt>
jmp    1254 <main+0xb4>
mov    %rbx,%rdi
call   1050 <do_query@plt>
xor    %ebx,%ebx
jmp    1254 <main+0xb4>
mov    %rbx,%rdi
call   1030 <do_enable@plt>
xor    %ebx,%ebx
jmp    1254 <main+0xb4>
mov    %rbx,%rdi
call   1070 <do_disable@plt>
xor    %ebx,%ebx
jmp    1254 <main+0xb4>

LLVM IR (-O0):
@.str = [27 x i8] c"Cannot open display '%s'.\0A\00"
@True = global i64 0
@.str.1 = [52 x i8] c"The NV-CONTROL X extension does not exist on '%s'.\0A\00"
@.str.2 = [41 x i8] c"Using NV-CONTROL extension %d.%d on %s\0A\0A\00"
@.str.3 = [120 x i8] c"The NV-CONTROL X extension is too old. Version 1.9 or above is required for configuring Frame Lock via target types.\0A\00"
@.str.4 = [3 x i8] c"-q\00"
@.str.5 = [3 x i8] c"-e\00"
@.str.6 = [3 x i8] c"-d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32* @XOpenDisplay(i32* null)
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = icmp ne i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = call i8* @XDisplayName(i32* null)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %75
16: ; preds = %2
%17 = load i32*, i32** %6
%18 = call i64 @XNVCTRLQueryVersion(i32* %17, i32* %8, i32* %9)
store i64 %18, i64* %7
%19 = load i64, i64* %7
%20 = load i64, i64* @True
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i8* @XDisplayName(i32* null)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %75
25: ; preds = %16
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = call i8* @XDisplayName(i32* null)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27, i8* %28)
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 1
br i1 %31, label %38, label %32
32: ; preds = %25
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i32, i32* %9
%37 = icmp slt i32 %36, 9
br i1 %37, label %38, label %40
38: ; preds = %35, %25
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %75
40: ; preds = %35, %32
%41 = load i32, i32* %4
%42 = icmp sle i32 %41, 1
br i1 %42, label %49, label %43
43: ; preds = %40
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %43, %40
%50 = load i32*, i32** %6
%51 = call i32 @do_query(i32* %50)
br label %74
52: ; preds = %43
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = load i32*, i32** %6
%60 = call i32 @do_enable(i32* %59)
br label %73
61: ; preds = %52
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %61
%68 = load i32*, i32** %6
%69 = call i32 @do_disable(i32* %68)
br label %72
70: ; preds = %61
%71 = call i32 (...) @do_help()
br label %72
72: ; preds = %70, %67
br label %73
73: ; preds = %72, %58
br label %74
74: ; preds = %73, %49
store i32 0, i32* %3
br label %75
75: ; preds = %74, %38, %22, %13
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@.str = [27 x i8] c"Cannot open display '%s'.\0A\00"
@True = global i64 0
@.str.1 = [52 x i8] c"The NV-CONTROL X extension does not exist on '%s'.\0A\00"
@.str.2 = [41 x i8] c"Using NV-CONTROL extension %d.%d on %s\0A\0A\00"
@.str.4 = [3 x i8] c"-q\00"
@.str.5 = [3 x i8] c"-e\00"
@.str.6 = [3 x i8] c"-d\00"
@str = [119 x i8] c"The NV-CONTROL X extension is too old. Version 1.9 or above is required for configuring Frame Lock via target types.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32* @XOpenDisplay(i32* null)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i8* @XDisplayName(i32* null)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %56
12: ; preds = %2
%13 = call i64 @XNVCTRLQueryVersion(i32* %7, i32* %3, i32* %4)
%14 = load i64, i64* @True
%15 = icmp eq i64 %13, %14
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = call i8* @XDisplayName(i32* null)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %56
19: ; preds = %12
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i8* @XDisplayName(i32* null)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21, i8* %22)
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 1
br i1 %25, label %31, label %26
26: ; preds = %19
%27 = icmp eq i32 %24, 1
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 9
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %31, label %33
31: ; preds = %26, %19
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([119 x i8], [119 x i8]* @str, i64 0, i64 0))
br label %56
33: ; preds = %26
%34 = icmp slt i32 %0, 2
br i1 %34, label %40, label %35
35: ; preds = %33
%36 = getelementptr inbounds i8*, i8** %1, i64 1
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35, %33
%41 = call i32 @do_query(i32* %7)
br label %56
42: ; preds = %35
%43 = load i8*, i8** %36
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @do_enable(i32* %7)
br label %56
48: ; preds = %42
%49 = load i8*, i8** %36
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 @do_disable(i32* %7)
br label %56
54: ; preds = %48
%55 = call i32 (...) @do_help()
br label %56
56: ; preds = %40, %52, %54, %46, %31, %16, %9
%57 = phi i32 [ 1, %16 ], [ 1, %31 ], [ 1, %9 ], [ 0, %46 ], [ 0, %54 ], [ 0, %52 ], [ 0, %40 ]
ret i32 %57
}