#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 getpid();
int getppid();
int /*<<< orphan*/ printf(char *, ...);
void printProcessInfo(int childPid, int childStatus) {
  printf("PPID: %d, PID: %d", getppid(), getpid());
  if (childStatus > 0) {
    printf(", CPID: %d, RETVAL: %d", childPid, childStatus);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printProcessInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getppid@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1180 <printProcessInfo+0x50>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProcessInfo>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
xor    %eax,%eax
call   1060 <getppid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xea0(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    1182 <printProcessInfo+0x42>
lea    0xe9c(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"PPID: %d, PID: %d\00"
@.str.1 = [23 x i8] c", CPID: %d, RETVAL: %d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printProcessInfo(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = call i32 (...) @getppid()
%6 = call i32 (...) @getpid()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
br label %14
14: ; preds = %10, %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"PPID: %d, PID: %d\00"
@.str.1 = [23 x i8] c", CPID: %d, RETVAL: %d\00"
define void @printProcessInfo(i32 %0, i32 %1) {
%3 = tail call i32 (...) @getppid()
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
br label %9
9: ; preds = %7, %2
%10 = tail call i32 @putchar(i32 10)
ret void
}