#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 atoi(char *);
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ show_events(int, int, int);
int /*<<< orphan*/ usage(char *, int);
int main(int argc, char *argv[]) {
  int timeout = 10;
  int grab = 0;
  int c, devnr;
  for (;;) {
    if (-1 == (c = getopt(argc, argv, "hgt:")))
      break;
    switch (c) {
    case 't':
      timeout = atoi(optarg);
      break;
    case 'g':
      grab = 1;
      break;
    case 'h':
      usage(argv[0], 0);
    default:
      usage(argv[0], 1);
    }
  }
  if (optind == argc)
    usage(argv[0], 1);
  devnr = atoi(argv[optind]);
  show_events(devnr, timeout, grab);
  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)
movl   $0xa,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8e(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    118e <main+0x4e>
jmp    120b <main+0xcb>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x67,%eax
je     11db <main+0x9b>
jmp    11a2 <main+0x62>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
je     11e7 <main+0xa7>
jmp    11b3 <main+0x73>
mov    -0x24(%rbp),%eax
sub    $0x74,%eax
jne    11f5 <main+0xb5>
jmp    11c4 <main+0x84>
mov    0x2e2d(%rip),%rax
mov    (%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1206 <main+0xc6>
movl   $0x1,-0x18(%rbp)
jmp    1206 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %esi,%esi
call   1030 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1,%esi
call   1030 <usage@plt>
jmp    1164 <main+0x24>
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    122e <main+0xee>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1,%esi
call   1030 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2da7(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <show_events@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xa,%r15d
xor    %r14d,%r14d
lea    0xea0(%rip),%r12
mov    0x2e91(%rip),%r13
jmp    1187 <main+0x47>
nopl   0x0(%rax)
mov    (%rbx),%rdi
xor    %esi,%esi
call   1030 <usage@plt>
mov    (%rbx),%rdi
mov    $0x1,%esi
call   1030 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    $0x67,%eax
jle    11c0 <main+0x80>
cmp    $0x68,%eax
je     1170 <main+0x30>
cmp    $0x74,%eax
jne    117a <main+0x3a>
mov    0x0(%r13),%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
jmp    1187 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     11d2 <main+0x92>
cmp    $0x67,%eax
jne    117a <main+0x3a>
mov    $0x1,%r14d
jmp    1187 <main+0x47>
mov    0x2e07(%rip),%r12
mov    (%r12),%eax
cmp    %ebp,%eax
jne    11f2 <main+0xb2>
mov    (%rbx),%rdi
mov    $0x1,%esi
call   1030 <usage@plt>
mov    (%r12),%eax
cltq
mov    (%rbx,%rax,8),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <show_events@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"hgt:\00"
@optarg = global i8* null
@optind = 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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %32, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %8
%14 = icmp eq i32 -1, %13
br i1 %14, label %15, label %16
15: ; preds = %10
br label %33
16: ; preds = %10
%17 = load i32, i32* %8
switch i32 %17, label %27 [
i32 116, label %18
i32 103, label %21
i32 104, label %22
]
18: ; preds = %16
%19 = load i8*, i8** @optarg
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
br label %32
21: ; preds = %16
store i32 1, i32* %7
br label %32
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @usage(i8* %25, i32 0)
br label %27
27: ; preds = %16, %22
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @usage(i8* %30, i32 1)
br label %32
32: ; preds = %27, %21, %18
br label %10
33: ; preds = %15
%34 = load i32, i32* @optind
%35 = load i32, i32* %4
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @usage(i8* %40, i32 1)
br label %42
42: ; preds = %37, %33
%43 = load i8**, i8*** %5
%44 = load i32, i32* @optind
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @atoi(i8* %47)
store i32 %48, i32* %9
%49 = load i32, i32* %9
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = call i32 @show_events(i32 %49, i32 %50, i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"hgt:\00"
@optarg = global i8* null
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %8, %2
%4 = phi i32 [ 0, %2 ], [ 1, %8 ]
%5 = phi i32 [ 10, %2 ], [ %7, %8 ]
br label %6
6: ; preds = %3, %10
%7 = phi i32 [ %5, %3 ], [ %12, %10 ]
br label %8
8: ; preds = %6, %16
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %16 [
i32 -1, label %19
i32 116, label %10
i32 103, label %3
i32 104, label %13
]
10: ; preds = %8
%11 = load i8*, i8** @optarg
%12 = tail call i32 @atoi(i8* %11)
br label %6
13: ; preds = %8
%14 = load i8*, i8** %1
%15 = tail call i32 @usage(i8* %14, i32 0)
br label %16
16: ; preds = %8, %13
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17, i32 1)
br label %8
19: ; preds = %8
%20 = load i32, i32* @optind
%21 = icmp eq i32 %20, %0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i8*, i8** %1
%24 = tail call i32 @usage(i8* %23, i32 1)
%25 = load i32, i32* @optind
br label %26
26: ; preds = %22, %19
%27 = phi i32 [ %25, %22 ], [ %20, %19 ]
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32 @atoi(i8* %30)
%32 = tail call i32 @show_events(i32 %31, i32 %7, i32 %4)
ret i32 0
}