#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 /*<<< orphan*/ WEXITSTATUS(int);
scalar_t__ WIFCONTINUED(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int /*<<< orphan*/ WSTOPSIG(int);
int /*<<< orphan*/ WTERMSIG(int);
int /*<<< orphan*/ msg(char *, char *, ...);
void _interpret_status(int s, char *cmd) {
  if (WIFEXITED(s))
    msg("%s exited with rc=%d", cmd, WEXITSTATUS(s));
  else if (WIFSIGNALED(s))
    msg("%s killed with signal %d%s", cmd, WTERMSIG(s),
        WCOREDUMP(s) ? " (core dumped)" : "");
  else if (WIFSTOPPED(s))
    msg("%s stopped with signal %d", cmd, WSTOPSIG(s));
  else if (WIFCONTINUED(s))
    msg("%s restarted with SIGCONT", cmd);
}


x86 assembly (clang, -O0):
<_interpret_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1090 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11da <_interpret_status+0x4a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    12a8 <_interpret_status+0x118>
mov    -0x4(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     123a <_interpret_status+0xaa>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <WTERMSIG@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <WCOREDUMP@plt>
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    %rax,%rdi
lea    0xe26(%rip),%rcx
lea    0xe11(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%rcx
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    12a3 <_interpret_status+0x113>
mov    -0x4(%rbp),%edi
call   1060 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     1275 <_interpret_status+0xe5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <WSTOPSIG@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    129e <_interpret_status+0x10e>
mov    -0x4(%rbp),%edi
call   1050 <WIFCONTINUED@plt>
cmp    $0x0,%rax
je     1299 <_interpret_status+0x109>
mov    -0x10(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    129e <_interpret_status+0x10e>
jmp    12a3 <_interpret_status+0x113>
jmp    12a8 <_interpret_status+0x118>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_interpret_status>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1090 <WIFEXITED@plt>
test   %rax,%rax
je     11c1 <_interpret_status+0x31>
mov    %ebp,%edi
call   1080 <WEXITSTATUS@plt>
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    10b0 <msg@plt>
mov    %ebp,%edi
call   1040 <WIFSIGNALED@plt>
mov    %ebp,%edi
test   %rax,%rax
je     120b <_interpret_status+0x7b>
call   1070 <WTERMSIG@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1030 <WCOREDUMP@plt>
test   %rax,%rax
lea    0xe56(%rip),%rax
lea    0xe41(%rip),%rcx
cmove  %rax,%rcx
lea    0xe1b(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    10b0 <msg@plt>
call   1060 <WIFSTOPPED@plt>
mov    %ebp,%edi
test   %rax,%rax
je     1225 <_interpret_status+0x95>
call   10a0 <WSTOPSIG@plt>
lea    0xe1c(%rip),%rdi
jmp    11b1 <_interpret_status+0x21>
call   1050 <WIFCONTINUED@plt>
test   %rax,%rax
je     1244 <_interpret_status+0xb4>
lea    0xe23(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    10b0 <msg@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%s exited with rc=%d\00"
@.str.1 = [27 x i8] c"%s killed with signal %d%s\00"
@.str.2 = [15 x i8] c" (core dumped)\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [26 x i8] c"%s stopped with signal %d\00"
@.str.5 = [26 x i8] c"%s restarted with SIGCONT\00"
define void @_interpret_status(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = call i64 @WIFEXITED(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load i32, i32* %3
%11 = call i32 @WEXITSTATUS(i32 %10)
%12 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %11)
br label %46
13: ; preds = %2
%14 = load i32, i32* %3
%15 = call i64 @WIFSIGNALED(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = load i32, i32* %3
%20 = call i32 @WTERMSIG(i32 %19)
%21 = load i32, i32* %3
%22 = call i64 @WCOREDUMP(i32 %21)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%26 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %20, i8* %25)
br label %45
27: ; preds = %13
%28 = load i32, i32* %3
%29 = call i64 @WIFSTOPPED(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = load i32, i32* %3
%34 = call i32 @WSTOPSIG(i32 %33)
%35 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %32, i32 %34)
br label %44
36: ; preds = %27
%37 = load i32, i32* %3
%38 = call i64 @WIFCONTINUED(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i8*, i8** %4
%42 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %36
br label %44
44: ; preds = %43, %31
br label %45
45: ; preds = %44, %17
br label %46
46: ; preds = %45, %8
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"%s exited with rc=%d\00"
@.str.1 = [27 x i8] c"%s killed with signal %d%s\00"
@.str.2 = [15 x i8] c" (core dumped)\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [26 x i8] c"%s stopped with signal %d\00"
@.str.5 = [26 x i8] c"%s restarted with SIGCONT\00"
define void @_interpret_status(i32 %0, i8* %1) {
%3 = tail call i64 @WIFEXITED(i32 %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @WEXITSTATUS(i32 %0)
%7 = tail call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %6)
br label %28
8: ; preds = %2
%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.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0)
%16 = tail call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %12, i8* %15)
br label %28
17: ; preds = %8
%18 = tail call i64 @WIFSTOPPED(i32 %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = tail call i32 @WSTOPSIG(i32 %0)
%22 = tail call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %1, i32 %21)
br label %28
23: ; preds = %17
%24 = tail call i64 @WIFCONTINUED(i32 %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %1)
br label %28
28: ; preds = %11, %23, %26, %20, %5
ret void
}