#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*/ error(char *);
__attribute__((const)) int shorten_status(int status_big) {
  if (WIFEXITED(status_big))
    return WEXITSTATUS(status_big);
  if (WIFSIGNALED(status_big))
    return 128 + WTERMSIG(status_big);
  if (WIFSTOPPED(status_big))
    return 128 + WSTOPSIG(status_big);
  error("shorten_status got an invalid status (?!)");
}


x86 assembly (clang, -O0):
<shorten_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     119d <shorten_status+0x2d>
mov    -0x8(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,-0x4(%rbp)
jmp    11f7 <shorten_status+0x87>
mov    -0x8(%rbp),%edi
call   1030 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11c4 <shorten_status+0x54>
mov    -0x8(%rbp),%edi
call   1050 <WTERMSIG@plt>
add    $0x80,%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <shorten_status+0x87>
mov    -0x8(%rbp),%edi
call   1040 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     11eb <shorten_status+0x7b>
mov    -0x8(%rbp),%edi
call   1090 <WSTOPSIG@plt>
add    $0x80,%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <shorten_status+0x87>
lea    0xe0e(%rip),%rdi
call   1070 <error@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shorten_status>:
push   %rbx
mov    %edi,%ebx
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     1185 <shorten_status+0x15>
mov    %ebx,%edi
pop    %rbx
jmp    1060 <WEXITSTATUS@plt>
mov    %ebx,%edi
call   1030 <WIFSIGNALED@plt>
test   %rax,%rax
je     119a <shorten_status+0x2a>
mov    %ebx,%edi
call   1050 <WTERMSIG@plt>
jmp    11ad <shorten_status+0x3d>
mov    %ebx,%edi
call   1040 <WIFSTOPPED@plt>
test   %rax,%rax
je     11b2 <shorten_status+0x42>
mov    %ebx,%edi
call   1090 <WSTOPSIG@plt>
sub    $0xffffff80,%eax
pop    %rbx
ret
lea    0xe47(%rip),%rdi
call   1070 <error@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"shorten_status got an invalid status (?!)\00"
define i32 @shorten_status(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 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = call i32 @WEXITSTATUS(i32 %8)
store i32 %9, i32* %2
br label %28
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i64 @WIFSIGNALED(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i32 @WTERMSIG(i32 %15)
%17 = add nsw i32 128, %16
store i32 %17, i32* %2
br label %28
18: ; preds = %10
%19 = load i32, i32* %3
%20 = call i64 @WIFSTOPPED(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* %3
%24 = call i32 @WSTOPSIG(i32 %23)
%25 = add nsw i32 128, %24
store i32 %25, i32* %2
br label %28
26: ; preds = %18
%27 = call i32 @error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %22, %14, %7
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [42 x i8] c"shorten_status got an invalid status (?!)\00"
define i32 @shorten_status(i32 %0) {
%2 = tail call i64 @WIFEXITED(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @WEXITSTATUS(i32 %0)
br label %20
6: ; preds = %1
%7 = tail call i64 @WIFSIGNALED(i32 %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @WTERMSIG(i32 %0)
%11 = add nsw i32 %10, 128
br label %20
12: ; preds = %6
%13 = tail call i64 @WIFSTOPPED(i32 %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @WSTOPSIG(i32 %0)
%17 = add nsw i32 %16, 128
br label %20
18: ; preds = %12
%19 = tail call i32 @error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15, %9, %4
%21 = phi i32 [ %5, %4 ], [ %11, %9 ], [ %17, %15 ], [ undef, %18 ]
ret i32 %21
}