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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ cur_time;
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  time_t cur_time = time(&cur_time);
  char *cur_time_str = ctime(&cur_time);
  printf("%s\n", cur_time_str);
  int i;
  for (i = 0; i < 5; i++) {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    printf("sizeof(tv.tv_sec)  = %d.\n", sizeof(tv.tv_sec));
    printf("sizeof(tv.tv_usec) = %d.\n", sizeof(tv.tv_usec));
    printf("%d.%06d\n", tv.tv_sec, tv.tv_usec);
    sleep(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    -0x14(%rbp),%rdi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    1201 <main+0xb1>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    0xe4e(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1198 <main+0x48>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %eax,0x14(%rsp)
mov    %rbx,%rdi
call   1040 <ctime@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0xe5e(%rip),%r14
mov    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe62(%rip),%r12
mov    $0x4,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe5e(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [26 x i8] c"sizeof(tv.tv_sec) = %d.\0A\00"
@.str.2 = [26 x i8] c"sizeof(tv.tv_usec) = %d.\0A\00"
@.str.3 = [9 x i8] c"%d.%06d\0A\00"
@cur_time = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32* %6)
store i32 %10, i32* %6
%11 = call i8* @ctime(i32* %6)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %8
br label %14
14: ; preds = %27, %2
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 4)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 4)
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %24)
%26 = call i32 @sleep(i32 1)
br label %27
27: ; preds = %17
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %14
30: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str.1 = [26 x i8] c"sizeof(tv.tv_sec) = %d.\0A\00"
@.str.2 = [26 x i8] c"sizeof(tv.tv_usec) = %d.\0A\00"
@.str.3 = [9 x i8] c"%d.%06d\0A\00"
@cur_time = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = bitcast i32* %3 to i8*
%6 = call i32 @time(i32* %3)
store i32 %6, i32* %3
%7 = call i8* @ctime(i32* %3)
%8 = call i32 @puts(i8* dereferenceable(1) %7)
%9 = bitcast %struct.timeval* %4 to i8*
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%12 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 4)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 4)
%15 = load i32, i32* %10
%16 = load i32, i32* %11
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16)
%18 = call i32 @sleep(i32 1)
%19 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 4)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 4)
%22 = load i32, i32* %10
%23 = load i32, i32* %11
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 @sleep(i32 1)
%26 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 4)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 4)
%29 = load i32, i32* %10
%30 = load i32, i32* %11
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %30)
%32 = call i32 @sleep(i32 1)
%33 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 4)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 4)
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %36, i32 %37)
%39 = call i32 @sleep(i32 1)
%40 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 4)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 4)
%43 = load i32, i32* %10
%44 = load i32, i32* %11
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %43, i32 %44)
%46 = call i32 @sleep(i32 1)
ret i32 0
}