#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*/ STDIN_FILENO;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getpgrp();
int getpid();
int getppid();
int /*<<< orphan*/ printf(char *, char *, int, int, int, int);
int /*<<< orphan*/ stdout;
int tcgetpgrp(int /*<<< orphan*/);
void prIds(char *name) {
  printf("%s: pid = %d, ppid = %d, pgrp = %d, tpgrp = %d\n", name, getpid(),
         getppid(), getpgrp(), tcgetpgrp(STDIN_FILENO));
  fflush(stdout);
}


x86 assembly (clang, -O0):
<prIds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1080 <getppid@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <getpgrp@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <tcgetpgrp@plt>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    %eax,%r9d
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prIds>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <getpgrp@plt>
mov    %eax,%ebp
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1050 <tcgetpgrp@plt>
lea    0xe65(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1040 <printf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fflush@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"%s: pid = %d, ppid = %d, pgrp = %d, tpgrp = %d\0A\00"
@STDIN_FILENO = global i32 0
@stdout = global i32 0
define void @prIds(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (...) @getpid()
%5 = call i32 (...) @getppid()
%6 = call i32 (...) @getpgrp()
%7 = load i32, i32* @STDIN_FILENO
%8 = call i32 @tcgetpgrp(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %4, i32 %5, i32 %6, i32 %8)
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"%s: pid = %d, ppid = %d, pgrp = %d, tpgrp = %d\0A\00"
@STDIN_FILENO = global i32 0
@stdout = global i32 0
define void @prIds(i8* %0) {
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 (...) @getppid()
%4 = tail call i32 (...) @getpgrp()
%5 = load i32, i32* @STDIN_FILENO
%6 = tail call i32 @tcgetpgrp(i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i32 %3, i32 %4, i32 %6)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fflush(i32 %8)
ret void
}