#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 */
int /*<<< orphan*/ BTLZA_BitDec_MemCpy(char *, char *, int);
scalar_t__ CLOCKS_PER_SEC;
int clock();
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char *tbuf1, *tbuf2;
  char *ts1, *ts2;
  int t0, t1, t2;
  int i, j, k, n;
  tbuf1 = malloc(1 << 26);
  tbuf2 = malloc(1 << 26);
  ts1 = tbuf1;
  ts2 = tbuf2;
  t0 = clock();
  n = 0;
  for (i = 0; i < 64; i++) {
    for (j = 0; j < 64; j++) {
      ts1 = tbuf1 + (j << 20);
      ts2 = tbuf2 + (j << 20);
      BTLZA_BitDec_MemCpy(ts1, ts2, 1 << 20);
      n++;
    }
    t1 = clock();
    t2 = t1 - t0;
    printf("%.3fMB/sec\r", n / (t2 / ((double)CLOCKS_PER_SEC)));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4000000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4000000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x40,-0x38(%rbp)
jge    124c <main+0x10c>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x40,-0x3c(%rbp)
jge    11ff <main+0xbf>
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x14,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x14,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x100000,%edx
call   1060 <BTLZA_BitDec_MemCpy@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a4 <main+0x64>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
cvtsi2sdl -0x44(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
mov    0x2dc5(%rip),%rax
cvtsi2sdq (%rax),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xdc9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1193 <main+0x53>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x4000000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x4000000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    %eax,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%r15,1),%rdi
lea    (%rbx,%r15,1),%rsi
mov    $0x100000,%edx
call   1070 <BTLZA_BitDec_MemCpy@plt>
add    $0x100000,%r15
cmp    $0x4000000,%r15
jne    11a0 <main+0x50>
add    $0x40,%ebp
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r13d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    0x2e04(%rip),%rax
xorps  %xmm2,%xmm2
cvtsi2sdq (%rax),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xe05(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%r12d
cmp    $0x40,%r12d
jne    1190 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%.3fMB/sec\0D\00"
@CLOCKS_PER_SEC = global i64 0
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
%13 = call i8* @malloc(i32 67108864)
store i8* %13, i8** %2
%14 = call i8* @malloc(i32 67108864)
store i8* %14, i8** %3
%15 = load i8*, i8** %2
store i8* %15, i8** %4
%16 = load i8*, i8** %3
store i8* %16, i8** %5
%17 = call i32 (...) @clock()
store i32 %17, i32* %6
store i32 0, i32* %12
store i32 0, i32* %9
br label %18
18: ; preds = %58, %0
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 64
br i1 %20, label %21, label %61
21: ; preds = %18
store i32 0, i32* %10
br label %22
22: ; preds = %41, %21
%23 = load i32, i32* %10
%24 = icmp slt i32 %23, 64
br i1 %24, label %25, label %44
25: ; preds = %22
%26 = load i8*, i8** %2
%27 = load i32, i32* %10
%28 = shl i32 %27, 20
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8* %30, i8** %4
%31 = load i8*, i8** %3
%32 = load i32, i32* %10
%33 = shl i32 %32, 20
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8* %35, i8** %5
%36 = load i8*, i8** %4
%37 = load i8*, i8** %5
%38 = call i32 @BTLZA_BitDec_MemCpy(i8* %36, i8* %37, i32 1048576)
%39 = load i32, i32* %12
%40 = add nsw i32 %39, 1
store i32 %40, i32* %12
br label %41
41: ; preds = %25
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %22
44: ; preds = %22
%45 = call i32 (...) @clock()
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = sub nsw i32 %46, %47
store i32 %48, i32* %8
%49 = load i32, i32* %12
%50 = sitofp i32 %49 to double
%51 = load i32, i32* %8
%52 = sitofp i32 %51 to double
%53 = load i64, i64* @CLOCKS_PER_SEC
%54 = sitofp i64 %53 to double
%55 = fdiv double %52, %54
%56 = fdiv double %50, %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %56)
br label %58
58: ; preds = %44
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %18
61: ; preds = %18
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [12 x i8] c"%.3fMB/sec\0D\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main() {
%1 = tail call dereferenceable_or_null(67108864) i8* @malloc(i32 67108864)
%2 = tail call dereferenceable_or_null(67108864) i8* @malloc(i32 67108864)
%3 = tail call i32 (...) @clock()
br label %4
4: ; preds = %0, %15
%5 = phi i32 [ 0, %0 ], [ %16, %15 ]
%6 = phi i32 [ 0, %0 ], [ %26, %15 ]
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %13, %7 ]
%9 = shl nuw nsw i64 %8, 20
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = getelementptr inbounds i8, i8* %2, i64 %9
%12 = tail call i32 @BTLZA_BitDec_MemCpy(i8* %10, i8* %11, i32 1048576)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, 64
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = add nuw nsw i32 %5, 64
%17 = tail call i32 (...) @clock()
%18 = sub nsw i32 %17, %3
%19 = sitofp i32 %16 to double
%20 = sitofp i32 %18 to double
%21 = load i64, i64* @CLOCKS_PER_SEC
%22 = sitofp i64 %21 to double
%23 = fdiv double %20, %22
%24 = fdiv double %19, %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %24)
%26 = add nuw nsw i32 %6, 1
%27 = icmp eq i32 %26, 64
br i1 %27, label %28, label %4
28: ; preds = %15
%29 = tail call i32 @putchar(i32 10)
ret i32 0
}