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

/* Variables and functions */
char *ctime(char **);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *localtime(char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
char *time(int /*<<< orphan*/ *);
int main() {
  time_t hora = time(NULL);
  printf("Hora formato time: %ld\n", hora);
  printf("Hora formato legible: %s\n", ctime(&hora));
  int i = 0;
  int var = 1;
  struct timeval tim;
  gettimeofday(&tim, NULL);
  double t1 = tim.tv_sec + (tim.tv_usec / 1000000.0);
  for (i; i < 10000; i++) {
    var++;
  }
  gettimeofday(&tim, NULL);
  double t2 = tim.tv_sec + (tim.tv_usec / 1000000.0);
  printf("%.6lf seconds elapsed\n", t2 - t1);
  struct tm *local;
  local = localtime(&hora);
  printf("Estamos en el año %d\n", local->tm_year + 1900);
  char buf[25];
  strftime(buf, sizeof(buf), "Hoy es %A, %H:%M", local);
  printf("%s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe2b(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1206 <main+0xa6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e2 <main+0x82>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xddb(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
lea    0xdf7(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
add    $0x76c,%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0x19,%esi
lea    0xde3(%rip),%rdx
call   1080 <strftime@plt>
lea    -0x60(%rbp),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,0x18(%rsp)
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x18(%rsp),%r14
mov    %r14,%rdi
call   1050 <ctime@plt>
lea    0xe80(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
movsd  (%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
movapd (%rsp),%xmm0
movapd %xmm0,%xmm1
shufpd $0x1,0x20(%rsp),%xmm1
divpd  0xe0a(%rip),%xmm1
unpcklpd 0x30(%rsp),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    $0x76c,%esi
add    (%rax),%esi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe2f(%rip),%rdx
lea    0x40(%rsp),%r14
mov    %r14,%rdi
mov    $0x19,%esi
mov    %rbx,%rcx
call   1090 <strftime@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
%struct.tm = type { i32 }
@.str = [24 x i8] c"Hora formato time: %ld\0A\00"
@.str.1 = [26 x i8] c"Hora formato legible: %s\0A\00"
@.str.2 = [23 x i8] c"%.6lf seconds elapsed\0A\00"
@.str.3 = [23 x i8] c"Estamos en el a\C3\B1o %d\0A\00"
@.str.4 = [17 x i8] c"Hoy es %A, %H:%M\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca double
%7 = alloca double
%8 = alloca %struct.tm*
%9 = alloca [25 x i8]
store i32 0, i32* %1
%10 = call i8* @time(i32* null)
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i8* @ctime(i8** %2)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 0, i32* %3
store i32 1, i32* %4
%15 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%17 = load double, double* %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%19 = load double, double* %18
%20 = fdiv double %19, 1.000000e+06
%21 = fadd double %17, %20
store double %21, double* %6
%22 = load i32, i32* %3
br label %23
23: ; preds = %29, %0
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 10000
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %29
29: ; preds = %26
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %23
32: ; preds = %23
%33 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%35 = load double, double* %34
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%37 = load double, double* %36
%38 = fdiv double %37, 1.000000e+06
%39 = fadd double %35, %38
store double %39, double* %7
%40 = load double, double* %7
%41 = load double, double* %6
%42 = fsub double %40, %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %42)
%44 = call %struct.tm* @localtime(i8** %2)
store %struct.tm* %44, %struct.tm** %8
%45 = load %struct.tm*, %struct.tm** %8
%46 = getelementptr inbounds %struct.tm, %struct.tm* %45, i32 0, i32 0
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1900
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%51 = load %struct.tm*, %struct.tm** %8
%52 = call i32 @strftime(i8* %50, i32 25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %51)
%53 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %53)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
%struct.tm = type { i32 }
@.str = [24 x i8] c"Hora formato time: %ld\0A\00"
@.str.1 = [26 x i8] c"Hora formato legible: %s\0A\00"
@.str.2 = [23 x i8] c"%.6lf seconds elapsed\0A\00"
@.str.3 = [23 x i8] c"Estamos en el a\C3\B1o %d\0A\00"
@.str.4 = [17 x i8] c"Hoy es %A, %H:%M\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca <2 x double>
%3 = bitcast <2 x double>* %2 to %struct.timeval*
%4 = alloca [25 x i8]
%5 = bitcast i8** %1 to i8*
%6 = tail call i8* @time(i32* null)
store i8* %6, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i8* @ctime(i8** %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = bitcast <2 x double>* %2 to i8*
%11 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%12 = getelementptr inbounds <2 x double>, <2 x double>* %2, i64 0, i64 0
%13 = load double, double* %12
%14 = getelementptr inbounds <2 x double>, <2 x double>* %2, i64 0, i64 1
%15 = load double, double* %14
%16 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%17 = load <2 x double>, <2 x double>* %2
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%19 = insertelement <2 x double> %18, double %15, i64 1
%20 = fdiv <2 x double> %19, <double 1.000000e+06, double 1.000000e+06>
%21 = insertelement <2 x double> %17, double %13, i64 1
%22 = fadd <2 x double> %21, %20
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%24 = fsub <2 x double> %22, %23
%25 = extractelement <2 x double> %24, i64 0
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = call %struct.tm* @localtime(i8** %1)
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i64 0, i32 0
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1900
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%33 = call i32 @strftime(i8* %32, i32 25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %27)
%34 = call i32 @puts(i8* %32)
ret i32 0
}