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

/* Variables and functions */
int /*<<< orphan*/ SIGCONT;
int /*<<< orphan*/ SIGSTOP;
int findVictim(unsigned int *);
int /*<<< orphan*/ printf(char *, int, unsigned int);
int /*<<< orphan*/ sendSignal(int, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  int i;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--sleep") == 0)
      usleep(250000);
  }
  unsigned int button;
  Window xid = findVictim(&button);
  printf("I think you clicked window %d with button %u\n", xid, button);
  switch (button) {
  case 1:
    sendSignal(xid, SIGCONT);
    break;
  case 3:
    sendSignal(xid, SIGSTOP);
    break;
  }
  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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <main+0x68>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a5 <main+0x55>
mov    $0x3d090,%edi
call   1070 <usleep@plt>
jmp    11aa <main+0x5a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
lea    -0x18(%rbp),%rdi
call   1050 <findVictim@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x1,%eax
je     11fb <main+0xab>
jmp    11ea <main+0x9a>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
je     1211 <main+0xc1>
jmp    1222 <main+0xd2>
mov    -0x1c(%rbp),%edi
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
call   1060 <sendSignal@plt>
jmp    1222 <main+0xd2>
mov    -0x1c(%rbp),%edi
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
call   1060 <sendSignal@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11a6 <main+0x56>
mov    %rsi,%r15
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xe91(%rip),%r14
jmp    1189 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11a6 <main+0x56>
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1180 <main+0x30>
mov    $0x3d090,%edi
call   1070 <usleep@plt>
jmp    1180 <main+0x30>
lea    0x4(%rsp),%rdi
call   1050 <findVictim@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edx
lea    0xe4b(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11db <main+0x8b>
cmp    $0x3,%eax
jne    11eb <main+0x9b>
mov    0x2dff(%rip),%rax
jmp    11e2 <main+0x92>
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1060 <sendSignal@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"--sleep\00"
@.str.1 = [46 x i8] c"I think you clicked window %d with button %u\0A\00"
@SIGCONT = global i32 0
@SIGSTOP = global i32 0
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = call i32 @usleep(i32 250000)
br label %23
23: ; preds = %21, %13
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
%28 = call i32 @findVictim(i32* %7)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i32, i32* %7
switch i32 %32, label %41 [
i32 1, label %33
i32 3, label %37
]
33: ; preds = %27
%34 = load i32, i32* %8
%35 = load i32, i32* @SIGCONT
%36 = call i32 @sendSignal(i32 %34, i32 %35)
br label %41
37: ; preds = %27
%38 = load i32, i32* %8
%39 = load i32, i32* @SIGSTOP
%40 = call i32 @sendSignal(i32 %38, i32 %39)
br label %41
41: ; preds = %27, %37, %33
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"--sleep\00"
@.str.1 = [46 x i8] c"I think you clicked window %d with button %u\0A\00"
@SIGCONT = global i32 0
@SIGSTOP = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 1, %5 ], [ %16, %15 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @usleep(i32 250000)
br label %15
15: ; preds = %7, %13
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %15, %2
%19 = bitcast i32* %3 to i8*
%20 = call i32 @findVictim(i32* %3)
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %3
switch i32 %23, label %29 [
i32 1, label %25
i32 3, label %24
]
24: ; preds = %18
br label %25
25: ; preds = %18, %24
%26 = phi i32* [ @SIGSTOP, %24 ], [ @SIGCONT, %18 ]
%27 = load i32, i32* %26
%28 = call i32 @sendSignal(i32 %20, i32 %27)
br label %29
29: ; preds = %25, %18
ret i32 0
}