#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 scalar_t__ pid_t;

/* Variables and functions */
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ ksft_test_result_fail(char *, char *);
int /*<<< orphan*/ ksft_test_result_pass(char *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int run_test(int (*test)(void), char *name) {
  int result;
  pid_t childpid;
  int ret;
  fflush(stdout);
  childpid = fork();
  if (childpid) {
    waitpid(childpid, &result, 0);
    if (WIFEXITED(result)) {
      ret = WEXITSTATUS(result);
      if (!ret)
        ksft_test_result_pass("[RUN]\t%s\n", name);
      else
        ksft_test_result_fail("[RUN]\t%s\n", name);
      return ret;
    }
    return 1;
  }
  exit(test());
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1226 <run_test+0xa6>
mov    -0x28(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x1c(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     121a <run_test+0x9a>
mov    -0x1c(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11ff <run_test+0x7f>
mov    -0x18(%rbp),%rsi
lea    0xe0b(%rip),%rdi
call   1030 <ksft_test_result_pass@plt>
jmp    120f <run_test+0x8f>
mov    -0x18(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <ksft_test_result_fail@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1230 <run_test+0xb0>
movl   $0x1,-0x4(%rbp)
jmp    1230 <run_test+0xb0>
call   *-0x10(%rbp)
mov    %eax,%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
je     1201 <run_test+0x81>
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    0x4(%rsp),%edi
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     11e0 <run_test+0x60>
mov    0x4(%rsp),%edi
call   1060 <WEXITSTATUS@plt>
test   %eax,%eax
je     11e7 <run_test+0x67>
mov    %eax,%ebp
lea    0xe2a(%rip),%rdi
mov    %rbx,%rsi
call   1040 <ksft_test_result_fail@plt>
jmp    11f8 <run_test+0x78>
mov    $0x1,%ebp
jmp    11f8 <run_test+0x78>
lea    0xe12(%rip),%rdi
mov    %rbx,%rsi
call   1030 <ksft_test_result_pass@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
call   *%rbp
mov    %eax,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [10 x i8] c"[RUN]\09%s\0A\00"
define i32 @run_test(i32 ()* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32 ()*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i32 ()* %0, i32 ()** %4
store i8* %1, i8** %5
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = call i64 (...) @fork()
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %2
%15 = load i64, i64* %7
%16 = call i32 @waitpid(i64 %15, i32* %6, i32 0)
%17 = load i32, i32* %6
%18 = call i64 @WIFEXITED(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %14
%21 = load i32, i32* %6
%22 = call i32 @WEXITSTATUS(i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load i8*, i8** %5
%27 = call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %31
28: ; preds = %20
%29 = load i8*, i8** %5
%30 = call i32 @ksft_test_result_fail(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %25
%32 = load i32, i32* %8
store i32 %32, i32* %3
br label %38
33: ; preds = %14
store i32 1, i32* %3
br label %38
34: ; preds = %2
%35 = load i32 ()*, i32 ()** %4
%36 = call i32 %35()
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %33, %31
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [10 x i8] c"[RUN]\09%s\0A\00"
define i32 @run_test(i32 ()* nocapture %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @stdout
%6 = tail call i32 @fflush(i32 %5)
%7 = tail call i64 (...) @fork()
%8 = icmp eq i64 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %2
%10 = call i32 @waitpid(i64 %7, i32* %3, i32 0)
%11 = load i32, i32* %3
%12 = call i64 @WIFEXITED(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = call i32 @WEXITSTATUS(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %25
20: ; preds = %14
%21 = call i32 @ksft_test_result_fail(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %25
22: ; preds = %2
%23 = tail call i32 %0()
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %9, %18, %20
%26 = phi i32 [ %16, %20 ], [ 0, %18 ], [ 1, %9 ]
ret i32 %26
}