#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 */
double atof(char *);
int calculate(double);
int /*<<< orphan*/ compute_time_and_flush();
int /*<<< orphan*/ set_file_log_path(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, double);
int /*<<< orphan*/ time_log_init(char *);
int /*<<< orphan*/ time_log_stop();
int main(int argc, char *argv[]) {
  int result;
  double weight;
  char tag_log[100];
  weight = atof(argv[1]);
  set_file_log_path("logs/serial_version.log");
  sprintf(tag_log, "input:%d, weight:%2.0f", 99999999, weight);
  time_log_init(tag_log);
  result = calculate(weight);
  time_log_stop();
  compute_time_and_flush();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe5e(%rip),%rdi
call   1080 <set_file_log_path@plt>
lea    -0x90(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe5e(%rip),%rsi
mov    $0x5f5e0ff,%edx
call   1070 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1090 <time_log_init@plt>
movsd  -0x20(%rbp),%xmm0
call   1050 <calculate@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <time_log_stop@plt>
mov    $0x0,%al
call   1030 <compute_time_and_flush@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    0x8(%rsi),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe72(%rip),%rdi
call   1080 <set_file_log_path@plt>
lea    0xe7e(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5f5e0ff,%edx
movsd  0x8(%rsp),%xmm0
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1090 <time_log_init@plt>
movsd  0x8(%rsp),%xmm0
call   1050 <calculate@plt>
xor    %eax,%eax
call   1060 <time_log_stop@plt>
xor    %eax,%eax
call   1030 <compute_time_and_flush@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"logs/serial_version.log\00"
@.str.1 = [23 x i8] c"input:%d, weight:%2.0f\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call double @atof(i8* %11)
store double %12, double* %7
%13 = call i32 @set_file_log_path(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%15 = load double, double* %7
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 99999999, double %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%18 = call i32 @time_log_init(i8* %17)
%19 = load double, double* %7
%20 = call i32 @calculate(double %19)
store i32 %20, i32* %6
%21 = call i32 (...) @time_log_stop()
%22 = call i32 (...) @compute_time_and_flush()
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"logs/serial_version.log\00"
@.str.1 = [23 x i8] c"input:%d, weight:%2.0f\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call double @atof(i8* %6)
%8 = tail call i32 @set_file_log_path(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 99999999, double %7)
%10 = call i32 @time_log_init(i8* %4)
%11 = call i32 @calculate(double %7)
%12 = call i32 (...) @time_log_stop()
%13 = call i32 (...) @compute_time_and_flush()
ret i32 0
}