#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 */
typedef scalar_t__ status;

/* 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 signame(int);
int /*<<< orphan*/ tprintf(char *, int, ...);
int /*<<< orphan*/ tprints(char *);
int printstatus(int status) {
  int exited = 0;
  if (WIFSTOPPED(status)) {
    tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}", signame(WSTOPSIG(status)));
    status &= ~((WSTOPSIG(status)) << 8 | 0x7f);
  } else if (WIFSIGNALED(status)) {
    tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
            signame(WTERMSIG(status)),
            ((status)&0200) ? " && WCOREDUMP(s)" : "");
    status &= ~(((0) << 8 | (WTERMSIG(status))) | 0x80);
  } else if (WIFEXITED(status)) {
    tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}", WEXITSTATUS(status));
    exited = 1;
    status &= ~((WEXITSTATUS(status)) << 8 | (0));
  } else {
    tprintf("[%#x]", status);
    return 0;
  }
  if (status == 0)
    tprints("]");
  else
    tprintf(" | %#x]", status);
  return exited;
}


x86 assembly (clang, -O0):
<printstatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     11ef <printstatus+0x5f>
mov    -0x8(%rbp),%edi
call   1090 <WSTOPSIG@plt>
mov    %eax,%edi
call   10b0 <signame@plt>
mov    %eax,%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
mov    -0x8(%rbp),%edi
call   1090 <WSTOPSIG@plt>
shl    $0x8,%eax
or     $0x7f,%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    12d0 <printstatus+0x140>
mov    -0x8(%rbp),%edi
call   1030 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     125c <printstatus+0xcc>
mov    -0x8(%rbp),%edi
call   1060 <WTERMSIG@plt>
mov    %eax,%edi
call   10b0 <signame@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%ecx
and    $0x80,%ecx
lea    0xe3d(%rip),%rdx
lea    0xe26(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
mov    -0x8(%rbp),%edi
call   1060 <WTERMSIG@plt>
or     $0x0,%eax
or     $0x80,%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    12cb <printstatus+0x13b>
mov    -0x8(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     12a9 <printstatus+0x119>
mov    -0x8(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
shl    $0x8,%eax
or     $0x0,%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    12c6 <printstatus+0x136>
mov    -0x8(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1302 <printstatus+0x172>
jmp    12cb <printstatus+0x13b>
jmp    12d0 <printstatus+0x140>
cmpl   $0x0,-0x8(%rbp)
jne    12eb <printstatus+0x15b>
lea    0xdb3(%rip),%rdi
call   10a0 <tprints@plt>
jmp    12fc <printstatus+0x16c>
mov    -0x8(%rbp),%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printstatus>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1050 <WIFSTOPPED@plt>
mov    %ebx,%edi
test   %rax,%rax
je     11d5 <printstatus+0x45>
call   1090 <WSTOPSIG@plt>
mov    %eax,%edi
call   10b0 <signame@plt>
lea    0xe4c(%rip),%rdi
xor    %ebp,%ebp
mov    %eax,%esi
xor    %eax,%eax
call   1040 <tprintf@plt>
mov    %ebx,%edi
call   1090 <WSTOPSIG@plt>
shl    $0x8,%eax
xor    $0xffffff80,%eax
and    %ebx,%eax
jne    1226 <printstatus+0x96>
jmp    126e <printstatus+0xde>
call   1030 <WIFSIGNALED@plt>
mov    %ebx,%edi
test   %rax,%rax
je     1238 <printstatus+0xa8>
call   1060 <WTERMSIG@plt>
mov    %eax,%edi
call   10b0 <signame@plt>
test   $0x80,%bl
lea    0xe68(%rip),%rcx
lea    0xe51(%rip),%rdx
cmove  %rcx,%rdx
lea    0xe1d(%rip),%rdi
xor    %ebp,%ebp
mov    %eax,%esi
xor    %eax,%eax
call   1040 <tprintf@plt>
mov    %ebx,%edi
call   1060 <WTERMSIG@plt>
not    %eax
and    $0xffffff7f,%eax
and    %ebx,%eax
je     126e <printstatus+0xde>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <tprintf@plt>
jmp    127a <printstatus+0xea>
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     1283 <printstatus+0xf3>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
lea    0xe10(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <tprintf@plt>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
shl    $0x8,%eax
not    %eax
mov    $0x1,%ebp
and    %ebx,%eax
jne    1226 <printstatus+0x96>
lea    0xe1f(%rip),%rdi
call   10a0 <tprints@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdfe(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
jmp    122f <printstatus+0x9f>

LLVM IR (-O0):
@.str = [38 x i8] c"[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}\00"
@.str.1 = [41 x i8] c"[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}\00"
@.str.2 = [17 x i8] c" && WCOREDUMP(s)\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [40 x i8] c"[{WIFEXITED(s) && WEXITSTATUS(s) == %d}\00"
@.str.5 = [6 x i8] c"[%#x]\00"
@.str.6 = [2 x i8] c"]\00"
@.str.7 = [8 x i8] c" | %#x]\00"
define i32 @printstatus(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %3
%6 = call i64 @WIFSTOPPED(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @WSTOPSIG(i32 %9)
%11 = call i32 @signame(i32 %10)
%12 = call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %3
%14 = call i32 @WSTOPSIG(i32 %13)
%15 = shl i32 %14, 8
%16 = or i32 %15, 127
%17 = xor i32 %16, -1
%18 = load i32, i32* %3
%19 = and i32 %18, %17
store i32 %19, i32* %3
br label %61
20: ; preds = %1
%21 = load i32, i32* %3
%22 = call i64 @WIFSIGNALED(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %41
24: ; preds = %20
%25 = load i32, i32* %3
%26 = call i32 @WTERMSIG(i32 %25)
%27 = call i32 @signame(i32 %26)
%28 = load i32, i32* %3
%29 = and i32 %28, 128
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%33 = call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %27, i8* %32)
%34 = load i32, i32* %3
%35 = call i32 @WTERMSIG(i32 %34)
%36 = or i32 0, %35
%37 = or i32 %36, 128
%38 = xor i32 %37, -1
%39 = load i32, i32* %3
%40 = and i32 %39, %38
store i32 %40, i32* %3
br label %60
41: ; preds = %20
%42 = load i32, i32* %3
%43 = call i64 @WIFEXITED(i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %56
45: ; preds = %41
%46 = load i32, i32* %3
%47 = call i32 @WEXITSTATUS(i32 %46)
%48 = call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %47)
store i32 1, i32* %4
%49 = load i32, i32* %3
%50 = call i32 @WEXITSTATUS(i32 %49)
%51 = shl i32 %50, 8
%52 = or i32 %51, 0
%53 = xor i32 %52, -1
%54 = load i32, i32* %3
%55 = and i32 %54, %53
store i32 %55, i32* %3
br label %59
56: ; preds = %41
%57 = load i32, i32* %3
%58 = call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %57)
store i32 0, i32* %2
br label %71
59: ; preds = %45
br label %60
60: ; preds = %59, %24
br label %61
61: ; preds = %60, %8
%62 = load i32, i32* %3
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @tprints(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %69
66: ; preds = %61
%67 = load i32, i32* %3
%68 = call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %66, %64
%70 = load i32, i32* %4
store i32 %70, i32* %2
br label %71
71: ; preds = %69, %56
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@.str = [38 x i8] c"[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}\00"
@.str.1 = [41 x i8] c"[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}\00"
@.str.2 = [17 x i8] c" && WCOREDUMP(s)\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [40 x i8] c"[{WIFEXITED(s) && WEXITSTATUS(s) == %d}\00"
@.str.5 = [6 x i8] c"[%#x]\00"
@.str.6 = [2 x i8] c"]\00"
@.str.7 = [8 x i8] c" | %#x]\00"
define i32 @printstatus(i32 %0) {
%2 = tail call i64 @WIFSTOPPED(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @WSTOPSIG(i32 %0)
%6 = tail call i32 @signame(i32 %5)
%7 = tail call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @WSTOPSIG(i32 %0)
%9 = shl i32 %8, 8
%10 = xor i32 %9, -128
br label %35
11: ; preds = %1
%12 = tail call i64 @WIFSIGNALED(i32 %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %11
%15 = tail call i32 @WTERMSIG(i32 %0)
%16 = tail call i32 @signame(i32 %15)
%17 = and i32 %0, 128
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0)
%20 = tail call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %19)
%21 = tail call i32 @WTERMSIG(i32 %0)
%22 = or i32 %21, 128
%23 = xor i32 %22, -1
br label %35
24: ; preds = %11
%25 = tail call i64 @WIFEXITED(i32 %0)
%26 = icmp eq i64 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = tail call i32 @WEXITSTATUS(i32 %0)
%29 = tail call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = tail call i32 @WEXITSTATUS(i32 %0)
%31 = shl i32 %30, 8
%32 = xor i32 %31, -1
br label %35
33: ; preds = %24
%34 = tail call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %0)
br label %44
35: ; preds = %14, %27, %4
%36 = phi i32 [ %10, %4 ], [ %23, %14 ], [ %32, %27 ]
%37 = phi i32 [ 0, %4 ], [ 0, %14 ], [ 1, %27 ]
%38 = and i32 %36, %0
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = tail call i32 @tprints(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %44
42: ; preds = %35
%43 = tail call i32 (i8*, i32, ...) @tprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %38)
br label %44
44: ; preds = %40, %42, %33
%45 = phi i32 [ 0, %33 ], [ %37, %42 ], [ %37, %40 ]
ret i32 %45
}