#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__ 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 *, ...);
int _interpret_status(int s, char *cmd) {
  int rc = 1;
  if (WIFEXITED(s)) {
    rc = WEXITSTATUS(s);
    msg("%s exited with rc=%d", cmd, rc);
  } 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);
  return rc;
}


x86 assembly (clang, -O0):
<_interpret_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1090 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11dd <_interpret_status+0x4d>
mov    -0x4(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    12ab <_interpret_status+0x11b>
mov    -0x4(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     123d <_interpret_status+0xad>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <WTERMSIG@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <WCOREDUMP@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    %rax,%rdi
lea    0xe23(%rip),%rcx
lea    0xe0e(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%rcx
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    12a6 <_interpret_status+0x116>
mov    -0x4(%rbp),%edi
call   1060 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     1278 <_interpret_status+0xe8>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <WSTOPSIG@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    12a1 <_interpret_status+0x111>
mov    -0x4(%rbp),%edi
call   1050 <WIFCONTINUED@plt>
cmp    $0x0,%rax
je     129c <_interpret_status+0x10c>
mov    -0x10(%rbp),%rsi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   10b0 <msg@plt>
jmp    12a1 <_interpret_status+0x111>
jmp    12a6 <_interpret_status+0x116>
jmp    12ab <_interpret_status+0x11b>
mov    -0x14(%rbp),%eax
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     11c4 <_interpret_status+0x34>
mov    %ebp,%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,%ebp
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <msg@plt>
jmp    125c <_interpret_status+0xcc>
mov    %ebp,%edi
call   1040 <WIFSIGNALED@plt>
mov    %ebp,%edi
test   %rax,%rax
je     1211 <_interpret_status+0x81>
call   1070 <WTERMSIG@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1030 <WCOREDUMP@plt>
test   %rax,%rax
lea    0xe53(%rip),%rax
lea    0xe3e(%rip),%rcx
cmove  %rax,%rcx
lea    0xe18(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   10b0 <msg@plt>
mov    $0x1,%ebp
jmp    125c <_interpret_status+0xcc>
call   1060 <WIFSTOPPED@plt>
mov    %ebp,%edi
test   %rax,%rax
je     123c <_interpret_status+0xac>
call   10a0 <WSTOPSIG@plt>
lea    0xe16(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <msg@plt>
mov    $0x1,%ebp
jmp    125c <_interpret_status+0xcc>
call   1050 <WIFCONTINUED@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     125c <_interpret_status+0xcc>
lea    0xe07(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <msg@plt>
mov    %ebp,%eax
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 i32 @_interpret_status(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 1, i32* %5
%6 = load i32, i32* %3
%7 = call i64 @WIFEXITED(i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* %3
%11 = call i32 @WEXITSTATUS(i32 %10)
store i32 %11, i32* %5
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13)
br label %48
15: ; preds = %2
%16 = load i32, i32* %3
%17 = call i64 @WIFSIGNALED(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = load i32, i32* %3
%22 = call i32 @WTERMSIG(i32 %21)
%23 = load i32, i32* %3
%24 = call i64 @WCOREDUMP(i32 %23)
%25 = icmp ne i64 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, 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)
%28 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %22, i8* %27)
br label %47
29: ; preds = %15
%30 = load i32, i32* %3
%31 = call i64 @WIFSTOPPED(i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = load i32, i32* %3
%36 = call i32 @WSTOPSIG(i32 %35)
%37 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %34, i32 %36)
br label %46
38: ; preds = %29
%39 = load i32, i32* %3
%40 = call i64 @WIFCONTINUED(i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i8*, i8** %4
%44 = call i32 (i8*, i8*, ...) @msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %38
br label %46
46: ; preds = %45, %33
br label %47
47: ; preds = %46, %19
br label %48
48: ; preds = %47, %9
%49 = load i32, i32* %5
ret i32 %49
}

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 i32 @_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
%29 = phi i32 [ %6, %5 ], [ 1, %11 ], [ 1, %20 ], [ 1, %26 ], [ 1, %23 ]
ret i32 %29
}