#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 scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int EXIT_SUCCESS;
scalar_t__ clock();
int /*<<< orphan*/ make_hex_string_learning(long, char *);
int /*<<< orphan*/ num_hex_digits(long);
int /*<<< orphan*/ pow(double, double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ sprintf(char **, char *, long);
int /*<<< orphan*/ sqrt(double);
int /*<<< orphan*/ strcat(char **, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char toupper(char);
int main(int argc, char **argv) {
  clock_t begin = clock();
  char str[50000];
  strcpy(str, "");
  for (long i = 0; i < 50000000L; i++) {
    sqrt((double)i);
    pow((double)i, 2.56);
    long j = i * 745L;
    char string[80];
    sprintf(&string, "%ld", i);
    strcat(&string, " kaka pipi");
    int ij = 0;
    while (string[ij]) {
      string[ij] = toupper(string[ij]);
      ij++;
    }
    if (i % 300 == 0) {
      strcpy(str, "");
    } else {
      char tmp[num_hex_digits(i) + 1];
      make_hex_string_learning(i, tmp);
      strcat(&str, tmp);
    }
  }
  clock_t end = clock();
  double timetocalc = ((double)(end - begin) / CLOCKS_PER_SEC) * 1000;
  printf("timetocalc(msec): %f\n", timetocalc);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc400,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0x18(%rbp)
lea    -0xc370(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcpy@plt>
movq   $0x0,-0xc378(%rbp)
cmpq   $0x2faf080,-0xc378(%rbp)
80 f0 fa 02
jge    1360 <main+0x1c0>
cvtsi2sdq -0xc378(%rbp),%xmm0
ff ff
call   10a0 <sqrt@plt>
cvtsi2sdq -0xc378(%rbp),%xmm0
ff ff
movsd  0xdf6(%rip),%xmm1
call   1080 <pow@plt>
imul   $0x2e9,-0xc378(%rbp),%rax
mov    %rax,-0xc380(%rbp)
lea    -0xc3d0(%rbp),%rdi
mov    -0xc378(%rbp),%rdx
lea    0xdd2(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0xc3d0(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   10b0 <strcat@plt>
movl   $0x0,-0xc3d4(%rbp)
movslq -0xc3d4(%rbp),%rax
cmpb   $0x0,-0xc3d0(%rbp,%rax,1)
je     12ad <main+0x10d>
movslq -0xc3d4(%rbp),%rax
movsbl -0xc3d0(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
mov    %al,%cl
movslq -0xc3d4(%rbp),%rax
mov    %cl,-0xc3d0(%rbp,%rax,1)
mov    -0xc3d4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3d4(%rbp)
jmp    1260 <main+0xc0>
mov    -0xc378(%rbp),%rax
mov    $0x12c,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    12e0 <main+0x140>
lea    -0xc370(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1344 <main+0x1a4>
mov    -0xc378(%rbp),%rdi
call   1070 <num_hex_digits@plt>
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0xc3e0(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0xc400(%rbp)
mov    %rsi,%rsp
mov    %rax,-0xc3e8(%rbp)
mov    -0xc378(%rbp),%rdi
call   1090 <make_hex_string_learning@plt>
mov    -0xc400(%rbp),%rsi
lea    -0xc370(%rbp),%rdi
call   10b0 <strcat@plt>
mov    -0xc3e0(%rbp),%rax
mov    %rax,%rsp
jmp    1349 <main+0x1a9>
mov    -0xc378(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xc378(%rbp)
jmp    11e2 <main+0x42>
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0xc3f0(%rbp)
mov    -0xc3f0(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2c63(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xc6f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xc3f8(%rbp)
ff
movsd  -0xc3f8(%rbp),%xmm0
ff
lea    0xc73(%rip),%rdi
call   1060 <printf@plt>
mov    0x2c20(%rip),%rax
mov    (%rax),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc3b8,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,-0x30(%rbp)
lea    0xe6b(%rip),%rsi
lea    -0xc3e0(%rbp),%rdi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%r14
movabs $0xda740da740da74,%r13
jmp    123d <main+0x9d>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1070 <num_hex_digits@plt>
mov    %rsp,%rbx
add    $0x1,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r15,%rdi
mov    %r12,%rsi
call   1090 <make_hex_string_learning@plt>
lea    -0xc3e0(%rbp),%rdi
mov    %r12,%rsi
call   10b0 <strcat@plt>
mov    %rbx,%rsp
add    $0x1,%r15
cmp    $0x2faf080,%r15
je     12ec <main+0x14c>
xorps  %xmm0,%xmm0
cvtsi2sd %r15,%xmm0
movsd  %xmm0,-0x38(%rbp)
call   10a0 <sqrt@plt>
movsd  -0x38(%rbp),%xmm0
movsd  0xda4(%rip),%xmm1
call   1080 <pow@plt>
mov    %r14,%rdi
lea    0xda5(%rip),%rsi
mov    %r15,%rdx
call   10c0 <sprintf@plt>
mov    %r14,%rdi
lea    0xd97(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x90(%rbp),%al
test   %al,%al
je     12b6 <main+0x116>
lea    -0x8f(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    12a0 <main+0x100>
mov    %r15,%rax
movabs $0x2fc962fc962fc963,%rcx
62 c9 2f
imul   %rcx,%rax
ror    $0x2,%rax
cmp    %r13,%rax
ja     11f0 <main+0x50>
lea    -0xc3e0(%rbp),%rdi
lea    0xd52(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <main+0x8c>
xor    %eax,%eax
call   1050 <clock@plt>
sub    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2ce2(%rip),%rax
divsd  (%rax),%xmm0
mulsd  0xcf6(%rip),%xmm0
lea    0xd06(%rip),%rdi
call   1060 <printf@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [11 x i8] c" kaka pipi\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [22 x i8] c"timetocalc(msec): %f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [50000 x i8]
%8 = alloca i64
%9 = alloca i64
%10 = alloca [80 x i8]
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = call i64 (...) @clock()
store i64 %16, i64* %6
%17 = getelementptr inbounds [50000 x i8], [50000 x i8]* %7, i64 0, i64 0
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %8
br label %19
19: ; preds = %73, %2
%20 = load i64, i64* %8
%21 = icmp slt i64 %20, 50000000
br i1 %21, label %22, label %76
22: ; preds = %19
%23 = load i64, i64* %8
%24 = sitofp i64 %23 to double
%25 = call i32 @sqrt(double %24)
%26 = load i64, i64* %8
%27 = sitofp i64 %26 to double
%28 = call i32 @pow(double %27, double 2.560000e+00)
%29 = load i64, i64* %8
%30 = mul nsw i64 %29, 745
store i64 %30, i64* %9
%31 = bitcast [80 x i8]* %10 to i8**
%32 = load i64, i64* %8
%33 = call i32 @sprintf(i8** %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %32)
%34 = bitcast [80 x i8]* %10 to i8**
%35 = call i32 @strcat(i8** %34, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %11
br label %36
36: ; preds = %42, %22
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %42, label %53
42: ; preds = %36
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = call signext i8 @toupper(i8 signext %46)
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 %49
store i8 %47, i8* %50
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
br label %36
53: ; preds = %36
%54 = load i64, i64* %8
%55 = srem i64 %54, 300
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = getelementptr inbounds [50000 x i8], [50000 x i8]* %7, i64 0, i64 0
%59 = call i32 @strcpy(i8* %58, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %72
60: ; preds = %53
%61 = load i64, i64* %8
%62 = call i32 @num_hex_digits(i64 %61)
%63 = add nsw i32 %62, 1
%64 = zext i32 %63 to i64
%65 = call i8* @llvm.stacksave()
store i8* %65, i8** %12
%66 = alloca i8, i64 %64
store i64 %64, i64* %13
%67 = load i64, i64* %8
%68 = call i32 @make_hex_string_learning(i64 %67, i8* %66)
%69 = bitcast [50000 x i8]* %7 to i8**
%70 = call i32 @strcat(i8** %69, i8* %66)
%71 = load i8*, i8** %12
br label %72
72: ; preds = %60, %57
br label %73
73: ; preds = %72
%74 = load i64, i64* %8
%75 = add nsw i64 %74, 1
store i64 %75, i64* %8
br label %19
76: ; preds = %19
%77 = call i64 (...) @clock()
store i64 %77, i64* %14
%78 = load i64, i64* %14
%79 = load i64, i64* %6
%80 = sub nsw i64 %78, %79
%81 = sitofp i64 %80 to double
%82 = load double, double* @CLOCKS_PER_SEC
%83 = fdiv double %81, %82
%84 = fmul double %83, 1.000000e+03
store double %84, double* %15
%85 = load double, double* %15
%86 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %85)
%87 = load i32, i32* @EXIT_SUCCESS
ret i32 %87
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [11 x i8] c" kaka pipi\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.3 = [22 x i8] c"timetocalc(msec): %f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50000 x i8]
%4 = alloca [80 x i8]
%5 = tail call i64 (...) @clock()
%6 = getelementptr inbounds [50000 x i8], [50000 x i8]* %3, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%9 = bitcast [80 x i8]* %4 to i8**
%10 = bitcast [50000 x i8]* %3 to i8**
br label %20
11: ; preds = %51
%12 = call i64 (...) @clock()
%13 = sub nsw i64 %12, %5
%14 = sitofp i64 %13 to double
%15 = load double, double* @CLOCKS_PER_SEC
%16 = fdiv double %14, %15
%17 = fmul double %16, 1.000000e+03
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %17)
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
20: ; preds = %2, %51
%21 = phi i64 [ 0, %2 ], [ %52, %51 ]
%22 = sitofp i64 %21 to double
%23 = call i32 @sqrt(double %22)
%24 = call i32 @pow(double %22, double 2.560000e+00)
%25 = call i32 @sprintf(i8** %9, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %21)
%26 = call i32 @strcat(i8** %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%27 = load i8, i8* %8
%28 = icmp eq i8 %27, 0
br i1 %28, label %38, label %29
29: ; preds = %20, %29
%30 = phi i64 [ %34, %29 ], [ 0, %20 ]
%31 = phi i8 [ %36, %29 ], [ %27, %20 ]
%32 = phi i8* [ %35, %29 ], [ %8, %20 ]
%33 = call signext i8 @toupper(i8 signext %31)
store i8 %33, i8* %32
%34 = add nuw i64 %30, 1
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %38, label %29
38: ; preds = %29, %20
%39 = urem i64 %21, 300
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %51
43: ; preds = %38
%44 = call i32 @num_hex_digits(i64 %21)
%45 = add nsw i32 %44, 1
%46 = zext i32 %45 to i64
%47 = call i8* @llvm.stacksave()
%48 = alloca i8, i64 %46
%49 = call i32 @make_hex_string_learning(i64 %21, i8* %48)
%50 = call i32 @strcat(i8** %10, i8* %48)
br label %51
51: ; preds = %43, %41
%52 = add nuw nsw i64 %21, 1
%53 = icmp eq i64 %52, 50000000
br i1 %53, label %11, label %20
}