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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
int WTERMSIG(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ memcpy(char *, char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ panic(char *);
int /*<<< orphan*/ printf(char *, char const *, int);
int /*<<< orphan*/ puts(char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *strtok(char *, char *);
scalar_t__ waitpid(int, int *, int /*<<< orphan*/);
int write(int, char *, int);
void launch_tests(void) {
  char cmdline[4096], *success_dev;
  int status, fd;
  pid_t pid;
  puts("\x1b[32m\x1b[1m"
       "[+] Launching tests..."
       "\x1b[0m");
  pid = fork();
  if (pid == -1)
    panic("fork");
  else if (pid == 0) {
    execl("/init.sh", "init", NULL);
    panic("exec");
  }
  if (waitpid(pid, &status, 0) < 0)
    panic("waitpid");
  if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
    puts("\x1b[32m\x1b[1m"
         "[+] Tests successful! :-)"
         "\x1b[0m");
    fd = open("/proc/cmdline", O_RDONLY);
    if (fd < 0)
      panic("open(/proc/cmdline)");
    if (read(fd, cmdline, sizeof(cmdline) - 1) <= 0)
      panic("read(/proc/cmdline)");
    cmdline[sizeof(cmdline) - 1] = '\0';
    for (success_dev = strtok(cmdline, " \n"); success_dev;
         success_dev = strtok(NULL, " \n")) {
      if (strncmp(success_dev, "wg.success=", 11))
        continue;
      memcpy(success_dev + 11 - 5, "/dev/", 5);
      success_dev += 11 - 5;
      break;
    }
    if (!success_dev || !strlen(success_dev))
      panic("Unable to find success device");
    fd = open(success_dev, O_WRONLY);
    if (fd < 0)
      panic("open(success_dev)");
    if (write(fd, "success\n", 8) != 8)
      panic("write(success_dev)");
    close(fd);
  } else {
    const char *why = "unknown cause";
    int what = -1;
    if (WIFEXITED(status)) {
      why = "exit code";
      what = WEXITSTATUS(status);
    } else if (WIFSIGNALED(status)) {
      why = "signal";
      what = WTERMSIG(status);
    }
    printf("\x1b[31m\x1b[1m[-] Tests failed with %s %d! \u2639\x1b[0m\n", why,
           what);
  }
}


x86 assembly (clang, -O0):
<launch_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
lea    0xdce(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1140 <fork@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0xffffffff,-0x1014(%rbp)
jne    1262 <launch_tests+0x42>
lea    0xdcc(%rip),%rdi
call   1080 <panic@plt>
jmp    1297 <launch_tests+0x77>
cmpl   $0x0,-0x1014(%rbp)
jne    1292 <launch_tests+0x72>
lea    0xdb3(%rip),%rdi
lea    0xdb5(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1130 <execl@plt>
lea    0xdaa(%rip),%rdi
call   1080 <panic@plt>
jmp    1297 <launch_tests+0x77>
mov    -0x1014(%rbp),%edi
lea    -0x100c(%rbp),%rsi
xor    %edx,%edx
call   10f0 <waitpid@plt>
cmp    $0x0,%rax
jge    12c1 <launch_tests+0xa1>
lea    0xd80(%rip),%rdi
call   1080 <panic@plt>
mov    -0x100c(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%rax
je     149c <launch_tests+0x27c>
mov    -0x100c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
cmp    $0x0,%eax
jne    149c <launch_tests+0x27c>
lea    0xd53(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
lea    0xd65(%rip),%rdi
call   1100 <open@plt>
mov    %eax,-0x1010(%rbp)
cmpl   $0x0,-0x1010(%rbp)
jge    132a <launch_tests+0x10a>
lea    0xd54(%rip),%rdi
call   1080 <panic@plt>
mov    -0x1010(%rbp),%edi
lea    -0x1000(%rbp),%rsi
mov    $0xfff,%edx
call   10a0 <read@plt>
cmp    $0x0,%rax
jg     1357 <launch_tests+0x137>
lea    0xd3b(%rip),%rdi
call   1080 <panic@plt>
movb   $0x0,-0x1(%rbp)
lea    -0x1000(%rbp),%rdi
lea    0xd38(%rip),%rsi
call   1110 <strtok@plt>
mov    %rax,-0x1008(%rbp)
cmpq   $0x0,-0x1008(%rbp)
je     13fd <launch_tests+0x1dd>
mov    -0x1008(%rbp),%rdi
lea    0xd13(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     13aa <launch_tests+0x18a>
jmp    13e1 <launch_tests+0x1c1>
mov    -0x1008(%rbp),%rdi
add    $0xb,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xcf0(%rip),%rsi
mov    $0x5,%edx
call   10c0 <memcpy@plt>
mov    -0x1008(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x1008(%rbp)
jmp    13fd <launch_tests+0x1dd>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcb5(%rip),%rsi
call   1110 <strtok@plt>
mov    %rax,-0x1008(%rbp)
jmp    1375 <launch_tests+0x155>
cmpq   $0x0,-0x1008(%rbp)
je     1420 <launch_tests+0x200>
mov    -0x1008(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%eax
jne    142c <launch_tests+0x20c>
lea    0xc8f(%rip),%rdi
call   1080 <panic@plt>
mov    -0x1008(%rbp),%rdi
mov    0x2b96(%rip),%rax
mov    (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x1010(%rbp)
cmpl   $0x0,-0x1010(%rbp)
jge    1460 <launch_tests+0x240>
lea    0xc79(%rip),%rdi
call   1080 <panic@plt>
mov    -0x1010(%rbp),%edi
lea    0xc79(%rip),%rsi
mov    $0x8,%edx
call   1050 <write@plt>
cmp    $0x8,%eax
je     148c <launch_tests+0x26c>
lea    0xc68(%rip),%rdi
call   1080 <panic@plt>
mov    -0x1010(%rbp),%edi
call   1090 <close@plt>
jmp    153f <launch_tests+0x31f>
lea    0xc5f(%rip),%rax
mov    %rax,-0x1020(%rbp)
movl   $0xffffffff,-0x1024(%rbp)
ff ff ff
mov    -0x100c(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%rax
je     14ed <launch_tests+0x2cd>
lea    0xc40(%rip),%rax
mov    %rax,-0x1020(%rbp)
mov    -0x100c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    %eax,-0x1024(%rbp)
jmp    1526 <launch_tests+0x306>
mov    -0x100c(%rbp),%edi
call   10b0 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     1521 <launch_tests+0x301>
lea    0xc11(%rip),%rax
mov    %rax,-0x1020(%rbp)
mov    -0x100c(%rbp),%edi
call   10d0 <WTERMSIG@plt>
mov    %eax,-0x1024(%rbp)
jmp    1526 <launch_tests+0x306>
mov    -0x1020(%rbp),%rsi
mov    -0x1024(%rbp),%edx
lea    0xbe7(%rip),%rdi
call   1070 <printf@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<launch_tests>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1140 <fork@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     126a <launch_tests+0x4a>
test   %ebx,%ebx
jne    1276 <launch_tests+0x56>
lea    0xdd6(%rip),%rdi
lea    0xdd8(%rip),%rsi
xor    %edx,%edx
call   1130 <execl@plt>
lea    0xdcf(%rip),%rdi
jmp    1271 <launch_tests+0x51>
lea    0xdb3(%rip),%rdi
call   1080 <panic@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   10f0 <waitpid@plt>
test   %rax,%rax
jns    1295 <launch_tests+0x75>
lea    0xdac(%rip),%rdi
call   1080 <panic@plt>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
test   %rax,%rax
je     12b0 <launch_tests+0x90>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
test   %eax,%eax
je     12fa <launch_tests+0xda>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
mov    0xc(%rsp),%edi
test   %rax,%rax
je     12d5 <launch_tests+0xb5>
call   10e0 <WEXITSTATUS@plt>
mov    %eax,%edx
lea    0xe40(%rip),%rsi
jmp    13c5 <launch_tests+0x1a5>
call   10b0 <WIFSIGNALED@plt>
test   %rax,%rax
je     13b9 <launch_tests+0x199>
mov    0xc(%rsp),%edi
call   10d0 <WTERMSIG@plt>
mov    %eax,%edx
lea    0xe25(%rip),%rsi
jmp    13c5 <launch_tests+0x1a5>
lea    0xd43(%rip),%rdi
call   1040 <puts@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%esi
lea    0xd55(%rip),%rdi
call   1100 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    132d <launch_tests+0x10d>
lea    0xd51(%rip),%rdi
call   1080 <panic@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xfff,%edx
call   10a0 <read@plt>
test   %rax,%rax
jg     134f <launch_tests+0x12f>
lea    0xd43(%rip),%rdi
call   1080 <panic@plt>
movb   $0x0,0x100f(%rsp)
lea    0xd43(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1110 <strtok@plt>
test   %rax,%rax
je     13d6 <launch_tests+0x1b6>
mov    %rax,%rbx
lea    0xd2d(%rip),%r15
lea    0xd23(%rip),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13db <launch_tests+0x1bb>
xor    %edi,%edi
mov    %r12,%rsi
call   1110 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1390 <launch_tests+0x170>
jmp    1402 <launch_tests+0x1e2>
mov    $0xffffffff,%edx
lea    0xd3d(%rip),%rsi
lea    0xd55(%rip),%rdi
call   1070 <printf@plt>
jmp    145c <launch_tests+0x23c>
xor    %r14d,%r14d
jmp    1402 <launch_tests+0x1e2>
add    $0x6,%rbx
lea    0xcca(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   10c0 <memcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbx,%r14
test   %eax,%eax
jne    140e <launch_tests+0x1ee>
lea    0xcad(%rip),%rdi
call   1080 <panic@plt>
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1100 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1431 <launch_tests+0x211>
lea    0xca8(%rip),%rdi
call   1080 <panic@plt>
lea    0xcae(%rip),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1050 <write@plt>
cmp    $0x8,%eax
je     1455 <launch_tests+0x235>
lea    0xc9f(%rip),%rdi
call   1080 <panic@plt>
mov    %ebx,%edi
call   1090 <close@plt>
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\1B[32m\1B[1m[+] Launching tests...\1B[0m\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [9 x i8] c"/init.sh\00"
@.str.3 = [5 x i8] c"init\00"
@.str.4 = [5 x i8] c"exec\00"
@.str.5 = [8 x i8] c"waitpid\00"
@.str.6 = [39 x i8] c"\1B[32m\1B[1m[+] Tests successful! :-)\1B[0m\00"
@.str.7 = [14 x i8] c"/proc/cmdline\00"
@O_RDONLY = global i32 0
@.str.8 = [20 x i8] c"open(/proc/cmdline)\00"
@.str.9 = [20 x i8] c"read(/proc/cmdline)\00"
@.str.10 = [3 x i8] c" \0A\00"
@.str.11 = [12 x i8] c"wg.success=\00"
@.str.12 = [6 x i8] c"/dev/\00"
@.str.13 = [30 x i8] c"Unable to find success device\00"
@O_WRONLY = global i32 0
@.str.14 = [18 x i8] c"open(success_dev)\00"
@.str.15 = [9 x i8] c"success\0A\00"
@.str.16 = [19 x i8] c"write(success_dev)\00"
@.str.17 = [14 x i8] c"unknown cause\00"
@.str.18 = [10 x i8] c"exit code\00"
@.str.19 = [7 x i8] c"signal\00"
@.str.20 = [47 x i8] c"\1B[31m\1B[1m[-] Tests failed with %s %d! \E2\98\B9\1B[0m\0A\00"
define void @launch_tests() {
%1 = alloca [4096 x i8]
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @fork()
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @panic(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %21
14: ; preds = %0
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* null)
%19 = call i32 @panic(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20, %12
%22 = load i32, i32* %5
%23 = call i64 @waitpid(i32 %22, i32* %3, i32 0)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @panic(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %3
%29 = call i64 @WIFEXITED(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %97
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i32 @WEXITSTATUS(i32 %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %97
35: ; preds = %31
%36 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%37 = load i32, i32* @O_RDONLY
%38 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %37)
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %43
43: ; preds = %41, %35
%44 = load i32, i32* %4
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%46 = call i64 @read(i32 %44, i8* %45, i32 4095)
%47 = icmp sle i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 @panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %50
50: ; preds = %48, %43
%51 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 4095
store i8 0, i8* %51
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%53 = call i8* @strtok(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i8* %53, i8** %2
br label %54
54: ; preds = %69, %50
%55 = load i8*, i8** %2
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %71
57: ; preds = %54
%58 = load i8*, i8** %2
%59 = call i64 @strncmp(i8* %58, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 11)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %57
br label %69
62: ; preds = %57
%63 = load i8*, i8** %2
%64 = getelementptr inbounds i8, i8* %63, i64 11
%65 = getelementptr inbounds i8, i8* %64, i64 -5
%66 = call i32 @memcpy(i8* %65, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 5)
%67 = load i8*, i8** %2
%68 = getelementptr inbounds i8, i8* %67, i64 6
store i8* %68, i8** %2
br label %71
69: ; preds = %61
%70 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i8* %70, i8** %2
br label %54
71: ; preds = %62, %54
%72 = load i8*, i8** %2
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = load i8*, i8** %2
%76 = call i32 @strlen(i8* %75)
%77 = icmp ne i32 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %74, %71
%79 = call i32 @panic(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
br label %80
80: ; preds = %78, %74
%81 = load i8*, i8** %2
%82 = load i32, i32* @O_WRONLY
%83 = call i32 @open(i8* %81, i32 %82)
store i32 %83, i32* %4
%84 = load i32, i32* %4
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %80
%87 = call i32 @panic(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
br label %88
88: ; preds = %86, %80
%89 = load i32, i32* %4
%90 = call i32 @write(i32 %89, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i32 8)
%91 = icmp ne i32 %90, 8
br i1 %91, label %92, label %94
92: ; preds = %88
%93 = call i32 @panic(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0))
br label %94
94: ; preds = %92, %88
%95 = load i32, i32* %4
%96 = call i32 @close(i32 %95)
br label %116
97: ; preds = %31, %27
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i8** %6
store i32 -1, i32* %7
%98 = load i32, i32* %3
%99 = call i64 @WIFEXITED(i32 %98)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %97
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i8** %6
%102 = load i32, i32* %3
%103 = call i32 @WEXITSTATUS(i32 %102)
store i32 %103, i32* %7
br label %112
104: ; preds = %97
%105 = load i32, i32* %3
%106 = call i64 @WIFSIGNALED(i32 %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %104
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8** %6
%109 = load i32, i32* %3
%110 = call i32 @WTERMSIG(i32 %109)
store i32 %110, i32* %7
br label %111
111: ; preds = %108, %104
br label %112
112: ; preds = %111, %101
%113 = load i8*, i8** %6
%114 = load i32, i32* %7
%115 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.20, i64 0, i64 0), i8* %113, i32 %114)
br label %116
116: ; preds = %112, %94
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"\1B[32m\1B[1m[+] Launching tests...\1B[0m\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [9 x i8] c"/init.sh\00"
@.str.3 = [5 x i8] c"init\00"
@.str.4 = [5 x i8] c"exec\00"
@.str.5 = [8 x i8] c"waitpid\00"
@.str.6 = [39 x i8] c"\1B[32m\1B[1m[+] Tests successful! :-)\1B[0m\00"
@.str.7 = [14 x i8] c"/proc/cmdline\00"
@O_RDONLY = global i32 0
@.str.8 = [20 x i8] c"open(/proc/cmdline)\00"
@.str.9 = [20 x i8] c"read(/proc/cmdline)\00"
@.str.10 = [3 x i8] c" \0A\00"
@.str.11 = [12 x i8] c"wg.success=\00"
@.str.12 = [6 x i8] c"/dev/\00"
@.str.13 = [30 x i8] c"Unable to find success device\00"
@O_WRONLY = global i32 0
@.str.14 = [18 x i8] c"open(success_dev)\00"
@.str.15 = [9 x i8] c"success\0A\00"
@.str.16 = [19 x i8] c"write(success_dev)\00"
@.str.17 = [14 x i8] c"unknown cause\00"
@.str.18 = [10 x i8] c"exit code\00"
@.str.19 = [7 x i8] c"signal\00"
@.str.20 = [47 x i8] c"\1B[31m\1B[1m[-] Tests failed with %s %d! \E2\98\B9\1B[0m\0A\00"
define void @launch_tests() {
%1 = alloca [4096 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @fork()
switch i32 %6, label %12 [
i32 -1, label %9
i32 0, label %7
]
7: ; preds = %0
%8 = tail call i32 @execl(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %9
9: ; preds = %0, %7
%10 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %0 ]
%11 = tail call i32 @panic(i8* %10)
br label %12
12: ; preds = %9, %0
%13 = call i64 @waitpid(i32 %6, i32* %2, i32 0)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @panic(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %2
%19 = call i64 @WIFEXITED(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %70, label %21
21: ; preds = %17
%22 = load i32, i32* %2
%23 = call i32 @WEXITSTATUS(i32 %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %70
25: ; preds = %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 @panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %32
32: ; preds = %30, %25
%33 = call i64 @read(i32 %28, i8* %3, i32 4095)
%34 = icmp slt i64 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 4095
store i8 0, i8* %38
%39 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%40 = icmp eq i8* %39, null
br i1 %40, label %53, label %41
41: ; preds = %37, %45
%42 = phi i8* [ %46, %45 ], [ %39, %37 ]
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 11)
%44 = icmp eq i64 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %41
%46 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%47 = icmp eq i8* %46, null
br i1 %47, label %53, label %41
48: ; preds = %41
%49 = getelementptr inbounds i8, i8* %42, i64 6
%50 = call i32 @memcpy(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 5)
%51 = call i32 @strlen(i8* %49)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %45, %37, %48
%54 = phi i8* [ %49, %48 ], [ null, %37 ], [ null, %45 ]
%55 = call i32 @panic(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
br label %56
56: ; preds = %53, %48
%57 = phi i8* [ %54, %53 ], [ %49, %48 ]
%58 = load i32, i32* @O_WRONLY
%59 = call i32 @open(i8* %57, i32 %58)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @panic(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = call i32 @write(i32 %59, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i32 8)
%65 = icmp eq i32 %64, 8
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @panic(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = call i32 @close(i32 %59)
br label %87
70: ; preds = %21, %17
%71 = load i32, i32* %2
%72 = call i64 @WIFEXITED(i32 %71)
%73 = icmp eq i64 %72, 0
%74 = load i32, i32* %2
br i1 %73, label %77, label %75
75: ; preds = %70
%76 = call i32 @WEXITSTATUS(i32 %74)
br label %83
77: ; preds = %70
%78 = call i64 @WIFSIGNALED(i32 %74)
%79 = icmp eq i64 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %77
%81 = load i32, i32* %2
%82 = call i32 @WTERMSIG(i32 %81)
br label %83
83: ; preds = %77, %80, %75
%84 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), %75 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), %80 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), %77 ]
%85 = phi i32 [ %76, %75 ], [ %82, %80 ], [ -1, %77 ]
%86 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.20, i64 0, i64 0), i8* %84, i32 %85)
br label %87
87: ; preds = %83, %68
ret void
}