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

/* Variables and functions */
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int main(int argc, char *argv[]) {
  struct timeval tv;
  struct timezone tz;
  test_init(argc, argv);
  test_msg("%s pid %d\n", argv[0], getpid());
  gettimeofday(&tv, &tz);
  test_msg("%d time: %10li\n", getpid(), tv.tv_sec);
  test_daemon();
  test_waitsig();
  gettimeofday(&tv, &tz);
  test_msg("%d time: %10li\n", getpid(), tv.tv_sec);
  test_msg("PASS\n");
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <gettimeofday@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%edx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
mov    $0x0,%al
call   1050 <test_daemon@plt>
mov    $0x0,%al
call   1080 <test_waitsig@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <gettimeofday@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%edx
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1070 <test_msg@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
call   1030 <test_init@plt>
mov    (%rbx),%rbx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <test_msg@plt>
mov    %rsp,%r15
lea    0x8(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    (%rsp),%edx
lea    0xe59(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <test_msg@plt>
xor    %eax,%eax
call   1050 <test_daemon@plt>
xor    %eax,%eax
call   1080 <test_waitsig@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <test_msg@plt>
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1070 <test_msg@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.timezone = type { i32 }
@.str = [11 x i8] c"%s pid %d\0A\00"
@.str.1 = [16 x i8] c"%d time: %10li\0A\00"
@.str.2 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timezone
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @test_init(i32 %8, i8** %9)
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (...) @getpid()
%15 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14)
%16 = call i32 @gettimeofday(%struct.timeval* %6, %struct.timezone* %7)
%17 = call i32 (...) @getpid()
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %19)
%21 = call i32 (...) @test_daemon()
%22 = call i32 (...) @test_waitsig()
%23 = call i32 @gettimeofday(%struct.timeval* %6, %struct.timezone* %7)
%24 = call i32 (...) @getpid()
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %26)
%28 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.timezone = type { i32 }
@.str = [11 x i8] c"%s pid %d\0A\00"
@.str.1 = [16 x i8] c"%d time: %10li\0A\00"
@.str.2 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timezone
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timezone* %4 to i8*
%7 = tail call i32 @test_init(i32 %0, i8** %1)
%8 = load i8*, i8** %1
%9 = tail call i32 (...) @getpid()
%10 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
%11 = call i32 @gettimeofday(%struct.timeval* %3, %struct.timezone* %4)
%12 = tail call i32 (...) @getpid()
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %14)
%16 = tail call i32 (...) @test_daemon()
%17 = tail call i32 (...) @test_waitsig()
%18 = call i32 @gettimeofday(%struct.timeval* %3, %struct.timezone* %4)
%19 = tail call i32 (...) @getpid()
%20 = load i32, i32* %13
%21 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
%22 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}