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

/* Variables and functions */
int /*<<< orphan*/ LockMask;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XkbLockModifiers(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XkbUseCoreKbd;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  Display *disp;
  if (argc > 1) {
    usage(argv[0]);
    return 1;
  }
  disp = XOpenDisplay(NULL);
  if (!disp) {
    fprintf(stderr, "Could not connect to X server.\n");
    return 1;
  }
  if (!XkbLockModifiers(disp, XkbUseCoreKbd, LockMask, 0)) {
    fprintf(stderr, "Unlocking Caps Lock failed.\n");
  }
  XCloseDisplay(disp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1188 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    120c <main+0xbc>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c1 <main+0x71>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120c <main+0xbc>
mov    -0x18(%rbp),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
mov    0x2dfb(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1040 <XkbLockModifiers@plt>
cmp    $0x0,%eax
jne    11fc <main+0xac>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1163 <main+0x13>
mov    (%rsi),%rdi
call   1060 <usage@plt>
jmp    11c8 <main+0x78>
xor    %edi,%edi
call   1030 <XOpenDisplay@plt>
test   %rax,%rax
je     11b3 <main+0x63>
mov    %rax,%r14
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %ecx,%ecx
call   1040 <XkbLockModifiers@plt>
test   %eax,%eax
jne    11a9 <main+0x59>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1070 <XCloseDisplay@plt>
jmp    11cd <main+0x7d>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Could not connect to X server.\0A\00"
@XkbUseCoreKbd = global i32 0
@LockMask = global i32 0
@.str.1 = [29 x i8] c"Unlocking Caps Lock failed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @usage(i8* %12)
store i32 1, i32* %3
br label %33
14: ; preds = %2
%15 = call i32* @XOpenDisplay(i32* null)
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %33
21: ; preds = %14
%22 = load i32*, i32** %6
%23 = load i32, i32* @XkbUseCoreKbd
%24 = load i32, i32* @LockMask
%25 = call i32 @XkbLockModifiers(i32* %22, i32 %23, i32 %24, i32 0)
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %27, %21
%31 = load i32*, i32** %6
%32 = call i32 @XCloseDisplay(i32* %31)
store i32 0, i32* %3
br label %33
33: ; preds = %30, %18, %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Could not connect to X server.\0A\00"
@XkbUseCoreKbd = global i32 0
@LockMask = global i32 0
@.str.1 = [29 x i8] c"Unlocking Caps Lock failed.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %23
7: ; preds = %2
%8 = tail call i32* @XOpenDisplay(i32* null)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %23
13: ; preds = %7
%14 = load i32, i32* @XkbUseCoreKbd
%15 = load i32, i32* @LockMask
%16 = tail call i32 @XkbLockModifiers(i32* %8, i32 %14, i32 %15, i32 0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18, %13
%22 = tail call i32 @XCloseDisplay(i32* %8)
br label %23
23: ; preds = %21, %10, %4
%24 = phi i32 [ 1, %4 ], [ 0, %21 ], [ 1, %10 ]
ret i32 %24
}