#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 /*<<< orphan*/ custom();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ one();
int /*<<< orphan*/ stderr;
int test_hash(int);
int /*<<< orphan*/ three(int);
int /*<<< orphan*/ two();
int main(int argc, char **argv) {
  int mode = 0;
  int log_threads = 1;
  if (argc >= 2) {
    mode = atoi(argv[1]);
    if (mode == 3) {
      log_threads = atoi(argv[2]);
    }
  } else {
    return (0);
  }
  switch (mode) {
  case 0:
    fprintf(stderr, "running tests\n");
    int success = (test_hash(1) & test_hash(2) & test_hash(4));
    fprintf(stderr, "test results: %s\n", success ? "PASS" : "FAIL");
    return (!success);
  case 4:
    custom();
    break;
  case 1:
    one();
    break;
  case 2:
    two();
    break;
  case 3:
    three(log_threads);
    break;
  }
  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   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11cd <main+0x5d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jne    11c8 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11d9 <main+0x69>
movl   $0x0,-0x4(%rbp)
jmp    12c2 <main+0x152>
mov    -0x14(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x4,%rax
ja     12bb <main+0x14b>
mov    -0x28(%rbp),%rax
lea    0xe0b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1040 <test_hash@plt>
mov    %eax,-0x30(%rbp)
mov    $0x2,%edi
call   1040 <test_hash@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    $0x4,%edi
call   1040 <test_hash@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%ecx
lea    0xddd(%rip),%rdx
lea    0xdd1(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12c2 <main+0x152>
mov    $0x0,%al
call   1080 <custom@plt>
jmp    12bb <main+0x14b>
mov    $0x0,%al
call   1060 <one@plt>
jmp    12bb <main+0x14b>
mov    $0x0,%al
call   1030 <two@plt>
jmp    12bb <main+0x14b>
mov    -0x18(%rbp),%edi
call   1070 <three@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     1240 <main+0xd0>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
cmp    $0x4,%eax
ja     1240 <main+0xd0>
mov    %eax,%eax
lea    0xe63(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e33(%rip),%r14
mov    (%r14),%edi
lea    0xe5d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1040 <test_hash@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1040 <test_hash@plt>
mov    %eax,%ebx
and    %ebp,%ebx
mov    $0x4,%edi
call   1040 <test_hash@plt>
mov    (%r14),%edi
xor    %ebp,%ebp
test   %eax,%ebx
sete   %bpl
lea    0xe46(%rip),%rax
lea    0xe3a(%rip),%rdx
cmove  %rax,%rdx
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1240 <main+0xd0>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <one@plt>
jmp    1240 <main+0xd0>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <two@plt>
jmp    1240 <main+0xd0>
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%edi
call   1070 <three@plt>
jmp    1240 <main+0xd0>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <custom@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"running tests\0A\00"
@.str.1 = [18 x i8] c"test results: %s\0A\00"
@.str.2 = [5 x i8] c"PASS\00"
@.str.3 = [5 x i8] c"FAIL\00"
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 0, i32* %6
store i32 1, i32* %7
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %7
br label %23
23: ; preds = %18, %11
br label %25
24: ; preds = %2
store i32 0, i32* %3
br label %55
25: ; preds = %23
%26 = load i32, i32* %6
switch i32 %26, label %54 [
i32 0, label %27
i32 4, label %45
i32 1, label %47
i32 2, label %49
i32 3, label %51
]
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @test_hash(i32 1)
%31 = call i32 @test_hash(i32 2)
%32 = and i32 %30, %31
%33 = call i32 @test_hash(i32 4)
%34 = and i32 %32, %33
store i32 %34, i32* %8
%35 = load i32, i32* @stderr
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
%38 = zext i1 %37 to i64
%39 = select i1 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = load i32, i32* %8
%42 = icmp ne i32 %41, 0
%43 = xor i1 %42, true
%44 = zext i1 %43 to i32
store i32 %44, i32* %3
br label %55
45: ; preds = %25
%46 = call i32 (...) @custom()
br label %54
47: ; preds = %25
%48 = call i32 (...) @one()
br label %54
49: ; preds = %25
%50 = call i32 (...) @two()
br label %54
51: ; preds = %25
%52 = load i32, i32* %7
%53 = call i32 @three(i32 %52)
br label %54
54: ; preds = %25, %51, %49, %47, %45
store i32 0, i32* %3
br label %55
55: ; preds = %54, %27, %24
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"running tests\0A\00"
@.str.1 = [18 x i8] c"test results: %s\0A\00"
@.str.2 = [5 x i8] c"PASS\00"
@.str.3 = [5 x i8] c"FAIL\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %32
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
switch i32 %7, label %32 [
i32 3, label %8
i32 0, label %13
i32 4, label %26
i32 1, label %28
i32 2, label %30
]
8: ; preds = %4
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 @three(i32 %11)
br label %32
13: ; preds = %4
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @test_hash(i32 1)
%17 = tail call i32 @test_hash(i32 2)
%18 = and i32 %17, %16
%19 = tail call i32 @test_hash(i32 4)
%20 = and i32 %18, %19
%21 = load i32, i32* @stderr
%22 = icmp eq i32 %20, 0
%23 = select i1 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = zext i1 %22 to i32
br label %32
26: ; preds = %4
%27 = tail call i32 (...) @custom()
br label %32
28: ; preds = %4
%29 = tail call i32 (...) @one()
br label %32
30: ; preds = %4
%31 = tail call i32 (...) @two()
br label %32
32: ; preds = %4, %26, %28, %30, %8, %2, %13
%33 = phi i32 [ %25, %13 ], [ 0, %2 ], [ 0, %8 ], [ 0, %30 ], [ 0, %28 ], [ 0, %26 ], [ 0, %4 ]
ret i32 %33
}