#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__ WIFCONTINUED(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WSTOPSIG(int);
int WTERMSIG(int);
int /*<<< orphan*/ printf(char *, ...);
void print_exit_status(int status) {
  if (WIFEXITED(status)) {
    printf("exited, status=%d\n", WEXITSTATUS(status));
  } else if (WIFSIGNALED(status)) {
    printf("killed by signal %d\n", WTERMSIG(status));
  } else if (WIFSTOPPED(status)) {
    printf("stopped by signal %d\n", WSTOPSIG(status));
  } else if (WIFCONTINUED(status)) {
    printf("continued\n");
  }
}


x86 assembly (clang, -O0):
<print_exit_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1090 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11ba <print_exit_status+0x3a>
mov    -0x4(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <print_exit_status+0xc7>
mov    -0x4(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11e9 <print_exit_status+0x69>
mov    -0x4(%rbp),%edi
call   1070 <WTERMSIG@plt>
mov    %eax,%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1242 <print_exit_status+0xc2>
mov    -0x4(%rbp),%edi
call   1060 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     1218 <print_exit_status+0x98>
mov    -0x4(%rbp),%edi
call   10a0 <WSTOPSIG@plt>
mov    %eax,%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <print_exit_status+0xbd>
mov    -0x4(%rbp),%edi
call   1050 <WIFCONTINUED@plt>
cmp    $0x0,%rax
je     1238 <print_exit_status+0xb8>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <print_exit_status+0xbd>
jmp    1242 <print_exit_status+0xc2>
jmp    1247 <print_exit_status+0xc7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_exit_status>:
push   %rbx
mov    %edi,%ebx
call   10a0 <WIFEXITED@plt>
test   %rax,%rax
je     11ad <print_exit_status+0x1d>
mov    %ebx,%edi
call   1090 <WEXITSTATUS@plt>
lea    0xe55(%rip),%rdi
jmp    11e3 <print_exit_status+0x53>
mov    %ebx,%edi
call   1050 <WIFSIGNALED@plt>
test   %rax,%rax
je     11c9 <print_exit_status+0x39>
mov    %ebx,%edi
call   1080 <WTERMSIG@plt>
lea    0xe4c(%rip),%rdi
jmp    11e3 <print_exit_status+0x53>
mov    %ebx,%edi
call   1070 <WIFSTOPPED@plt>
mov    %ebx,%edi
test   %rax,%rax
je     11ed <print_exit_status+0x5d>
call   10b0 <WSTOPSIG@plt>
lea    0xe45(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
call   1060 <WIFCONTINUED@plt>
test   %rax,%rax
je     1204 <print_exit_status+0x74>
lea    0xe40(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"exited, status=%d\0A\00"
@.str.1 = [21 x i8] c"killed by signal %d\0A\00"
@.str.2 = [22 x i8] c"stopped by signal %d\0A\00"
@.str.3 = [11 x i8] c"continued\0A\00"
define void @print_exit_status(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i64 @WIFEXITED(i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @WEXITSTATUS(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %35
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i64 @WIFSIGNALED(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %2
%16 = call i32 @WTERMSIG(i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %34
18: ; preds = %10
%19 = load i32, i32* %2
%20 = call i64 @WIFSTOPPED(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* %2
%24 = call i32 @WSTOPSIG(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %33
26: ; preds = %18
%27 = load i32, i32* %2
%28 = call i64 @WIFCONTINUED(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
br label %33
33: ; preds = %32, %22
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34, %6
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"exited, status=%d\0A\00"
@.str.1 = [21 x i8] c"killed by signal %d\0A\00"
@.str.2 = [22 x i8] c"stopped by signal %d\0A\00"
@str = [10 x i8] c"continued\00"
define void @print_exit_status(i32 %0) {
%2 = tail call i64 @WIFEXITED(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @WEXITSTATUS(i32 %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %24
7: ; preds = %1
%8 = tail call i64 @WIFSIGNALED(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @WTERMSIG(i32 %0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %24
13: ; preds = %7
%14 = tail call i64 @WIFSTOPPED(i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @WSTOPSIG(i32 %0)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %13
%20 = tail call i64 @WIFCONTINUED(i32 %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %10, %19, %22, %16, %4
ret void
}