#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 /*<<< orphan*/ printf(char *, int, int, ...);
int wait(int *);
void parent_code(int childPid) {
  int wait_rv;
  int child_status;
  int high_8, low_7, bit7;
  wait_rv = wait(&child_status);
  printf("done waiting for %d. Wait returned: %d\n", childPid, wait_rv);
  high_8 = child_status >> 8;
  low_7 = child_status & 0x7f;
  bit7 = child_status & 0x80;
  printf("status:exit = %d, sig = %d, core = %d\n", high_8, low_7, bit7);
}


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    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xeb0(%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),%ecx
mov    %ecx,%esi
sar    $0x8,%esi
mov    %ecx,%edx
and    $0x7f,%edx
and    $0x80,%ecx
lea    0xeca(%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 returned: %d\0A\00"
@.str.1 = [39 x i8] c"status: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* %5
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"done waiting for %d. Wait returned: %d\0A\00"
@.str.1 = [39 x i8] c"status: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 ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
ret void
}