#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, ...);
int wait(int *);
extern void parent_code(int child_pid) {
  int child_status;
  int wait_rv = wait(&child_status);
  printf("done waiting for %d, wait returned %d\n", child_pid, wait_rv);
  int high_8 = child_status >> 8;
  int low_7 = child_status & 0x7F;
  int bit_7 = child_status & 0x80;
  printf("high_8: %d, low_7: %d, bit_7: %d\n", high_8, low_7, bit_7);
  exit(EXIT_SUCCESS);
}


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

x86 assembly (clang, -O2):
<parent_code>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rdi
call   1050 <wait@plt>
lea    0xeb8(%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    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"done waiting for %d, wait returned %d\0A\00"
@.str.1 = [34 x i8] c"high_8: %d, low_7: %d, bit_7: %d\0A\00"
@EXIT_SUCCESS = global i32 0
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* %3)
store i32 %8, i32* %4
%9 = load i32, i32* %2
%10 = load i32, i32* %4
%11 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = ashr i32 %12, 8
store i32 %13, i32* %5
%14 = load i32, i32* %3
%15 = and i32 %14, 127
store i32 %15, i32* %6
%16 = load i32, i32* %3
%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 ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
@.str = [39 x i8] c"done waiting for %d, wait returned %d\0A\00"
@.str.1 = [34 x i8] c"high_8: %d, low_7: %d, bit_7: %d\0A\00"
@EXIT_SUCCESS = global i32 0
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 ([39 x i8], [39 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 ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
%11 = load i32, i32* @EXIT_SUCCESS
%12 = call i32 @exit(i32 %11)
unreachable
}