#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);
int WIFSIGNALED(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdout;
void showStatus(int childExitMethod) {
  if (WIFEXITED(childExitMethod)) {
    printf("exit value %i\n", WEXITSTATUS(childExitMethod));
    fflush(stdout);
  } else if (WIFSIGNALED(childExitMethod)) {
    printf("terminated by signal %i\n", WIFSIGNALED(childExitMethod));
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<showStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1196 <showStatus+0x46>
mov    -0x4(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    11d0 <showStatus+0x80>
mov    -0x4(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%eax
je     11cb <showStatus+0x7b>
mov    -0x4(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    11d0 <showStatus+0x80>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showStatus>:
push   %rbx
mov    %edi,%ebx
call   1070 <WIFEXITED@plt>
test   %rax,%rax
je     116d <showStatus+0x1d>
mov    %ebx,%edi
call   1060 <WEXITSTATUS@plt>
lea    0xe95(%rip),%rdi
jmp    1186 <showStatus+0x36>
mov    %ebx,%edi
call   1040 <WIFSIGNALED@plt>
test   %eax,%eax
je     119c <showStatus+0x4c>
mov    %ebx,%edi
call   1040 <WIFSIGNALED@plt>
lea    0xe89(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
pop    %rbx
jmp    1050 <fflush@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"exit value %i\0A\00"
@stdout = global i32 0
@.str.1 = [25 x i8] c"terminated by signal %i\0A\00"
define void @showStatus(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 %12
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @WEXITSTATUS(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
br label %23
12: ; preds = %1
%13 = load i32, i32* %2
%14 = call i32 @WIFSIGNALED(i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* %2
%18 = call i32 @WIFSIGNALED(i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
br label %22
22: ; preds = %16, %12
br label %23
23: ; preds = %22, %6
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"exit value %i\0A\00"
@stdout = global i32 0
@.str.1 = [25 x i8] c"terminated by signal %i\0A\00"
define void @showStatus(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 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %13
7: ; preds = %1
%8 = tail call i32 @WIFSIGNALED(i32 %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = tail call i32 @WIFSIGNALED(i32 %0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %4, %10
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
br label %16
16: ; preds = %13, %7
ret void
}