#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 */

/* Variables and functions */
char *b_sprinft(char *);
char *b_strftime(char *);
double get_cpu_time();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  int count = 1 << 16;
  char buf[20];
  double start_time, end_time;
  start_time = get_cpu_time();
  for (i = 0; i < count; i++) {
    b_sprinft(buf);
  }
  end_time = get_cpu_time();
  printf("sprinft:\t%f\n", end_time - start_time);
  start_time = get_cpu_time();
  for (i = 0; i < count; i++) {
    b_strftime(buf);
  }
  end_time = get_cpu_time();
  printf("strftime:\t%f\n", end_time - start_time);
  printf("sprinft:\t%s\n", b_sprinft(buf));
  printf("strftime:\t%s\n", b_strftime(buf));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x10000,-0xc(%rbp)
mov    $0x0,%al
call   1060 <get_cpu_time@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118c <main+0x4c>
lea    -0x20(%rbp),%rdi
call   1050 <b_sprinft@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x29>
mov    $0x0,%al
call   1060 <get_cpu_time@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <get_cpu_time@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e6 <main+0xa6>
lea    -0x20(%rbp),%rdi
call   1030 <b_strftime@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <main+0x83>
mov    $0x0,%al
call   1060 <get_cpu_time@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
lea    0xe0a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <b_sprinft@plt>
mov    %rax,%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <b_strftime@plt>
mov    %rax,%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1060 <get_cpu_time@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x10000,%ebp
lea    0x10(%rsp),%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <b_sprinft@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x20>
xor    %eax,%eax
call   1060 <get_cpu_time@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <get_cpu_time@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x10000,%ebp
lea    0x10(%rsp),%rbx
nop
mov    %rbx,%rdi
call   1030 <b_strftime@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x60>
xor    %eax,%eax
call   1060 <get_cpu_time@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <b_sprinft@plt>
lea    0xe3f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <b_strftime@plt>
lea    0xe33(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"sprinft:\09%f\0A\00"
@.str.1 = [14 x i8] c"strftime:\09%f\0A\00"
@.str.2 = [13 x i8] c"sprinft:\09%s\0A\00"
@.str.3 = [14 x i8] c"strftime:\09%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
store i32 65536, i32* %3
%7 = call double (...) @get_cpu_time()
store double %7, double* %5
store i32 0, i32* %2
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%14 = call i8* @b_sprinft(i8* %13)
br label %15
15: ; preds = %12
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %8
18: ; preds = %8
%19 = call double (...) @get_cpu_time()
store double %19, double* %6
%20 = load double, double* %6
%21 = load double, double* %5
%22 = fsub double %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %22)
%24 = call double (...) @get_cpu_time()
store double %24, double* %5
store i32 0, i32* %2
br label %25
25: ; preds = %32, %18
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%31 = call i8* @b_strftime(i8* %30)
br label %32
32: ; preds = %29
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %25
35: ; preds = %25
%36 = call double (...) @get_cpu_time()
store double %36, double* %6
%37 = load double, double* %6
%38 = load double, double* %5
%39 = fsub double %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %39)
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%42 = call i8* @b_sprinft(i8* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%45 = call i8* @b_strftime(i8* %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"sprinft:\09%f\0A\00"
@.str.1 = [14 x i8] c"strftime:\09%f\0A\00"
@.str.2 = [13 x i8] c"sprinft:\09%s\0A\00"
@.str.3 = [14 x i8] c"strftime:\09%s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call double (...) @get_cpu_time()
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %7, %4 ]
%6 = call i8* @b_sprinft(i8* %2)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 65536
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = call double (...) @get_cpu_time()
%11 = fsub double %10, %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %11)
%13 = call double (...) @get_cpu_time()
br label %14
14: ; preds = %9, %14
%15 = phi i32 [ 0, %9 ], [ %17, %14 ]
%16 = call i8* @b_strftime(i8* %2)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, 65536
br i1 %18, label %19, label %14
19: ; preds = %14
%20 = call double (...) @get_cpu_time()
%21 = fsub double %20, %13
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = call i8* @b_sprinft(i8* %2)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = call i8* @b_strftime(i8* %2)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %25)
ret i32 0
}