#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 ECHILD 130
#define EINTR 129
#define EINVAL 128
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
void err_wait(int err) {
  fprintf(stderr, "error: wait() family function caused an error\n");
  switch (err) {
  case ECHILD:
    fprintf(stderr, "       Child does not exist for this process\n");
    break;
  case EINVAL:
    fprintf(stderr, "       Invalid options\n");
    break;
  case EINTR:
    fprintf(stderr, "       Unblocked signal or SIGCHLD was caught while "
                    "WNOHANG was not set\n");
    break;
  default:
    fprintf(stderr, "       wait family type error has occurred\n");
    break;
  }
  fprintf(stderr, "       errno is: %d\n", err);
  ;
  fprintf(stderr, "       %s\n", strerror(err));
  ;
  fflush(stderr);
}


x86 assembly (clang, -O0):
<err_wait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x80,%eax
je     11aa <err_wait+0x7a>
jmp    1168 <err_wait+0x38>
mov    -0x8(%rbp),%eax
sub    $0x81,%eax
je     11c6 <err_wait+0x96>
jmp    117b <err_wait+0x4b>
mov    -0x8(%rbp),%eax
sub    $0x82,%eax
jne    11e2 <err_wait+0xb2>
jmp    118e <err_wait+0x5e>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11f9 <err_wait+0xc9>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11f9 <err_wait+0xc9>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11f9 <err_wait+0xc9>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xede(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
lea    0xecb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_wait>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    0x2ea3(%rip),%r14
mov    (%r14),%edi
lea    0xeb9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x80(%rbx),%eax
cmp    $0x2,%eax
ja     1168 <err_wait+0x38>
cltq
lea    0xfad(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    116f <err_wait+0x3f>
lea    0xf4f(%rip),%rsi
mov    (%r14),%edi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xf67(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%ebp
mov    %ebx,%edi
call   1050 <strerror@plt>
lea    0xf62(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"error: wait() family function caused an error\0A\00"
@.str.1 = [46 x i8] c" Child does not exist for this process\0A\00"
@.str.2 = [24 x i8] c" Invalid options\0A\00"
@.str.3 = [73 x i8] c" Unblocked signal or SIGCHLD was caught while WNOHANG was not set\0A\00"
@.str.4 = [44 x i8] c" wait family type error has occurred\0A\00"
@.str.5 = [21 x i8] c" errno is: %d\0A\00"
@.str.6 = [11 x i8] c" %s\0A\00"
define void @err_wait(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @stderr
%4 = call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
switch i32 %5, label %15 [
i32 130, label %6
i32 128, label %9
i32 129, label %12
]
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %18
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %18
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0))
br label %18
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %15, %12, %9, %6
%19 = load i32, i32* @stderr
%20 = load i32, i32* %2
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @stderr
%23 = load i32, i32* %2
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @stderr
%27 = call i32 @fflush(i32 %26)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"error: wait() family function caused an error\0A\00"
@.str.1 = [46 x i8] c" Child does not exist for this process\0A\00"
@.str.2 = [24 x i8] c" Invalid options\0A\00"
@.str.3 = [73 x i8] c" Unblocked signal or SIGCHLD was caught while WNOHANG was not set\0A\00"
@.str.4 = [44 x i8] c" wait family type error has occurred\0A\00"
@.str.5 = [21 x i8] c" errno is: %d\0A\00"
@.str.6 = [11 x i8] c" %s\0A\00"
@reltable.err_wait = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.err_wait to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([73 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.err_wait to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([46 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.err_wait to i64)) to i32)]
define void @err_wait(i32 %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = add i32 %0, -128
%5 = icmp ult i32 %4, 3
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.err_wait to i8*), i64 %8)
br label %10
10: ; preds = %1, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), %1 ]
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* %11)
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %0)
%16 = load i32, i32* @stderr
%17 = tail call i8* @strerror(i32 %0)
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = tail call i32 @fflush(i32 %19)
ret void
}