#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 */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
scalar_t__ getpgid(int /*<<< orphan*/);
scalar_t__ getpid();
scalar_t__ getppid();
scalar_t__ getsid(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void get_info(char *str_proc, pid_t pid) {
  printf("%s\n", str_proc);
  printf("PPID: %ld\n", (long)getppid());
  printf(" PID: %ld\n", (long)getpid());
  printf(" SID: %ld\n", (long)getsid(pid));
  printf("PGID: %ld\n", (long)getpgid(pid));
}


x86 assembly (clang, -O0):
<get_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %rax,%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %rax,%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <getsid@plt>
mov    %rax,%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <getpgid@plt>
mov    %rax,%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_info>:
push   %rbx
mov    %esi,%ebx
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getppid@plt>
lea    0xe8a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe7d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <getsid@plt>
lea    0xe70(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1070 <getpgid@plt>
lea    0xe63(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [11 x i8] c"PPID: %ld\0A\00"
@.str.2 = [11 x i8] c" PID: %ld\0A\00"
@.str.3 = [11 x i8] c" SID: %ld\0A\00"
@.str.4 = [11 x i8] c"PGID: %ld\0A\00"
define void @get_info(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i64 (...) @getppid()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = call i64 (...) @getpid()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %9)
%11 = load i32, i32* %4
%12 = call i64 @getsid(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %12)
%14 = load i32, i32* %4
%15 = call i64 @getpgid(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 %15)
ret void
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"PPID: %ld\0A\00"
@.str.2 = [11 x i8] c" PID: %ld\0A\00"
@.str.3 = [11 x i8] c" SID: %ld\0A\00"
@.str.4 = [11 x i8] c"PGID: %ld\0A\00"
define void @get_info(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) %0)
%4 = tail call i64 (...) @getppid()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %4)
%6 = tail call i64 (...) @getpid()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %6)
%8 = tail call i64 @getsid(i32 %1)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %8)
%10 = tail call i64 @getpgid(i32 %1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 %10)
ret void
}