void pr_exit(int status) {
  if (WIFEXITED(status)) {
    printf("Child terminated normally, exit status = %d\n",
           WEXITSTATUS(status));
  } else if (WIFSIGNALED(status)) {
    printf("Terminated with %s", strsignal(WTERMSIG(status)));
    printf("\n");
  } else if (WIFSTOPPED(status)) {
    printf("Stopped with %s\n", strsignal(WSTOPSIG(status)));
  }
}


x86 assembly (clang, -O0):
<pr_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <WIFEXITED@plt>
cmp    $0x0,%eax
je     11bd <pr_exit+0x3d>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1080 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1246 <pr_exit+0xc6>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%eax
je     1206 <pr_exit+0x86>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <WTERMSIG@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1070 <strsignal@plt>
mov    %eax,%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <pr_exit+0xc1>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <WIFSTOPPED@plt>
cmp    $0x0,%eax
je     123c <pr_exit+0xbc>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   10a0 <WSTOPSIG@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1070 <strsignal@plt>
mov    %eax,%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <pr_exit+0xc1>
jmp    1246 <pr_exit+0xc6>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_exit>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   10a0 <WIFEXITED@plt>
test   %eax,%eax
je     11b8 <pr_exit+0x28>
mov    %ebx,%edi
xor    %eax,%eax
call   1090 <WEXITSTATUS@plt>
lea    0xe52(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <WIFSIGNALED@plt>
test   %eax,%eax
je     11f2 <pr_exit+0x62>
mov    %ebx,%edi
xor    %eax,%eax
call   1070 <WTERMSIG@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1080 <strsignal@plt>
lea    0xe4f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <WIFSTOPPED@plt>
test   %eax,%eax
je     121a <pr_exit+0x8a>
mov    %ebx,%edi
xor    %eax,%eax
call   10b0 <WSTOPSIG@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1080 <strsignal@plt>
lea    0xe28(%rip),%rdi
jmp    11ae <pr_exit+0x1e>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Child terminated normally, exit status = %d\0A\00"
@.str.1 = [19 x i8] c"Terminated with %s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [17 x i8] c"Stopped with %s\0A\00"
define void @pr_exit(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 (i32, ...) bitcast (i32 (...)* @WIFEXITED to i32 (i32, ...)*)(i32 %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 (i32, ...) bitcast (i32 (...)* @WEXITSTATUS to i32 (i32, ...)*)(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %31
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i32 (i32, ...) bitcast (i32 (...)* @WIFSIGNALED to i32 (i32, ...)*)(i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %2
%16 = call i32 (i32, ...) bitcast (i32 (...)* @WTERMSIG to i32 (i32, ...)*)(i32 %15)
%17 = call i32 (i32, ...) bitcast (i32 (...)* @strsignal to i32 (i32, ...)*)(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
20: ; preds = %10
%21 = load i32, i32* %2
%22 = call i32 (i32, ...) bitcast (i32 (...)* @WIFSTOPPED to i32 (i32, ...)*)(i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* %2
%26 = call i32 (i32, ...) bitcast (i32 (...)* @WSTOPSIG to i32 (i32, ...)*)(i32 %25)
%27 = call i32 (i32, ...) bitcast (i32 (...)* @strsignal to i32 (i32, ...)*)(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %24, %20
br label %30
30: ; preds = %29, %14
br label %31
31: ; preds = %30, %6
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"Child terminated normally, exit status = %d\0A\00"
@.str.1 = [19 x i8] c"Terminated with %s\00"
@.str.3 = [17 x i8] c"Stopped with %s\0A\00"
define void @pr_exit(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @WIFEXITED to i32 (i32, ...)*)(i32 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @WEXITSTATUS to i32 (i32, ...)*)(i32 %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %22
7: ; preds = %1
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @WIFSIGNALED to i32 (i32, ...)*)(i32 %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @WTERMSIG to i32 (i32, ...)*)(i32 %0)
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @strsignal to i32 (i32, ...)*)(i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @putchar(i32 10)
br label %22
15: ; preds = %7
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @WIFSTOPPED to i32 (i32, ...)*)(i32 %0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @WSTOPSIG to i32 (i32, ...)*)(i32 %0)
%20 = tail call i32 (i32, ...) bitcast (i32 (...)* @strsignal to i32 (i32, ...)*)(i32 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %10, %18, %15, %4
ret void
}