#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 int /*<<< orphan*/ sizes;
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, int, double);
int main(int argc, char **argv) {
  unsigned int meow = 256 * 1024 * 1024;
  static int arr[4 * 1024 * 1024];
  int lengthMod;
  unsigned int i;
  double timeTaken;
  clock_t start;
  int sizes[] = {
      1 * 1024,          4 * 1024,        8 * 1024,          16 * 1024,
      32 * 1024,         64 * 1024,       128 * 1024,        256 * 1024,
      512 * 1024,        1 * 1024 * 1024, 1.5 * 1024 * 1024, 2 * 1024 * 1024,
      2.5 * 1024 * 1024, 3 * 1024 * 1024, 3.5 * 1024 * 1024, 4 * 1024 * 1024};
  int results[sizeof(sizes) / sizeof(int)];
  int s;
  for (s = 0; s < sizeof(sizes) / sizeof(int); s++) {
    lengthMod = sizes[s] - 1;
    start = clock();
    for (i = 0; i < meow; i++) {
      arr[(i * 16) & lengthMod] *= 10;
      arr[(i * 16) & lengthMod] /= 10;
    }
    timeTaken = (double)(clock() - start) / CLOCKS_PER_SEC;
    printf("%d, %.8f \n", sizes[s] / 1024, timeTaken);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x10000000,-0x14(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xea5(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0xb4(%rbp)
movslq -0xb4(%rbp),%rax
cmp    $0x10,%rax
jae    1264 <main+0x134>
movslq -0xb4(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    120a <main+0xda>
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
and    -0x18(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2e8d(%rip),%rax
imul   $0xa,(%rax,%rcx,4),%edx
lea    0x2e82(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
and    -0x18(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2e6b(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    %eax,%edx
lea    0x2e57(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <main+0x73>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2dc7(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movslq -0xb4(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movsd  -0x28(%rbp),%xmm0
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    116f <main+0x3f>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xed0(%rip),%r15
mov    0x2eb1(%rip),%r12
lea    0xf02(%rip),%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r13,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r12),%xmm0
mov    (%rbx,%r15,1),%eax
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0xa,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x4,%rbx
cmp    $0x40,%rbx
jne    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.arr = internal global [4194304 x i32] zeroinitializer
@__const.main.sizes = [16 x i32] [i32 1024, i32 4096, i32 8192, i32 16384, i32 32768, i32 65536, i32 131072, i32 262144, i32 524288, i32 1048576, i32 1572864, i32 2097152, i32 2621440, i32 3145728, i32 3670016, i32 4194304]
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [11 x i8] c"%d, %.8f \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i64
%11 = alloca [16 x i32]
%12 = alloca [16 x i32]
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 268435456, i32* %6
%14 = bitcast [16 x i32]* %11 to i8*
store i32 0, i32* %13
br label %15
15: ; preds = %64, %2
%16 = load i32, i32* %13
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %17, 16
br i1 %18, label %19, label %67
19: ; preds = %15
%20 = load i32, i32* %13
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %7
%25 = call i64 (...) @clock()
store i64 %25, i64* %10
store i32 0, i32* %8
br label %26
26: ; preds = %47, %19
%27 = load i32, i32* %8
%28 = load i32, i32* %6
%29 = icmp ult i32 %27, %28
br i1 %29, label %30, label %50
30: ; preds = %26
%31 = load i32, i32* %8
%32 = mul i32 %31, 16
%33 = load i32, i32* %7
%34 = and i32 %32, %33
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [4194304 x i32], [4194304 x i32]* @main.arr, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = mul nsw i32 %37, 10
store i32 %38, i32* %36
%39 = load i32, i32* %8
%40 = mul i32 %39, 16
%41 = load i32, i32* %7
%42 = and i32 %40, %41
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds [4194304 x i32], [4194304 x i32]* @main.arr, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = sdiv i32 %45, 10
store i32 %46, i32* %44
br label %47
47: ; preds = %30
%48 = load i32, i32* %8
%49 = add i32 %48, 1
store i32 %49, i32* %8
br label %26
50: ; preds = %26
%51 = call i64 (...) @clock()
%52 = load i64, i64* %10
%53 = sub nsw i64 %51, %52
%54 = sitofp i64 %53 to double
%55 = load double, double* @CLOCKS_PER_SEC
%56 = fdiv double %54, %55
store double %56, double* %9
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = sdiv i32 %60, 1024
%62 = load double, double* %9
%63 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %61, double %62)
br label %64
64: ; preds = %50
%65 = load i32, i32* %13
%66 = add nsw i32 %65, 1
store i32 %66, i32* %13
br label %15
67: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@__const.main.sizes = [16 x i32] [i32 1024, i32 4096, i32 8192, i32 16384, i32 32768, i32 65536, i32 131072, i32 262144, i32 524288, i32 1048576, i32 1572864, i32 2097152, i32 2621440, i32 3145728, i32 3670016, i32 4194304]
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [11 x i8] c"%d, %.8f \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %15, %3 ]
%5 = tail call i64 (...) @clock()
%6 = getelementptr inbounds [16 x i32], [16 x i32]* @__const.main.sizes, i64 0, i64 %4
%7 = tail call i64 (...) @clock()
%8 = sub nsw i64 %7, %5
%9 = sitofp i64 %8 to double
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 1024
%14 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13, double %11)
%15 = add nuw nsw i64 %4, 1
%16 = icmp eq i64 %15, 16
br i1 %16, label %17, label %3
17: ; preds = %3
ret i32 0
}