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


x86 assembly (clang, -O0):
<pr_ids>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <getppid@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <getpgrp@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1050 <tcgetpgrp@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    %rax,%r9
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_ids>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1070 <getpgrp@plt>
mov    %rax,%rbx
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1050 <tcgetpgrp@plt>
lea    0xe62(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
mov    %rax,%r9
call   1040 <printf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <fflush@plt>

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

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