#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 */
scalar_t__ WCOREDUMP(int);
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WSTOPSIG(int);
int WTERMSIG(int);
int /*<<< orphan*/ printf(char *, int, ...);
void pr_exit(int status) {
  if (WIFEXITED(status)) {
    printf("normal termination, exit status = %d\n", WEXITSTATUS(status));
  } else if (WIFSIGNALED(status)) {
    printf("abnormal termination, signal number = %d%s\n", WTERMSIG(status),
           WCOREDUMP(status) ? " (core file generated)" : "");
  } else if (WIFSTOPPED(status)) {
    printf("child stopped, signal number = %d\n", WSTOPSIG(status));
  }
}


x86 assembly (clang, -O0):
<pr_exit>:
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 <pr_exit+0x3a>
mov    -0x4(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1242 <pr_exit+0xc2>
mov    -0x4(%rbp),%edi
call   1050 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     120e <pr_exit+0x8e>
mov    -0x4(%rbp),%edi
call   1070 <WTERMSIG@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <WCOREDUMP@plt>
mov    -0x8(%rbp),%esi
mov    %rax,%rcx
lea    0xe9f(%rip),%rdx
lea    0xe5f(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <pr_exit+0xbd>
mov    -0x4(%rbp),%edi
call   1060 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     1238 <pr_exit+0xb8>
mov    -0x4(%rbp),%edi
call   10a0 <WSTOPSIG@plt>
mov    %eax,%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <pr_exit+0xbd>
jmp    1242 <pr_exit+0xc2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_exit>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1090 <WIFEXITED@plt>
test   %rax,%rax
je     11ac <pr_exit+0x2c>
mov    %ebx,%edi
call   1080 <WEXITSTATUS@plt>
lea    0xe63(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
mov    %ebx,%edi
call   1050 <WIFSIGNALED@plt>
mov    %ebx,%edi
test   %rax,%rax
je     11f3 <pr_exit+0x73>
call   1070 <WTERMSIG@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <WCOREDUMP@plt>
test   %rax,%rax
lea    0xeb9(%rip),%rax
lea    0xe79(%rip),%rdx
cmove  %rax,%rdx
lea    0xe42(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
call   1060 <WIFSTOPPED@plt>
test   %rax,%rax
je     120d <pr_exit+0x8d>
mov    %ebx,%edi
call   10a0 <WSTOPSIG@plt>
lea    0xe5e(%rip),%rdi
jmp    119d <pr_exit+0x1d>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"normal termination, exit status = %d\0A\00"
@.str.1 = [44 x i8] c"abnormal termination, signal number = %d%s\0A\00"
@.str.2 = [23 x i8] c" (core file generated)\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [35 x i8] c"child stopped, signal number = %d\0A\00"
define void @pr_exit(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*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %33
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 %23
14: ; preds = %10
%15 = load i32, i32* %2
%16 = call i32 @WTERMSIG(i32 %15)
%17 = load i32, i32* %2
%18 = call i64 @WCOREDUMP(i32 %17)
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %21)
br label %32
23: ; preds = %10
%24 = load i32, i32* %2
%25 = call i64 @WIFSTOPPED(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* %2
%29 = call i32 @WSTOPSIG(i32 %28)
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %27, %23
br label %32
32: ; preds = %31, %14
br label %33
33: ; preds = %32, %6
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"normal termination, exit status = %d\0A\00"
@.str.1 = [44 x i8] c"abnormal termination, signal number = %d%s\0A\00"
@.str.2 = [23 x i8] c" (core file generated)\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [35 x i8] c"child stopped, signal number = %d\0A\00"
define void @pr_exit(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*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %22
7: ; preds = %1
%8 = tail call i64 @WIFSIGNALED(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = tail call i32 @WTERMSIG(i32 %0)
%12 = tail call i64 @WCOREDUMP(i32 %0)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0)
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %11, i8* %14)
br label %22
16: ; preds = %7
%17 = tail call i64 @WIFSTOPPED(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @WSTOPSIG(i32 %0)
%21 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %10, %19, %16, %4
ret void
}