#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ printf(char *, int);
int tcgetpgrp(int /*<<< orphan*/);
int tcgetsid(int /*<<< orphan*/);
int main(void) {
  printf("We are pid %d\n", getpid());
  printf("The session ID for this terminal %d\n", tcgetsid(0));
  printf("The process group for this terminal %d\n", tcgetpgrp(0));
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <tcgetsid@plt>
mov    %eax,%esi
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1060 <tcgetpgrp@plt>
mov    %eax,%esi
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xea1(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <tcgetsid@plt>
lea    0xe9b(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %edi,%edi
call   1060 <tcgetpgrp@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"We are pid %d\0A\00"
@.str.1 = [37 x i8] c"The session ID for this terminal %d\0A\00"
@.str.2 = [40 x i8] c"The process group for this terminal %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @getpid()
%3 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 @tcgetsid(i32 0)
%5 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = call i32 @tcgetpgrp(i32 0)
%7 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @EXIT_SUCCESS
%9 = call i32 @exit(i32 %8)
unreachable
}

LLVM IR (-O2):
@.str = [15 x i8] c"We are pid %d\0A\00"
@.str.1 = [37 x i8] c"The session ID for this terminal %d\0A\00"
@.str.2 = [40 x i8] c"The process group for this terminal %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @tcgetsid(i32 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @tcgetpgrp(i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @EXIT_SUCCESS
%8 = tail call i32 @exit(i32 %7)
unreachable
}