#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 */
typedef int /*<<< orphan*/ tests;

/* Variables and functions */
int call_test(char const *const);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc < 2) {
    char const *const tests[] = {
        "test_bitselect",
        "test_fabs",
        "test_hadd",
        "test_rotate",
    };
    int const ntests = sizeof(tests) / sizeof(*tests);
    for (int i = 0; i < ntests; ++i) {
      printf("Running test #%d %s...\n", i, tests[i]);
      int ierr;
      ierr = call_test(tests[i]);
      if (ierr) {
        printf("FAIL\n");
        return 1;
      }
    }
  } else {
    printf("Running test %s...\n", argv[1]);
    int ierr;
    ierr = call_test(argv[1]);
    if (ierr) {
      printf("FAIL\n");
      return 1;
    }
  }
  printf("OK\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11eb <main+0xcb>
mov    0x2cb9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb0(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x4,-0x38(%rbp)
jge    11e6 <main+0xc6>
mov    -0x38(%rbp),%esi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
call   1040 <call_test@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     11d3 <main+0xb3>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124f <main+0x12f>
jmp    11d8 <main+0xb8>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    117a <main+0x5a>
jmp    123a <main+0x11a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <call_test@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     1235 <main+0x115>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124f <main+0x12f>
jmp    123a <main+0x11a>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     11f9 <main+0xc9>
lea    0xeeb(%rip),%rdi
lea    0xeb5(%rip),%rbx
xor    %esi,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <call_test@plt>
mov    $0x1,%ebp
lea    0xef3(%rip),%rbx
test   %eax,%eax
jne    1232 <main+0x102>
lea    0xeb5(%rip),%rdi
lea    0xe8e(%rip),%r14
mov    $0x1,%ebp
mov    $0x1,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <call_test@plt>
test   %eax,%eax
jne    1232 <main+0x102>
lea    0xe83(%rip),%rdi
lea    0xe66(%rip),%r14
mov    $0x2,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <call_test@plt>
test   %eax,%eax
jne    1232 <main+0x102>
lea    0xe5a(%rip),%rdi
lea    0xe47(%rip),%r14
mov    $0x3,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <call_test@plt>
test   %eax,%eax
jne    1232 <main+0x102>
jmp    1229 <main+0xf9>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
call   1050 <call_test@plt>
test   %eax,%eax
je     1229 <main+0xf9>
mov    $0x1,%ebp
lea    0xe37(%rip),%rbx
jmp    1232 <main+0x102>
xor    %ebp,%ebp
lea    0xe29(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"test_bitselect\00"
@.str.1 = [10 x i8] c"test_fabs\00"
@.str.2 = [10 x i8] c"test_hadd\00"
@.str.3 = [12 x i8] c"test_rotate\00"
@__const.main.tests = [4 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [24 x i8] c"Running test #%d %s...\0A\00"
@.str.5 = [6 x i8] c"FAIL\0A\00"
@.str.6 = [20 x i8] c"Running test %s...\0A\00"
@.str.7 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %39
13: ; preds = %2
%14 = bitcast [4 x i8*]* %6 to i8*
store i32 4, i32* %7
store i32 0, i32* %8
br label %15
15: ; preds = %35, %13
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %8
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %19, i8* %23)
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @call_test(i8* %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %55
34: ; preds = %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %15
38: ; preds = %15
br label %53
39: ; preds = %2
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 @call_test(i8* %46)
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %39
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %55
52: ; preds = %39
br label %53
53: ; preds = %52, %38
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %55
55: ; preds = %53, %50, %32
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [15 x i8] c"test_bitselect\00"
@.str.1 = [10 x i8] c"test_fabs\00"
@.str.2 = [10 x i8] c"test_hadd\00"
@.str.3 = [12 x i8] c"test_rotate\00"
@.str.4 = [24 x i8] c"Running test #%d %s...\0A\00"
@.str.6 = [20 x i8] c"Running test %s...\0A\00"
@str = [3 x i8] c"OK\00"
@str.9 = [5 x i8] c"FAIL\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @call_test(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %28
8: ; preds = %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @call_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @call_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 @call_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %27, label %28
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %21
%25 = tail call i32 @call_test(i8* %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %16, %20
br label %28
28: ; preds = %20, %4, %8, %12, %16, %27
%29 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), %27 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0), %16 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0), %12 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0), %20 ]
%30 = phi i32 [ 0, %27 ], [ 1, %16 ], [ 1, %12 ], [ 1, %8 ], [ 1, %4 ], [ 1, %20 ]
%31 = tail call i32 @puts(i8* dereferenceable(1) %29)
ret i32 %30
}