#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
scalar_t__ opterr;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(int /*<<< orphan*/);
int OptHandler(int argc, char *argv[], char **FileName) {
  int opt = 0;
  opterr = 0;
  int WorkMode = 0;
  while ((opt = getopt(argc, argv, "rth")) != -1) {
    switch (opt) {
    case 'h': {
      usage(EXIT_SUCCESS);
      break;
    }
    case 'r': {
      if (WorkMode == 0)
        WorkMode = 1;
      else {
        usage(EXIT_FAILURE);
        return -1;
      }
      break;
    }
    case 't': {
      if (WorkMode == 0)
        WorkMode = 2;
      else {
        usage(EXIT_FAILURE);
        return -1;
      }
      break;
    }
    default: {
      fprintf(stderr, "Unrecognized command line option.\n");
      return -1;
    }
    }
  }
  if (WorkMode == 0) {
    usage(EXIT_FAILURE);
    return -1;
  }
  return WorkMode;
}


x86 assembly (clang, -O0):
<OptHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2e7f(%rip),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe93(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1257 <OptHandler+0x127>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x68,%eax
je     11b4 <OptHandler+0x84>
jmp    1192 <OptHandler+0x62>
mov    -0x24(%rbp),%eax
sub    $0x72,%eax
je     11c7 <OptHandler+0x97>
jmp    11a3 <OptHandler+0x73>
mov    -0x24(%rbp),%eax
sub    $0x74,%eax
je     11fc <OptHandler+0xcc>
jmp    1231 <OptHandler+0x101>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1040 <usage@plt>
jmp    1252 <OptHandler+0x122>
cmpl   $0x0,-0x20(%rbp)
jne    11dd <OptHandler+0xad>
movl   $0x1,-0x20(%rbp)
jmp    11f7 <OptHandler+0xc7>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1040 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1281 <OptHandler+0x151>
jmp    1252 <OptHandler+0x122>
cmpl   $0x0,-0x20(%rbp)
jne    1212 <OptHandler+0xe2>
movl   $0x2,-0x20(%rbp)
jmp    122c <OptHandler+0xfc>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1040 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1281 <OptHandler+0x151>
jmp    1252 <OptHandler+0x122>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1281 <OptHandler+0x151>
jmp    115f <OptHandler+0x2f>
cmpl   $0x0,-0x20(%rbp)
jne    127b <OptHandler+0x14b>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   1040 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1281 <OptHandler+0x151>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OptHandler>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e8c(%rip),%rax
movq   $0x0,(%rax)
xor    %r14d,%r14d
lea    0xeab(%rip),%r15
mov    0x2e6c(%rip),%r12
jmp    1169 <OptHandler+0x39>
xchg   %ax,%ax
mov    (%r12),%edi
call   1040 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x68,%eax
je     1160 <OptHandler+0x30>
cmp    $0xffffffff,%eax
je     11a4 <OptHandler+0x74>
cmp    $0x72,%eax
je     1197 <OptHandler+0x67>
cmp    $0x74,%eax
jne    11b9 <OptHandler+0x89>
test   %r14d,%r14d
mov    $0x2,%r14d
je     1169 <OptHandler+0x39>
jmp    11a9 <OptHandler+0x79>
test   %r14d,%r14d
mov    $0x1,%r14d
je     1169 <OptHandler+0x39>
jmp    11a9 <OptHandler+0x79>
test   %r14d,%r14d
jne    11d4 <OptHandler+0xa4>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1040 <usage@plt>
jmp    11ce <OptHandler+0x9e>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [4 x i8] c"rth\00"
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [35 x i8] c"Unrecognized command line option.\0A\00"
define i32 @OptHandler(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 0, i32* %8
store i64 0, i64* @opterr
store i32 0, i32* %9
br label %10
10: ; preds = %39, %3
%11 = load i32, i32* %5
%12 = load i8**, i8*** %6
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %8
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %40
15: ; preds = %10
%16 = load i32, i32* %8
switch i32 %16, label %36 [
i32 104, label %17
i32 114, label %20
i32 116, label %28
]
17: ; preds = %15
%18 = load i32, i32* @EXIT_SUCCESS
%19 = call i32 @usage(i32 %18)
br label %39
20: ; preds = %15
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %9
br label %27
24: ; preds = %20
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @usage(i32 %25)
store i32 -1, i32* %4
br label %48
27: ; preds = %23
br label %39
28: ; preds = %15
%29 = load i32, i32* %9
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 2, i32* %9
br label %35
32: ; preds = %28
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @usage(i32 %33)
store i32 -1, i32* %4
br label %48
35: ; preds = %31
br label %39
36: ; preds = %15
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %48
39: ; preds = %35, %27, %17
br label %10
40: ; preds = %10
%41 = load i32, i32* %9
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @usage(i32 %44)
store i32 -1, i32* %4
br label %48
46: ; preds = %40
%47 = load i32, i32* %9
store i32 %47, i32* %4
br label %48
48: ; preds = %46, %43, %36, %32, %24
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [4 x i8] c"rth\00"
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [35 x i8] c"Unrecognized command line option.\0A\00"
define i32 @OptHandler(i32 %0, i8** %1, i8** nocapture readnone %2) {
store i64 0, i64* @opterr
br label %4
4: ; preds = %13, %3
%5 = phi i32 [ 0, %3 ], [ %14, %13 ]
br label %6
6: ; preds = %4, %8
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %23 [
i32 -1, label %26
i32 104, label %8
i32 114, label %11
i32 116, label %18
]
8: ; preds = %6
%9 = load i32, i32* @EXIT_SUCCESS
%10 = tail call i32 @usage(i32 %9)
br label %6
11: ; preds = %6
%12 = icmp eq i32 %5, 0
br i1 %12, label %13, label %15
13: ; preds = %11, %18
%14 = phi i32 [ 2, %18 ], [ 1, %11 ]
br label %4
15: ; preds = %11
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @usage(i32 %16)
br label %31
18: ; preds = %6
%19 = icmp eq i32 %5, 0
br i1 %19, label %13, label %20
20: ; preds = %18
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @usage(i32 %21)
br label %31
23: ; preds = %6
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %31
26: ; preds = %6
%27 = icmp eq i32 %5, 0
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @usage(i32 %29)
br label %31
31: ; preds = %26, %28, %23, %20, %15
%32 = phi i32 [ -1, %23 ], [ -1, %20 ], [ -1, %15 ], [ -1, %28 ], [ %5, %26 ]
ret i32 %32
}