#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 *);
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);
}


x86 assembly (clang, -O0):
<parent_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <wait@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xebc(%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    0xeaf(%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    0xec9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

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"
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)
ret void
}

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"
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)
ret void
}