#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 EINVAL;
int EXIT_SUCCESS;
int getopt(int, char **, char *);
int optind;
int parse_int(char *);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ tunit_run_suite(char *, char const *, int);
int tunit_run_test(int, char **, int);
int tunit_main(int argc, char **argv, const char *name) {
  int opt;
  int fork = 0;
  while ((opt = getopt(argc, argv, "hf")) != -1) {
    switch (opt) {
    case 'h':
      print_usage(argv[0]);
      return EXIT_SUCCESS;
    case 'f':
      fork = 1;
      break;
    default:
      print_usage(argv[0]);
      return EINVAL;
    }
  }
  if (optind >= argc) {
    tunit_run_suite(argv[0], name, fork);
  } else {
    int test_num = parse_int(argv[optind]);
    if (test_num != -1) {
      return tunit_run_test(argc, argv, test_num);
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<tunit_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe88(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11f9 <tunit_main+0xa9>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x66,%eax
je     11cb <tunit_main+0x7b>
jmp    119d <tunit_main+0x4d>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
jne    11d7 <tunit_main+0x87>
jmp    11ae <tunit_main+0x5e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <print_usage@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    126f <tunit_main+0x11f>
movl   $0x1,-0x20(%rbp)
jmp    11f4 <tunit_main+0xa4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <print_usage@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    126f <tunit_main+0x11f>
jmp    116a <tunit_main+0x1a>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1223 <tunit_main+0xd3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1040 <tunit_run_suite@plt>
jmp    1263 <tunit_main+0x113>
mov    -0x10(%rbp),%rax
mov    0x2dba(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <parse_int@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
je     125e <tunit_main+0x10e>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <tunit_run_test@plt>
mov    %eax,-0x4(%rbp)
jmp    126f <tunit_main+0x11f>
jmp    1263 <tunit_main+0x113>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tunit_main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
xor    %ecx,%ecx
lea    0xe97(%rip),%r12
nopl   0x0(%rax)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x66,%eax
je     1170 <tunit_main+0x20>
cmp    $0xffffffff,%eax
je     119d <tunit_main+0x4d>
cmp    $0x68,%eax
jne    11cd <tunit_main+0x7d>
mov    (%r15),%rdi
call   1060 <print_usage@plt>
jmp    11eb <tunit_main+0x9b>
mov    0x2e44(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    11de <tunit_main+0x8e>
mov    (%r15,%rax,8),%rdi
call   1070 <parse_int@plt>
cmp    $0xffffffff,%eax
je     11eb <tunit_main+0x9b>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <tunit_run_test@plt>
mov    (%r15),%rdi
call   1060 <print_usage@plt>
mov    0x2dfc(%rip),%rax
jmp    11f2 <tunit_main+0xa2>
mov    (%r15),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <tunit_run_suite@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"hf\00"
@EXIT_SUCCESS = global i32 0
@EINVAL = global i32 0
@optind = global i32 0
define i32 @tunit_main(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i32 0, i32* %9
br label %11
11: ; preds = %31, %3
%12 = load i32, i32* %5
%13 = load i8**, i8*** %6
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %8
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %32
16: ; preds = %11
%17 = load i32, i32* %8
switch i32 %17, label %25 [
i32 104, label %18
i32 102, label %24
]
18: ; preds = %16
%19 = load i8**, i8*** %6
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @print_usage(i8* %21)
%23 = load i32, i32* @EXIT_SUCCESS
store i32 %23, i32* %4
br label %60
24: ; preds = %16
store i32 1, i32* %9
br label %31
25: ; preds = %16
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @print_usage(i8* %28)
%30 = load i32, i32* @EINVAL
store i32 %30, i32* %4
br label %60
31: ; preds = %24
br label %11
32: ; preds = %11
%33 = load i32, i32* @optind
%34 = load i32, i32* %5
%35 = icmp sge i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8**, i8*** %6
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = load i8*, i8** %7
%41 = load i32, i32* %9
%42 = call i32 @tunit_run_suite(i8* %39, i8* %40, i32 %41)
br label %58
43: ; preds = %32
%44 = load i8**, i8*** %6
%45 = load i32, i32* @optind
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @parse_int(i8* %48)
store i32 %49, i32* %10
%50 = load i32, i32* %10
%51 = icmp ne i32 %50, -1
br i1 %51, label %52, label %57
52: ; preds = %43
%53 = load i32, i32* %5
%54 = load i8**, i8*** %6
%55 = load i32, i32* %10
%56 = call i32 @tunit_run_test(i32 %53, i8** %54, i32 %55)
store i32 %56, i32* %4
br label %60
57: ; preds = %43
br label %58
58: ; preds = %57, %36
%59 = load i32, i32* @EXIT_SUCCESS
store i32 %59, i32* %4
br label %60
60: ; preds = %58, %52, %25, %18
%61 = load i32, i32* %4
ret i32 %61
}

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