#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 */
#define SIGTRAP 130
#define SIGUSR1 129
#define SIGXFSZ 128
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WSTOPSIG(int);
int parse_status(int status) {
  if (WIFEXITED(status)) {
    if (WEXITSTATUS(status) == 0)
      return 0;
    else
      return 253;
  }
  if (WIFSIGNALED(status))
    return 2;
  if (WIFSTOPPED(status)) {
    int sig = WSTOPSIG(status);
    switch (sig) {
    case SIGUSR1:
      break;
    case SIGTRAP:
      return (-127);
    case SIGXFSZ:
      return 253;
    default:
      return 253;
    }
  }
  return (-255);
}


x86 assembly (clang, -O0):
<parse_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1197 <parse_status+0x47>
mov    -0x8(%rbp),%edi
call   1050 <WEXITSTATUS@plt>
cmp    $0x0,%rax
jne    118b <parse_status+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1243 <parse_status+0xf3>
movl   $0xfd,-0x4(%rbp)
jmp    1243 <parse_status+0xf3>
mov    -0x8(%rbp),%edi
call   1030 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11b5 <parse_status+0x65>
movl   $0x2,-0x4(%rbp)
jmp    1243 <parse_status+0xf3>
mov    -0x8(%rbp),%edi
call   1040 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     123c <parse_status+0xec>
mov    -0x8(%rbp),%edi
call   1070 <WSTOPSIG@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x80,%eax
je     121f <parse_status+0xcf>
jmp    11e8 <parse_status+0x98>
mov    -0x10(%rbp),%eax
sub    $0x81,%eax
je     120e <parse_status+0xbe>
jmp    11fb <parse_status+0xab>
mov    -0x10(%rbp),%eax
sub    $0x82,%eax
je     1213 <parse_status+0xc3>
jmp    122b <parse_status+0xdb>
jmp    1237 <parse_status+0xe7>
movl   $0xffffff81,-0x4(%rbp)
jmp    1243 <parse_status+0xf3>
movl   $0xfd,-0x4(%rbp)
jmp    1243 <parse_status+0xf3>
movl   $0xfd,-0x4(%rbp)
jmp    1243 <parse_status+0xf3>
jmp    123c <parse_status+0xec>
movl   $0xffffff01,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_status>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1060 <WIFEXITED@plt>
test   %rax,%rax
je     1175 <parse_status+0x25>
mov    %ebp,%edi
call   1050 <WEXITSTATUS@plt>
xor    %ecx,%ecx
test   %rax,%rax
mov    $0xfd,%ebx
cmove  %ecx,%ebx
jmp    1186 <parse_status+0x36>
mov    %ebp,%edi
call   1030 <WIFSIGNALED@plt>
mov    $0x2,%ebx
test   %rax,%rax
je     118f <parse_status+0x3f>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
call   1040 <WIFSTOPPED@plt>
mov    $0xffffff01,%ebx
test   %rax,%rax
je     1186 <parse_status+0x36>
mov    %ebp,%edi
call   1070 <WSTOPSIG@plt>
cmp    $0x82,%eax
je     11c1 <parse_status+0x71>
cmp    $0x81,%eax
je     1186 <parse_status+0x36>
cmp    $0x80,%eax
mov    $0xfd,%ebx
jmp    1186 <parse_status+0x36>
mov    $0xffffff81,%ebx
jmp    1186 <parse_status+0x36>

LLVM IR (-O0):
define i32 @parse_status(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i64 @WIFEXITED(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i64 @WEXITSTATUS(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 0, i32* %2
br label %33
13: ; preds = %8
store i32 253, i32* %2
br label %33
14: ; preds = %1
%15 = load i32, i32* %3
%16 = call i64 @WIFSIGNALED(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 2, i32* %2
br label %33
19: ; preds = %14
%20 = load i32, i32* %3
%21 = call i64 @WIFSTOPPED(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 @WSTOPSIG(i32 %24)
store i32 %25, i32* %4
%26 = load i32, i32* %4
switch i32 %26, label %30 [
i32 129, label %27
i32 130, label %28
i32 128, label %29
]
27: ; preds = %23
br label %31
28: ; preds = %23
store i32 -127, i32* %2
br label %33
29: ; preds = %23
store i32 253, i32* %2
br label %33
30: ; preds = %23
store i32 253, i32* %2
br label %33
31: ; preds = %27
br label %32
32: ; preds = %31, %19
store i32 -255, i32* %2
br label %33
33: ; preds = %32, %30, %29, %28, %18, %13, %12
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @parse_status(i32 %0) {
%2 = tail call i64 @WIFEXITED(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i64 @WEXITSTATUS(i32 %0)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i32 0, i32 253
br label %20
8: ; preds = %1
%9 = tail call i64 @WIFSIGNALED(i32 %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = tail call i64 @WIFSTOPPED(i32 %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = tail call i32 @WSTOPSIG(i32 %0)
switch i32 %15, label %17 [
i32 129, label %20
i32 130, label %18
i32 128, label %16
]
16: ; preds = %14
br label %18
17: ; preds = %14
br label %18
18: ; preds = %17, %16, %14
%19 = phi i32 [ -127, %14 ], [ 253, %16 ], [ 253, %17 ]
br label %20
20: ; preds = %11, %14, %18, %8, %4
%21 = phi i32 [ %7, %4 ], [ 2, %8 ], [ %19, %18 ], [ -255, %14 ], [ -255, %11 ]
ret i32 %21
}