#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 char *time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
char *asctime(struct tm *);
struct tm *localtime(char **);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
char *time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  time_t now;
  char *buf;
  struct tm *tmnow;
  while (1) {
    now = time(NULL);
    printf("time: %lu\n", now);
    tmnow = localtime(&now);
    buf = asctime(tmnow);
    printf("asctime: %s\n", buf);
    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)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <asctime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe63(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    1166 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe9f(%rip),%rbx
nopl   0x0(%rax)
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    %rax,%rdi
call   1040 <asctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    1170 <main+0x20>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [11 x i8] c"time: %lu\0A\00"
@.str.1 = [13 x i8] c"asctime: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %2, %9
%10 = call i8* @time(i32* null)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call %struct.tm* @localtime(i8** %6)
store %struct.tm* %13, %struct.tm** %8
%14 = load %struct.tm*, %struct.tm** %8
%15 = call i8* @asctime(%struct.tm* %14)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @sleep(i32 1)
br label %9
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [11 x i8] c"time: %lu\0A\00"
@.str.1 = [13 x i8] c"asctime: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = call i8* @time(i32* null)
store i8* %6, i8** %3
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call %struct.tm* @localtime(i8** %3)
%9 = call i8* @asctime(%struct.tm* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @sleep(i32 1)
br label %5
}