#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 */
struct tm {
  int dummy;
};
struct timeval {
  scalar_t__ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int calc_speed(struct timeval const *, struct timeval const *, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
void printf_benchmark_result(const struct timeval *start,
                             const struct timeval *stop, double count) {
  struct tm begin_tm, end_tm;
  char time_buf[32];
  fprintf(stdout, "------------------------------------------------------------"
                  "-------------------------\n");
  fprintf(stdout, "|         start time         |         stop time          | "
                  "     average speed      |\n");
  fprintf(stdout, "|----------------------------|----------------------------|-"
                  "------------------------|\n");
  fprintf(stdout, "| ");
  localtime_r(&start->tv_sec, &begin_tm);
  strftime(time_buf, 32, "%Y-%m-%d %T", &begin_tm);
  fprintf(stdout, "%s.%06d", time_buf, (int)(start->tv_usec));
  fprintf(stdout, " | ");
  localtime_r(&stop->tv_sec, &end_tm);
  strftime(time_buf, 32, "%Y-%m-%d %T", &end_tm);
  fprintf(stdout, "%s.%06d", time_buf, (int)(stop->tv_usec));
  fprintf(stdout, " | ");
  fprintf(stdout, "   %07d logs/secs    |\n", calc_speed(start, stop, count));
  fprintf(stdout, "------------------------------------------------------------"
                  "-------------------------\n");
}


x86 assembly (clang, -O0):
<printf_benchmark_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xedb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xf1b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xf70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
lea    -0x20(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x50(%rbp),%rdi
mov    $0x20,%esi
lea    0xf33(%rip),%rdx
lea    -0x20(%rbp),%rcx
call   1060 <strftime@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%ecx
lea    0xf19(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xf0a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
lea    -0x28(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x50(%rbp),%rdi
mov    $0x20,%esi
lea    0xece(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   1060 <strftime@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%ecx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
call   1050 <calc_speed@plt>
mov    -0x54(%rbp),%edi
mov    %eax,%edx
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_benchmark_result>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x2e7f(%rip),%r14
mov    (%r14),%edi
lea    0xe95(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xedb(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xf21(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xf7c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0x8(%r12),%rdi
lea    0x18(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <localtime_r@plt>
lea    0xf47(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %rbp,%rcx
call   1060 <strftime@plt>
mov    (%r14),%edi
mov    (%r12),%ecx
lea    0xf30(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xf24(%rip),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0x8(%r15),%rdi
lea    0x10(%rsp),%r13
mov    %r13,%rsi
call   1030 <localtime_r@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
lea    0xee6(%rip),%rdx
mov    %r13,%rcx
call   1060 <strftime@plt>
mov    (%r14),%edi
mov    (%r15),%ecx
lea    0xedd(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%ebx
mov    %r12,%rdi
mov    %r15,%rsi
movsd  0x8(%rsp),%xmm0
call   1050 <calc_speed@plt>
lea    0xeb7(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xd85(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32 }
@stdout = global i32 0
@.str = [87 x i8] c"-------------------------------------------------------------------------------------\0A\00"
@.str.1 = [87 x i8] c"| start time | stop time | average speed |\0A\00"
@.str.2 = [87 x i8] c"|----------------------------|----------------------------|-------------------------|\0A\00"
@.str.3 = [3 x i8] c"| \00"
@.str.4 = [12 x i8] c"%Y-%m-%d %T\00"
@.str.5 = [8 x i8] c"%s.%06d\00"
@.str.6 = [4 x i8] c" | \00"
@.str.7 = [24 x i8] c" %07d logs/secs |\0A\00"
define void @printf_benchmark_result(%struct.timeval* %0, %struct.timeval* %1, double %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca double
%7 = alloca %struct.tm
%8 = alloca %struct.tm
%9 = alloca [32 x i8]
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store double %2, double* %6
%10 = load i32, i32* @stdout
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stdout
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = load %struct.timeval*, %struct.timeval** %4
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%20 = call i32 @localtime_r(i32* %19, %struct.tm* %7)
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%22 = call i32 @strftime(i8* %21, i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %7)
%23 = load i32, i32* @stdout
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%25 = load %struct.timeval*, %struct.timeval** %4
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i32
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %24, i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%32 = load %struct.timeval*, %struct.timeval** %5
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 1
%34 = call i32 @localtime_r(i32* %33, %struct.tm* %8)
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%36 = call i32 @strftime(i8* %35, i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %8)
%37 = load i32, i32* @stdout
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%39 = load %struct.timeval*, %struct.timeval** %5
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = trunc i64 %41 to i32
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %38, i32 %42)
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%46 = load i32, i32* @stdout
%47 = load %struct.timeval*, %struct.timeval** %4
%48 = load %struct.timeval*, %struct.timeval** %5
%49 = load double, double* %6
%50 = call i32 @calc_speed(%struct.timeval* %47, %struct.timeval* %48, double %49)
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @stdout
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32 }
@stdout = global i32 0
@.str = [87 x i8] c"-------------------------------------------------------------------------------------\0A\00"
@.str.1 = [87 x i8] c"| start time | stop time | average speed |\0A\00"
@.str.2 = [87 x i8] c"|----------------------------|----------------------------|-------------------------|\0A\00"
@.str.3 = [3 x i8] c"| \00"
@.str.4 = [12 x i8] c"%Y-%m-%d %T\00"
@.str.5 = [8 x i8] c"%s.%06d\00"
@.str.6 = [4 x i8] c" | \00"
@.str.7 = [24 x i8] c" %07d logs/secs |\0A\00"
define void @printf_benchmark_result(%struct.timeval* %0, %struct.timeval* %1, double %2) {
%4 = alloca %struct.tm
%5 = alloca %struct.tm
%6 = alloca [32 x i8]
%7 = bitcast %struct.tm* %4 to i8*
%8 = bitcast %struct.tm* %5 to i8*
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* @stdout
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stdout
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%19 = call i32 @localtime_r(i32* %18, %struct.tm* %4)
%20 = call i32 @strftime(i8* %9, i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %4)
%21 = load i32, i32* @stdout
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %9, i32 %24)
%26 = load i32, i32* @stdout
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%29 = call i32 @localtime_r(i32* %28, %struct.tm* %5)
%30 = call i32 @strftime(i8* %9, i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %5)
%31 = load i32, i32* @stdout
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i32
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %9, i32 %34)
%36 = load i32, i32* @stdout
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%38 = load i32, i32* @stdout
%39 = call i32 @calc_speed(%struct.timeval* %0, %struct.timeval* %1, double %2)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @stdout
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
ret void
}