#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 scalar_t__ time_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SYS_getcwd;
int /*<<< orphan*/ SYS_getpid;
int /*<<< orphan*/ SYS_getppid;
int /*<<< orphan*/ SYS_time;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int syscall(int /*<<< orphan*/, ...);
int main(int argc, char *argv[]) {
  int rc;
  time_t t;
  unsigned long cwd_size = 1024;
  char cwd[cwd_size];
  rc = syscall(SYS_getpid);
  printf("rc from getpid= %d\n", rc);
  rc = syscall(SYS_getppid);
  printf("rc from getppid= %d\n", rc);
  rc = syscall(SYS_time, &t);
  printf("rc from time= %d\n", rc);
  printf("t from time= %ld\n", (long)t);
  rc = syscall(SYS_getcwd, &cwd, cwd_size);
  printf("rc from getcwd= %d\n", rc);
  printf("getcwd gives = %s\n", cwd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x400,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1040 <syscall@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1040 <syscall@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <syscall@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1040 <syscall@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1040 <syscall@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1040 <syscall@plt>
lea    0xea5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <syscall@plt>
lea    0xe95(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <syscall@plt>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SYS_getpid = global i32 0
@.str = [20 x i8] c"rc from getpid= %d\0A\00"
@SYS_getppid = global i32 0
@.str.1 = [21 x i8] c"rc from getppid= %d\0A\00"
@SYS_time = global i32 0
@.str.2 = [18 x i8] c"rc from time= %d\0A\00"
@.str.3 = [18 x i8] c"t from time= %ld\0A\00"
@SYS_getcwd = global i32 0
@.str.4 = [20 x i8] c"rc from getcwd= %d\0A\00"
@.str.5 = [19 x i8] c"getcwd gives = %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1024, i64* %8
%11 = load i64, i64* %8
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %9
%13 = alloca i8, i64 %11
store i64 %11, i64* %10
%14 = load i32, i32* @SYS_getpid
%15 = call i32 (i32, ...) @syscall(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @SYS_getppid
%19 = call i32 (i32, ...) @syscall(i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @SYS_time
%23 = call i32 (i32, ...) @syscall(i32 %22, i64* %7)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i64, i64* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 %26)
%28 = load i32, i32* @SYS_getcwd
%29 = load i64, i64* %8
%30 = call i32 (i32, ...) @syscall(i32 %28, i8* %13, i64 %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
}

LLVM IR (-O2):
@SYS_getpid = global i32 0
@.str = [20 x i8] c"rc from getpid= %d\0A\00"
@SYS_getppid = global i32 0
@.str.1 = [21 x i8] c"rc from getppid= %d\0A\00"
@SYS_time = global i32 0
@.str.2 = [18 x i8] c"rc from time= %d\0A\00"
@.str.3 = [18 x i8] c"t from time= %ld\0A\00"
@SYS_getcwd = global i32 0
@.str.4 = [20 x i8] c"rc from getcwd= %d\0A\00"
@.str.5 = [19 x i8] c"getcwd gives = %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @SYS_getpid
%8 = tail call i32 (i32, ...) @syscall(i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @SYS_getppid
%11 = tail call i32 (i32, ...) @syscall(i32 %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @SYS_time
%14 = call i32 (i32, ...) @syscall(i32 %13, i64* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i64, i64* %3
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 %16)
%18 = load i32, i32* @SYS_getcwd
%19 = call i32 (i32, ...) @syscall(i32 %18, i8* %6, i64 1024)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}