#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ clearEventFlag(int /*<<< orphan*/);
int /*<<< orphan*/ createEventFlag(int /*<<< orphan*/);
int /*<<< orphan*/ deleteEventFlag(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getEventFlag(int /*<<< orphan*/);
char getopt(int, char **, char *);
int /*<<< orphan*/ helpAndExit(char *, int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ setEventFlag(int /*<<< orphan*/);
int /*<<< orphan*/ waitForEventFlag(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char opt;
  if (argc == 1) {
    helpAndExit(argv[0], EXIT_SUCCESS);
  }
  while ((opt = getopt(argc, argv, "+c:s:x:g:w:d:h")) != -1) {
    switch (opt) {
    case 'c':
      createEventFlag(optarg);
      break;
    case 's':
      setEventFlag(optarg);
      break;
    case 'x':
      clearEventFlag(optarg);
      break;
    case 'g':
      getEventFlag(optarg);
      break;
    case 'w':
      waitForEventFlag(optarg);
      break;
    case 'd':
      deleteEventFlag(optarg);
      break;
    case 'h':
      helpAndExit(argv[0], EXIT_SUCCESS);
      break;
    }
  }
  exit(EXIT_SUCCESS);
}


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)
jne    11c5 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
call   1090 <helpAndExit@plt>
jmp    11ca <main+0x3a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdx
call   1080 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     12a2 <main+0x112>
movsbl -0x11(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x15,%eax
ja     129d <main+0x10d>
mov    -0x20(%rbp),%rax
lea    0xdf3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1030 <createEventFlag@plt>
jmp    129d <main+0x10d>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1070 <setEventFlag@plt>
jmp    129d <main+0x10d>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   1050 <clearEventFlag@plt>
jmp    129d <main+0x10d>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   10b0 <getEventFlag@plt>
jmp    129d <main+0x10d>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1060 <waitForEventFlag@plt>
jmp    129d <main+0x10d>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   1040 <deleteEventFlag@plt>
jmp    129d <main+0x10d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
call   1090 <helpAndExit@plt>
jmp    11ca <main+0x3a>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
cmp    $0x1,%edi
jne    11b7 <main+0x27>
mov    (%rbx),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1090 <helpAndExit@plt>
lea    0xe9a(%rip),%rdx
mov    %r15d,%edi
mov    %rbx,%rsi
call   1080 <getopt@plt>
cmp    $0xff,%al
jne    11db <main+0x4b>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xe76(%rip),%r14
lea    0xe17(%rip),%rbp
mov    0x2e08(%rip),%r12
mov    0x2de1(%rip),%r13
jmp    1222 <main+0x92>
mov    (%r12),%edi
call   1040 <deleteEventFlag@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0xff,%al
je     11cd <main+0x3d>
movsbl %al,%eax
add    $0xffffff9d,%eax
cmp    $0x15,%eax
ja     1210 <main+0x80>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    (%r12),%edi
call   1030 <createEventFlag@plt>
jmp    1210 <main+0x80>
mov    (%r12),%edi
call   1060 <waitForEventFlag@plt>
jmp    1210 <main+0x80>
mov    (%r12),%edi
call   10b0 <getEventFlag@plt>
jmp    1210 <main+0x80>
mov    (%rbx),%rdi
mov    0x0(%r13),%esi
call   1090 <helpAndExit@plt>
jmp    1210 <main+0x80>
mov    (%r12),%edi
call   1070 <setEventFlag@plt>
jmp    1210 <main+0x80>
mov    (%r12),%edi
call   1050 <clearEventFlag@plt>
jmp    1210 <main+0x80>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [15 x i8] c"+c:s:x:g:w:d:h\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = load i32, i32* @EXIT_SUCCESS
%14 = call i32 @helpAndExit(i8* %12, i32 %13)
br label %15
15: ; preds = %9, %2
br label %16
16: ; preds = %49, %15
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call signext i8 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8 %19, i8* %6
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %50
22: ; preds = %16
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
switch i32 %24, label %49 [
i32 99, label %25
i32 115, label %28
i32 120, label %31
i32 103, label %34
i32 119, label %37
i32 100, label %40
i32 104, label %43
]
25: ; preds = %22
%26 = load i32, i32* @optarg
%27 = call i32 @createEventFlag(i32 %26)
br label %49
28: ; preds = %22
%29 = load i32, i32* @optarg
%30 = call i32 @setEventFlag(i32 %29)
br label %49
31: ; preds = %22
%32 = load i32, i32* @optarg
%33 = call i32 @clearEventFlag(i32 %32)
br label %49
34: ; preds = %22
%35 = load i32, i32* @optarg
%36 = call i32 @getEventFlag(i32 %35)
br label %49
37: ; preds = %22
%38 = load i32, i32* @optarg
%39 = call i32 @waitForEventFlag(i32 %38)
br label %49
40: ; preds = %22
%41 = load i32, i32* @optarg
%42 = call i32 @deleteEventFlag(i32 %41)
br label %49
43: ; preds = %22
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i32, i32* @EXIT_SUCCESS
%48 = call i32 @helpAndExit(i8* %46, i32 %47)
br label %49
49: ; preds = %22, %43, %40, %37, %34, %31, %28, %25
br label %16
50: ; preds = %16
%51 = load i32, i32* @EXIT_SUCCESS
%52 = call i32 @exit(i32 %51)
unreachable
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [15 x i8] c"+c:s:x:g:w:d:h\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = load i32, i32* @EXIT_SUCCESS
%7 = tail call i32 @helpAndExit(i8* %5, i32 %6)
br label %8
8: ; preds = %4, %2
%9 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8 %9, -1
br i1 %10, label %39, label %11
11: ; preds = %8, %36
%12 = phi i8 [ %37, %36 ], [ %9, %8 ]
%13 = sext i8 %12 to i32
switch i32 %13, label %36 [
i32 99, label %14
i32 115, label %17
i32 120, label %20
i32 103, label %23
i32 119, label %26
i32 100, label %29
i32 104, label %32
]
14: ; preds = %11
%15 = load i32, i32* @optarg
%16 = tail call i32 @createEventFlag(i32 %15)
br label %36
17: ; preds = %11
%18 = load i32, i32* @optarg
%19 = tail call i32 @setEventFlag(i32 %18)
br label %36
20: ; preds = %11
%21 = load i32, i32* @optarg
%22 = tail call i32 @clearEventFlag(i32 %21)
br label %36
23: ; preds = %11
%24 = load i32, i32* @optarg
%25 = tail call i32 @getEventFlag(i32 %24)
br label %36
26: ; preds = %11
%27 = load i32, i32* @optarg
%28 = tail call i32 @waitForEventFlag(i32 %27)
br label %36
29: ; preds = %11
%30 = load i32, i32* @optarg
%31 = tail call i32 @deleteEventFlag(i32 %30)
br label %36
32: ; preds = %11
%33 = load i8*, i8** %1
%34 = load i32, i32* @EXIT_SUCCESS
%35 = tail call i32 @helpAndExit(i8* %33, i32 %34)
br label %36
36: ; preds = %11, %32, %29, %26, %23, %20, %17, %14
%37 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i8 %37, -1
br i1 %38, label %39, label %11
39: ; preds = %36, %8
%40 = load i32, i32* @EXIT_SUCCESS
%41 = tail call i32 @exit(i32 %40)
unreachable
}