#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);
scalar_t__ WIFSIGNALED(int);
int WTERMSIG(int);
int /*<<< orphan*/ printf(char *, ...);
void analize_status(int status) {
  printf("Status = %d\n", status);
  if (WIFEXITED(status) != 0) {
    printf("WIFEXITED\n");
    printf("Exit code: %d\n", WEXITSTATUS(status));
  }
  if (WIFSIGNALED(status) != 0) {
    printf("WIFSIGNALED\n");
    printf("Signal number: %d\n", WTERMSIG(status));
  }
}


x86 assembly (clang, -O0):
<analize_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1070 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11a4 <analize_status+0x54>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11dc <analize_status+0x8c>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <WTERMSIG@plt>
mov    %eax,%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analize_status>:
push   %rbx
mov    %edi,%ebx
lea    0xe96(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     11a2 <analize_status+0x42>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
lea    0xe74(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <WIFSIGNALED@plt>
test   %rax,%rax
je     11d2 <analize_status+0x72>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <WTERMSIG@plt>
lea    0xe54(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Status = %d\0A\00"
@.str.1 = [11 x i8] c"WIFEXITED\0A\00"
@.str.2 = [15 x i8] c"Exit code: %d\0A\00"
@.str.3 = [13 x i8] c"WIFSIGNALED\0A\00"
@.str.4 = [19 x i8] c"Signal number: %d\0A\00"
define void @analize_status(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 (i8*, ...) @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 %13
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 @WEXITSTATUS(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %8, %1
%14 = load i32, i32* %2
%15 = call i64 @WIFSIGNALED(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 @WTERMSIG(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %17, %13
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Status = %d\0A\00"
@.str.2 = [15 x i8] c"Exit code: %d\0A\00"
@.str.4 = [19 x i8] c"Signal number: %d\0A\00"
@str = [12 x i8] c"WIFSIGNALED\00"
@str.5 = [10 x i8] c"WIFEXITED\00"
define void @analize_status(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 %9, label %5
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 @WEXITSTATUS(i32 %0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %5, %1
%10 = tail call i64 @WIFSIGNALED(i32 %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @WTERMSIG(i32 %0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12, %9
ret void
}