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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i;
  time_t curTime;
  for (i = 0; i < 10; i++) {
    curTime = time(NULL);
    printf("Hello, world. The current time is: %s", ctime(&curTime));
    sleep(i);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    119a <main+0x5a>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1030 <ctime@plt>
lea    0xe9d(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x3,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x4,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x6,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x7,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x8,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    $0x9,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Hello, world. The current time is: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = call i32 @time(i32* null)
store i32 %8, i32* %3
%9 = call i8* @ctime(i32* %3)
%10 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %2
%12 = call i32 @sleep(i32 %11)
br label %13
13: ; preds = %7
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %4
16: ; preds = %4
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [38 x i8] c"Hello, world. The current time is: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call i8* @ctime(i32* %1)
%5 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @sleep(i32 0)
%7 = call i32 @time(i32* null)
store i32 %7, i32* %1
%8 = call i8* @ctime(i32* %1)
%9 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @sleep(i32 1)
%11 = call i32 @time(i32* null)
store i32 %11, i32* %1
%12 = call i8* @ctime(i32* %1)
%13 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @sleep(i32 2)
%15 = call i32 @time(i32* null)
store i32 %15, i32* %1
%16 = call i8* @ctime(i32* %1)
%17 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @sleep(i32 3)
%19 = call i32 @time(i32* null)
store i32 %19, i32* %1
%20 = call i8* @ctime(i32* %1)
%21 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @sleep(i32 4)
%23 = call i32 @time(i32* null)
store i32 %23, i32* %1
%24 = call i8* @ctime(i32* %1)
%25 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @sleep(i32 5)
%27 = call i32 @time(i32* null)
store i32 %27, i32* %1
%28 = call i8* @ctime(i32* %1)
%29 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = call i32 @sleep(i32 6)
%31 = call i32 @time(i32* null)
store i32 %31, i32* %1
%32 = call i8* @ctime(i32* %1)
%33 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = call i32 @sleep(i32 7)
%35 = call i32 @time(i32* null)
store i32 %35, i32* %1
%36 = call i8* @ctime(i32* %1)
%37 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = call i32 @sleep(i32 8)
%39 = call i32 @time(i32* null)
store i32 %39, i32* %1
%40 = call i8* @ctime(i32* %1)
%41 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = call i32 @sleep(i32 9)
ret i32 0
}