#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 int pid_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, ...);
int wait(int *);
void parent_code(pid_t pid) {
  int wait_rv;
  int status;
  int high_8, low_7, bit_7;
  wait_rv = wait(&status);
  printf("done waiting for %d, wait() return: %d\n", pid, wait_rv);
  high_8 = status >> 8;
  low_7 = status & 0x7F;
  bit_7 = status & 0x80;
  printf("status = %d: exit = %d, sig = %d, core = %d\n", status, high_8, low_7,
         bit_7);
}


x86 assembly (clang, -O0):
<parent_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <wait@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    $0x80,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parent_code>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rdi
call   1040 <wait@plt>
lea    0xec8(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %esi,%edx
sar    $0x8,%edx
mov    %esi,%ecx
and    $0x7f,%ecx
mov    %esi,%r8d
and    $0x80,%r8d
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"done waiting for %d, wait() return: %d\0A\00"
@.str.1 = [45 x i8] c"status = %d: exit = %d, sig = %d, core = %d\0A\00"
define void @parent_code(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = call i32 @wait(i32* %4)
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %4
%13 = ashr i32 %12, 8
store i32 %13, i32* %5
%14 = load i32, i32* %4
%15 = and i32 %14, 127
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = and i32 %16, 128
store i32 %17, i32* %7
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"done waiting for %d, wait() return: %d\0A\00"
@.str.1 = [45 x i8] c"status = %d: exit = %d, sig = %d, core = %d\0A\00"
define void @parent_code(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @wait(i32* %2)
%5 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %4)
%6 = load i32, i32* %2
%7 = ashr i32 %6, 8
%8 = and i32 %6, 127
%9 = and i32 %6, 128
%10 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7, i32 %8, i32 %9)
ret void
}