#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);
scalar_t__ WIFSTOPPED(int);
int WSTOPSIG(int);
int WTERMSIG(int);
int /*<<< orphan*/ printf(char *, int);
int process_exit(int status) {
  if (0 != WIFEXITED(status)) {
    printf("INFO: normal termination, exit code: %d.\n", WEXITSTATUS(status));
    return 1;
  } else if (0 != WIFSIGNALED(status)) {
    printf("INFO: signal termination, signal NO: %d.\n", WTERMSIG(status));
    return 1;
  } else if (0 != WIFSTOPPED(status)) {
    printf("INFO: stopped status, signal NO: %d.\n", WSTOPSIG(status));
  }
  return 0;
}


x86 assembly (clang, -O0):
<process_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <WIFEXITED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11b3 <process_exit+0x43>
mov    -0x8(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <process_exit+0xb8>
mov    -0x8(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11eb <process_exit+0x7b>
mov    -0x8(%rbp),%edi
call   1060 <WTERMSIG@plt>
mov    %eax,%esi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <process_exit+0xb8>
mov    -0x8(%rbp),%edi
call   1050 <WIFSTOPPED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1217 <process_exit+0xa7>
mov    -0x8(%rbp),%edi
call   1090 <WSTOPSIG@plt>
mov    %eax,%esi
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
jmp    121c <process_exit+0xac>
jmp    1221 <process_exit+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_exit>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     118f <process_exit+0x1f>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
lea    0xe73(%rip),%rdi
jmp    11a9 <process_exit+0x39>
mov    %ebx,%edi
call   1040 <WIFSIGNALED@plt>
test   %rax,%rax
je     11be <process_exit+0x4e>
mov    %ebx,%edi
call   1060 <WTERMSIG@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebx,%edi
call   1050 <WIFSTOPPED@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11b5 <process_exit+0x45>
mov    %ebx,%edi
call   1090 <WSTOPSIG@plt>
lea    0xe7a(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
jmp    11b5 <process_exit+0x45>

LLVM IR (-O0):
@.str = [42 x i8] c"INFO: normal termination, exit code: %d.\0A\00"
@.str.1 = [42 x i8] c"INFO: signal termination, signal NO: %d.\0A\00"
@.str.2 = [38 x i8] c"INFO: stopped status, signal NO: %d.\0A\00"
define i32 @process_exit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 @WIFEXITED(i32 %4)
%6 = icmp ne i64 0, %5
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* %3
%9 = call i32 @WEXITSTATUS(i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 1, i32* %2
br label %30
11: ; preds = %1
%12 = load i32, i32* %3
%13 = call i64 @WIFSIGNALED(i32 %12)
%14 = icmp ne i64 0, %13
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %3
%17 = call i32 @WTERMSIG(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i32 1, i32* %2
br label %30
19: ; preds = %11
%20 = load i32, i32* %3
%21 = call i64 @WIFSTOPPED(i32 %20)
%22 = icmp ne i64 0, %21
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 @WSTOPSIG(i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23, %19
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
store i32 0, i32* %2
br label %30
30: ; preds = %29, %15, %7
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [42 x i8] c"INFO: normal termination, exit code: %d.\0A\00"
@.str.1 = [42 x i8] c"INFO: signal termination, signal NO: %d.\0A\00"
@.str.2 = [38 x i8] c"INFO: stopped status, signal NO: %d.\0A\00"
define i32 @process_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 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %19
7: ; preds = %1
%8 = tail call i64 @WIFSIGNALED(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @WTERMSIG(i32 %0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %19
13: ; preds = %7
%14 = tail call i64 @WIFSTOPPED(i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @WSTOPSIG(i32 %0)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13, %16, %10, %4
%20 = phi i32 [ 1, %4 ], [ 1, %10 ], [ 0, %16 ], [ 0, %13 ]
ret i32 %20
}