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

/* Variables and functions */
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
void print_status(pid_t c_pid, int status) {
  if (WIFEXITED(status)) {
    fprintf(stdout, "[%d] Terminated normally\n", c_pid);
  } else if (WIFSIGNALED(status)) {
    fprintf(stdout, "[%d] Terminated by a signal\n", c_pid);
  } else if (WIFSTOPPED(status)) {
    fprintf(stdout, "[%d] Stopped\n", c_pid);
  }
}


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   1060 <WIFEXITED@plt>
cmp    $0x0,%rax
je     117d <print_status+0x3d>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe8d(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e0 <print_status+0xa0>
mov    -0x8(%rbp),%edi
call   1030 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11ac <print_status+0x6c>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11db <print_status+0x9b>
mov    -0x8(%rbp),%edi
call   1050 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     11d6 <print_status+0x96>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11db <print_status+0x9b>
jmp    11e0 <print_status+0xa0>
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   1060 <WIFEXITED@plt>
test   %rax,%rax
je     115c <print_status+0x1c>
lea    0xea6(%rip),%rsi
jmp    1184 <print_status+0x44>
mov    %ebp,%edi
call   1030 <WIFSIGNALED@plt>
test   %rax,%rax
je     1171 <print_status+0x31>
lea    0xeab(%rip),%rsi
jmp    1184 <print_status+0x44>
mov    %ebp,%edi
call   1050 <WIFSTOPPED@plt>
test   %rax,%rax
je     119a <print_status+0x5a>
lea    0xeb3(%rip),%rsi
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [26 x i8] c"[%d] Terminated normally\0A\00"
@.str.1 = [29 x i8] c"[%d] Terminated by a signal\0A\00"
@.str.2 = [14 x i8] c"[%d] Stopped\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 %12
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = load i32, i32* %3
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %30
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i64 @WIFSIGNALED(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stdout
%18 = load i32, i32* %3
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %29
20: ; preds = %12
%21 = load i32, i32* %4
%22 = call i64 @WIFSTOPPED(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* @stdout
%26 = load i32, i32* %3
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %20
br label %29
29: ; preds = %28, %16
br label %30
30: ; preds = %29, %8
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [26 x i8] c"[%d] Terminated normally\0A\00"
@.str.1 = [29 x i8] c"[%d] Terminated by a signal\0A\00"
@.str.2 = [14 x i8] c"[%d] Stopped\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 %5, label %11
5: ; preds = %2
%6 = tail call i64 @WIFSIGNALED(i32 %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i64 @WIFSTOPPED(i32 %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8, %5, %2
%12 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %8 ]
%13 = load i32, i32* @stdout
%14 = tail call i32 @fprintf(i32 %13, i8* %12, i32 %0)
br label %15
15: ; preds = %11, %8
ret void
}