#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 timeval {
  double tv_sec;
  double tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double);
scalar_t__ strlen(char *);
int main(int argc, char const *argv[]) {
  char *s = (char *)malloc(sizeof(char) * (1 << 30));
  size_t size = 1;
  struct timeval t1, t2;
  for (int t = 0; t < 30; t++) {
    for (size_t i = 0; i < size; i++) {
      s[i] = 1;
    }
    s[size] = 0;
    gettimeofday(&t1, NULL);
    printf("%llu : ", (unsigned long long)size);
    printf("%llu\n", (unsigned long long)strlen(s));
    gettimeofday(&t2, NULL);
    printf("%.3f\n", (t2.tv_sec * 1000.0 - t1.tv_sec * 1000.0 +
                      t2.tv_usec / 1000.0 - t1.tv_usec / 1000.0));
    size <<= 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x40000000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x1e,-0x44(%rbp)
jge    12cf <main+0x18f>
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11b0 <main+0x70>
mov    -0x18(%rbp),%rax
mov    -0x50(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1185 <main+0x45>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
mov    %eax,%esi
lea    -0x30(%rbp),%rdi
call   1050 <gettimeofday@plt>
movq   -0x20(%rbp),%xmm0
movaps 0xe3b(%rip),%xmm1
movaps %xmm1,-0x70(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xe3b(%rip),%xmm1
movaps %xmm1,-0x60(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
movaps -0x70(%rbp),%xmm2
movaps -0x60(%rbp),%xmm1
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x40(%rbp),%xmm0
movsd  0xdad(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd89(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  0xd74(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xd5f(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
lea    0xd8e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1173 <main+0x33>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x40000000,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x1,%ebx
mov    $0x1e,%r12d
lea    0xecb(%rip),%r13
mov    %rsp,%rbp
lea    0xec7(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1060 <memset@plt>
movb   $0x0,(%r14,%rbx,1)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movq   %rbx,%xmm1
movdqa 0xe42(%rip),%xmm0
punpckldq %xmm0,%xmm1
movapd 0xe46(%rip),%xmm0
subpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
movq   %rax,%xmm1
punpckldq 0xe05(%rip),%xmm1
subpd  0xe0d(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  0x18(%rsp),%xmm1
mulsd  0xe01(%rip),%xmm1
movsd  (%rsp),%xmm0
mulsd  0xdfc(%rip),%xmm0
addsd  %xmm1,%xmm0
movapd (%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
shufpd $0x1,%xmm2,%xmm1
divpd  0xdc8(%rip),%xmm1
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
subsd  %xmm1,%xmm0
mov    %r15,%rdi
call   1040 <printf@plt>
add    %rbx,%rbx
add    $0xffffffff,%r12d
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [8 x i8] c"%llu : \00"
@.str.1 = [6 x i8] c"%llu\0A\00"
@.str.2 = [6 x i8] c"%.3f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca i32
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i64 @malloc(i32 1073741824)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %6
store i64 1, i64* %7
store i32 0, i32* %10
br label %14
14: ; preds = %60, %2
%15 = load i32, i32* %10
%16 = icmp slt i32 %15, 30
br i1 %16, label %17, label %63
17: ; preds = %14
store i64 0, i64* %11
br label %18
18: ; preds = %26, %17
%19 = load i64, i64* %11
%20 = load i64, i64* %7
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = load i64, i64* %11
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8 1, i8* %25
br label %26
26: ; preds = %22
%27 = load i64, i64* %11
%28 = add i64 %27, 1
store i64 %28, i64* %11
br label %18
29: ; preds = %18
%30 = load i8*, i8** %6
%31 = load i64, i64* %7
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8 0, i8* %32
%33 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%34 = load i64, i64* %7
%35 = uitofp i64 %34 to double
%36 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %35)
%37 = load i8*, i8** %6
%38 = call i64 @strlen(i8* %37)
%39 = uitofp i64 %38 to double
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %39)
%41 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%43 = load double, double* %42
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%45 = load double, double* %44
%46 = fmul double %45, 1.000000e+03
%47 = fneg double %46
%48 = call double @llvm.fmuladd.f64(double %43, double 1.000000e+03, double %47)
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%50 = load double, double* %49
%51 = fdiv double %50, 1.000000e+03
%52 = fadd double %48, %51
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%54 = load double, double* %53
%55 = fdiv double %54, 1.000000e+03
%56 = fsub double %52, %55
%57 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %56)
%58 = load i64, i64* %7
%59 = shl i64 %58, 1
store i64 %59, i64* %7
br label %60
60: ; preds = %29
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
store i32 %62, i32* %10
br label %14
63: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [8 x i8] c"%llu : \00"
@.str.1 = [6 x i8] c"%llu\0A\00"
@.str.2 = [6 x i8] c"%.3f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca <2 x double>
%5 = bitcast <2 x double>* %4 to %struct.timeval*
%6 = tail call i64 @malloc(i32 1073741824)
%7 = inttoptr i64 %6 to i8*
%8 = bitcast %struct.timeval* %3 to i8*
%9 = bitcast <2 x double>* %4 to i8*
%10 = getelementptr inbounds <2 x double>, <2 x double>* %4, i64 0, i64 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
br label %14
13: ; preds = %14
ret i32 0
14: ; preds = %2, %14
%15 = phi i32 [ 0, %2 ], [ %40, %14 ]
%16 = phi i64 [ 1, %2 ], [ %39, %14 ]
%17 = getelementptr inbounds i8, i8* %7, i64 %16
store i8 0, i8* %17
%18 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%19 = uitofp i64 %16 to double
%20 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %19)
%21 = tail call i64 @strlen(i8* dereferenceable(1) %7)
%22 = uitofp i64 %21 to double
%23 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%25 = load double, double* %10
%26 = load double, double* %11
%27 = fmul double %26, -1.000000e+03
%28 = tail call double @llvm.fmuladd.f64(double %25, double 1.000000e+03, double %27)
%29 = load <2 x double>, <2 x double>* %4
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%31 = load double, double* %12
%32 = insertelement <2 x double> %30, double %31, i64 1
%33 = fdiv <2 x double> %32, <double 1.000000e+03, double 1.000000e+03>
%34 = extractelement <2 x double> %33, i64 0
%35 = fadd double %28, %34
%36 = extractelement <2 x double> %33, i64 1
%37 = fsub double %35, %36
%38 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = shl i64 %16, 1
%40 = add nuw nsw i32 %15, 1
%41 = icmp eq i32 %40, 30
br i1 %41, label %13, label %14
}