#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 */
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int getpid();
int getppid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ show_sid(int);
int main(int argc, char *argv[]) {
  do {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(), getpid());
    printf("start");
    printf("\n");
  } while (0);
  show_sid(getpid());
  show_sid(getppid());
  show_sid(1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    %eax,%r8d
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
call   1060 <show_sid@plt>
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,%edi
call   1060 <show_sid@plt>
mov    $0x1,%edi
call   1060 <show_sid@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x8(%rsp),%r14d
mov    0xc(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe6c(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%edi
call   1070 <show_sid@plt>
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%edi
call   1070 <show_sid@plt>
mov    $0x1,%edi
call   1070 <show_sid@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [22 x i8] c"%ld.%6ld [%d->%d] -- \00"
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %2
%8 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 (...) @getppid()
%14 = call i32 (...) @getpid()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12, i32 %13, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %7
%19 = call i32 (...) @getpid()
%20 = call i32 @show_sid(i32 %19)
%21 = call i32 (...) @getppid()
%22 = call i32 @show_sid(i32 %21)
%23 = call i32 @show_sid(i32 1)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [22 x i8] c"%ld.%6ld [%d->%d] -- \00"
@.str.1 = [6 x i8] c"start\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 (...) @getppid()
%11 = tail call i32 (...) @getpid()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9, i32 %10, i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @putchar(i32 10)
%15 = tail call i32 (...) @getpid()
%16 = tail call i32 @show_sid(i32 %15)
%17 = tail call i32 (...) @getppid()
%18 = tail call i32 @show_sid(i32 %17)
%19 = tail call i32 @show_sid(i32 1)
ret i32 0
}