#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);
int WTERMSIG(int);
int /*<<< orphan*/ printf(char *, int, ...);
void print_system_status(int status) {
  printf("status = %d\n", 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" : "");
  }
}


x86 assembly (clang, -O0):
<print_system_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11ab <print_system_status+0x4b>
mov    -0x4(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ff <print_system_status+0x9f>
mov    -0x4(%rbp),%edi
call   1050 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11fa <print_system_status+0x9a>
mov    -0x4(%rbp),%edi
call   1060 <WTERMSIG@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <WCOREDUMP@plt>
mov    -0x8(%rbp),%esi
mov    %rax,%rcx
lea    0xe47(%rip),%rdx
lea    0xe6b(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ff <print_system_status+0x9f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_system_status>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xeac(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     119e <print_system_status+0x3e>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
lea    0xe71(%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>
test   %rax,%rax
je     11e5 <print_system_status+0x85>
mov    %ebx,%edi
call   1060 <WTERMSIG@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <WCOREDUMP@plt>
test   %rax,%rax
lea    0xe60(%rip),%rax
lea    0xe84(%rip),%rdx
cmove  %rax,%rdx
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"status = %d\0A\00"
@.str.1 = [37 x i8] c"normal termination,exit status = %d\0A\00"
@.str.2 = [42 x i8] c"abnormal termination,signal number =%d%s\0A\00"
@.str.3 = [20 x i8] c"core file generated\00"
@.str.4 = [1 x i8] zeroinitializer
define void @print_system_status(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* %2
%6 = call i64 @WIFEXITED(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* %2
%10 = call i32 @WEXITSTATUS(i32 %9)
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %26
12: ; preds = %1
%13 = load i32, i32* %2
%14 = call i64 @WIFSIGNALED(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32, i32* %2
%18 = call i32 @WTERMSIG(i32 %17)
%19 = load i32, i32* %2
%20 = call i64 @WCOREDUMP(i32 %19)
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %18, i8* %23)
br label %25
25: ; preds = %16, %12
br label %26
26: ; preds = %25, %8
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"status = %d\0A\00"
@.str.1 = [37 x i8] c"normal termination,exit status = %d\0A\00"
@.str.2 = [42 x i8] c"abnormal termination,signal number =%d%s\0A\00"
@.str.3 = [20 x i8] c"core file generated\00"
@.str.4 = [1 x i8] zeroinitializer
define void @print_system_status(i32 %0) {
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = tail call i64 @WIFEXITED(i32 %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 @WEXITSTATUS(i32 %0)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %17
8: ; preds = %1
%9 = tail call i64 @WIFSIGNALED(i32 %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = tail call i32 @WTERMSIG(i32 %0)
%13 = tail call i64 @WCOREDUMP(i32 %0)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0)
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %12, i8* %15)
br label %17
17: ; preds = %8, %11, %5
ret void
}