#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*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/);
int /*<<< orphan*/ numlock(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int arc, char *arg[]) {
  Display *c;
  if (arc != 2)
    return -1;
  c = XOpenDisplay(0);
  if (!c)
    return -1;
  if (!strcmp(arg[1], "on") || !strcmp(arg[1], "1"))
    numlock(c, 1);
  else
    numlock(c, 0);
  XCloseDisplay(c);
  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   $0x2,-0x8(%rbp)
je     116c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f6 <main+0xb6>
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <main+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11c8 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11db <main+0x9b>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1030 <numlock@plt>
jmp    11e6 <main+0xa6>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <numlock@plt>
mov    -0x18(%rbp),%rdi
call   1060 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebp
cmp    $0x2,%edi
jne    11a7 <main+0x67>
mov    %rsi,%rbx
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     11a7 <main+0x67>
mov    %rax,%r14
mov    0x8(%rbx),%rbx
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1190 <main+0x50>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %esi,%esi
test   %eax,%eax
sete   %sil
jmp    1195 <main+0x55>
mov    $0x1,%esi
mov    %r14,%rdi
call   1030 <numlock@plt>
mov    %r14,%rdi
call   1060 <XCloseDisplay@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [2 x i8] c"1\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 ne i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %36
10: ; preds = %2
%11 = call i32* @XOpenDisplay(i32 0)
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %15, label %14
14: ; preds = %10
store i32 -1, i32* %3
br label %36
15: ; preds = %10
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %21, %15
%28 = load i32*, i32** %6
%29 = call i32 @numlock(i32* %28, i32 1)
br label %33
30: ; preds = %21
%31 = load i32*, i32** %6
%32 = call i32 @numlock(i32* %31, i32 0)
br label %33
33: ; preds = %30, %27
%34 = load i32*, i32** %6
%35 = call i32 @XCloseDisplay(i32* %34)
store i32 0, i32* %3
br label %36
36: ; preds = %33, %14, %9
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [2 x i8] c"1\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = tail call i32* @XOpenDisplay(i32 0)
%6 = icmp eq i32* %5, null
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %7
%17 = phi i32 [ 1, %7 ], [ %15, %12 ]
%18 = tail call i32 @numlock(i32* %5, i32 %17)
%19 = tail call i32 @XCloseDisplay(i32* %5)
br label %20
20: ; preds = %4, %2, %16
%21 = phi i32 [ 0, %16 ], [ -1, %2 ], [ -1, %4 ]
ret i32 %21
}