#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*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ GetMouseLocation(int /*<<< orphan*/ *, int *, int *, int *,
                                    int /*<<< orphan*/ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XLowerWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(char *);
int /*<<< orphan*/ XRaiseWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strstr(char *, char *);
int main(int argc, char **argv) {
  int x, y, screen_num;
  Window window;
  Display *display;
  char *displayName;
  if ((displayName = getenv("DISPLAY")) == NULL) {
    display = XOpenDisplay(":0");
  } else {
    display = XOpenDisplay(displayName);
  }
  if (!GetMouseLocation(display, &x, &y, &screen_num, &window)) {
    if (strstr(argv[0], "lower")) {
      if (!XLowerWindow(display, window)) {
        fprintf(stderr, "XRaiseWindow error?\n");
        exit(1);
      }
    } else {
      if (!XRaiseWindow(display, window)) {
        fprintf(stderr, "XRaiseWindow error?\n");
        exit(1);
      }
    }
  }
  XCloseDisplay(display);
  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)
lea    0xe53(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11d5 <main+0x45>
lea    0xe41(%rip),%rdi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x28(%rbp)
jmp    11e2 <main+0x52>
mov    -0x30(%rbp),%rdi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1080 <GetMouseLocation@plt>
cmp    $0x0,%eax
jne    1298 <main+0x108>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf9(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     125a <main+0xca>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1060 <XLowerWindow@plt>
cmp    $0x0,%eax
jne    1255 <main+0xc5>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1293 <main+0x103>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1090 <XRaiseWindow@plt>
cmp    $0x0,%eax
jne    128e <main+0xfe>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    0xd92(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1293 <main+0x103>
jmp    1298 <main+0x108>
mov    -0x28(%rbp),%rdi
call   10a0 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
lea    0xe5f(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b0 <main+0x20>
mov    %rax,%rdi
jmp    11b7 <main+0x27>
lea    0xe51(%rip),%rdi
call   1040 <XOpenDisplay@plt>
mov    %rax,%rbx
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rax,%rdi
call   1080 <GetMouseLocation@plt>
test   %eax,%eax
jne    1203 <main+0x73>
mov    (%r14),%rdi
lea    0xe22(%rip),%rsi
call   10b0 <strstr@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
test   %rax,%rax
je     1215 <main+0x85>
call   1060 <XLowerWindow@plt>
test   %eax,%eax
je     121e <main+0x8e>
mov    %rbx,%rdi
call   10a0 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
call   1090 <XRaiseWindow@plt>
test   %eax,%eax
jne    1203 <main+0x73>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"DISPLAY\00"
@.str.1 = [3 x i8] c":0\00"
@.str.2 = [6 x i8] c"lower\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"XRaiseWindow error?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32* @XOpenDisplay(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %10
br label %19
16: ; preds = %2
%17 = load i8*, i8** %11
%18 = call i32* @XOpenDisplay(i8* %17)
store i32* %18, i32** %10
br label %19
19: ; preds = %16, %14
%20 = load i32*, i32** %10
%21 = call i32 @GetMouseLocation(i32* %20, i32* %6, i32* %7, i32* %8, i32* %9)
%22 = icmp ne i32 %21, 0
br i1 %22, label %50, label %23
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i64 @strstr(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %23
%30 = load i32*, i32** %10
%31 = load i32, i32* %9
%32 = call i32 @XLowerWindow(i32* %30, i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
br label %49
39: ; preds = %23
%40 = load i32*, i32** %10
%41 = load i32, i32* %9
%42 = call i32 @XRaiseWindow(i32* %40, i32 %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %39
br label %49
49: ; preds = %48, %38
br label %50
50: ; preds = %49, %19
%51 = load i32*, i32** %10
%52 = call i32 @XCloseDisplay(i32* %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"DISPLAY\00"
@.str.1 = [3 x i8] c":0\00"
@.str.2 = [6 x i8] c"lower\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"XRaiseWindow error?\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32* @XOpenDisplay(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %2
%16 = tail call i32* @XOpenDisplay(i8* %11)
br label %17
17: ; preds = %15, %13
%18 = phi i32* [ %14, %13 ], [ %16, %15 ]
%19 = call i32 @GetMouseLocation(i32* %18, i32* %3, i32* %4, i32* %5, i32* %6)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %17
%22 = load i8*, i8** %1
%23 = call i64 @strstr(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = load i32, i32* %6
br i1 %24, label %33, label %26
26: ; preds = %21
%27 = call i32 @XLowerWindow(i32* %18, i32 %25)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %21
%34 = call i32 @XRaiseWindow(i32* %18, i32 %25)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %26, %33, %17
%41 = call i32 @XCloseDisplay(i32* %18)
ret i32 0
}