#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 WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int /*<<< orphan*/ printf(char *, int, ...);
void print_status(int w, int status) {
  if (WIFEXITED(status)) {
    if (WEXITSTATUS(status) != 0)
      printf("\n[%d]+ Exit %d\n", w, WEXITSTATUS(status));
    else
      printf("\n[%d]+ Done\n", w);
  } else if (WIFSIGNALED(status)) {
    printf("\n[%d]+ Killed\n", w);
  } else if (WIFSTOPPED(status)) {
    printf("\n[%d]+ Stopped\n", w);
  } else {
    printf("\n[%d]+ Terminated\n", w);
  }
}


x86 assembly (clang, -O0):
<print_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11bd <print_status+0x6d>
mov    -0x8(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
cmp    $0x0,%eax
je     11a7 <print_status+0x57>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b8 <print_status+0x68>
mov    -0x4(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <print_status+0xd8>
mov    -0x8(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11e5 <print_status+0x95>
mov    -0x4(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <print_status+0xd3>
mov    -0x8(%rbp),%edi
call   1050 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     120d <print_status+0xbd>
mov    -0x4(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <print_status+0xce>
mov    -0x4(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <print_status+0xd3>
jmp    1228 <print_status+0xd8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_status>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    %esi,%edi
call   1070 <WIFEXITED@plt>
mov    %ebp,%edi
test   %rax,%rax
je     118d <print_status+0x3d>
call   1060 <WEXITSTATUS@plt>
test   %eax,%eax
je     11a0 <print_status+0x50>
mov    %ebp,%edi
call   1060 <WEXITSTATUS@plt>
lea    0xe84(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
call   1040 <WIFSIGNALED@plt>
test   %rax,%rax
je     11a9 <print_status+0x59>
lea    0xe7f(%rip),%rdi
jmp    11c5 <print_status+0x75>
lea    0xe69(%rip),%rdi
jmp    11c5 <print_status+0x75>
mov    %ebp,%edi
call   1050 <WIFSTOPPED@plt>
test   %rax,%rax
je     11be <print_status+0x6e>
lea    0xe70(%rip),%rdi
jmp    11c5 <print_status+0x75>
lea    0xe77(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"\0A[%d]+ Exit %d\0A\00"
@.str.1 = [13 x i8] c"\0A[%d]+ Done\0A\00"
@.str.2 = [15 x i8] c"\0A[%d]+ Killed\0A\00"
@.str.3 = [16 x i8] c"\0A[%d]+ Stopped\0A\00"
@.str.4 = [19 x i8] c"\0A[%d]+ Terminated\0A\00"
define void @print_status(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = call i64 @WIFEXITED(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %2
%9 = load i32, i32* %4
%10 = call i32 @WEXITSTATUS(i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @WEXITSTATUS(i32 %14)
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15)
br label %20
17: ; preds = %8
%18 = load i32, i32* %3
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %12
br label %40
21: ; preds = %2
%22 = load i32, i32* %4
%23 = call i64 @WIFSIGNALED(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %3
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %39
28: ; preds = %21
%29 = load i32, i32* %4
%30 = call i64 @WIFSTOPPED(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* %3
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %28
%36 = load i32, i32* %3
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38, %25
br label %40
40: ; preds = %39, %20
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0A[%d]+ Exit %d\0A\00"
@.str.1 = [13 x i8] c"\0A[%d]+ Done\0A\00"
@.str.2 = [15 x i8] c"\0A[%d]+ Killed\0A\00"
@.str.3 = [16 x i8] c"\0A[%d]+ Stopped\0A\00"
@.str.4 = [19 x i8] c"\0A[%d]+ Terminated\0A\00"
define void @print_status(i32 %0, i32 %1) {
%3 = tail call i64 @WIFEXITED(i32 %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i32 @WEXITSTATUS(i32 %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @WEXITSTATUS(i32 %1)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %9)
br label %25
11: ; preds = %5
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %25
13: ; preds = %2
%14 = tail call i64 @WIFSIGNALED(i32 %1)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %25
18: ; preds = %13
%19 = tail call i64 @WIFSTOPPED(i32 %1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %25
23: ; preds = %18
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %0)
br label %25
25: ; preds = %16, %23, %21, %8, %11
ret void
}