int main(void) {
  char *block1 = malloc(32768 + 1);
  char *block2 = malloc(32768 + 1);
  char *block3 = malloc(32768 + 1);
  char *block4 = malloc(32768 + 1);
  char *block5 = malloc(32768 + 1);
  memset(block1, 0x26, 32768);
  memset(block2, 0x26, 32768);
  memset(block3, 0x26, 32768);
  memset(block4, 0x26, 32768);
  memset(block5, 0x26, 32768);
  unsigned long t1, t2;
  asm volatile("rdtsc" : "=A"(t1) : :);
  ;
  old_bzero(block1, 32768);
  asm volatile("rdtsc" : "=A"(t2) : :);
  ;
  printf("old - (%6lu) %s\n", t2 - t1, block1);
  asm volatile("rdtsc" : "=A"(t1) : :);
  ;
  old_bzero(block2, 32768);
  asm volatile("rdtsc" : "=A"(t2) : :);
  ;
  printf("old - (%6lu) %s\n", t2 - t1, block2);
  asm volatile("rdtsc" : "=A"(t1) : :);
  ;
  new_bzero(block3, 32768);
  asm volatile("rdtsc" : "=A"(t2) : :);
  ;
  printf("new - (%6lu) %s\n", t2 - t1, block3);
  asm volatile("rdtsc" : "=A"(t1) : :);
  ;
  asm_bzero(block4, 32768);
  asm volatile("rdtsc" : "=A"(t2) : :);
  ;
  printf("asm - (%6lu) %s\n", t2 - t1, block4);
  asm volatile("rdtsc" : "=A"(t1) : :);
  ;
  bzero(block5, 32768);
  asm volatile("rdtsc" : "=A"(t2) : :);
  ;
  printf("std - (%6lu) %s\n", t2 - t1, block5);
  free(block1);
  free(block2);
  free(block3);
  free(block4);
  free(block5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x26,%esi
mov    $0x8000,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    $0x26,%esi
mov    $0x8000,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%rdi
mov    $0x26,%esi
mov    $0x8000,%edx
call   1060 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    $0x26,%esi
mov    $0x8000,%edx
call   1060 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    $0x26,%esi
mov    $0x8000,%edx
call   1060 <memset@plt>
rdtsc
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1080 <old_bzero@plt>
rdtsc
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
sub    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
rdtsc
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1080 <old_bzero@plt>
rdtsc
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
sub    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
rdtsc
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1030 <new_bzero@plt>
rdtsc
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
sub    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
rdtsc
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1090 <asm_bzero@plt>
rdtsc
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
sub    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
rdtsc
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8000,%edx
call   1060 <memset@plt>
rdtsc
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
sub    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x8001,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    $0x8000,%edx
mov    %rbx,%rdi
mov    %rbx,0x8(%rsp)
mov    $0x26,%esi
call   1060 <memset@plt>
mov    $0x8000,%edx
mov    %r15,%rdi
mov    $0x26,%esi
call   1060 <memset@plt>
mov    $0x8000,%edx
mov    %r12,%rdi
mov    $0x26,%esi
call   1060 <memset@plt>
mov    $0x8000,%edx
mov    %r14,%rdi
mov    $0x26,%esi
call   1060 <memset@plt>
rdtsc
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1080 <old_bzero@plt>
rdtsc
sub    %rbp,%rax
lea    0xdd2(%rip),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
rdtsc
mov    %rax,%r13
mov    %r15,%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1080 <old_bzero@plt>
rdtsc
sub    %r13,%rax
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
rdtsc
mov    %rax,%rbp
mov    %r12,%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1030 <new_bzero@plt>
rdtsc
sub    %rbp,%rax
lea    0xd8a(%rip),%rdi
mov    %rax,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
rdtsc
mov    %rax,%rbp
mov    %r14,%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1090 <asm_bzero@plt>
rdtsc
sub    %rbp,%rax
lea    0xd6e(%rip),%rdi
mov    %rax,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
rdtsc
mov    %rax,%rbp
mov    $0x8000,%edx
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
rdtsc
sub    %rbp,%rax
lea    0xd4d(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"old - (%6lu) %s\0A\00"
@.str.1 = [17 x i8] c"new - (%6lu) %s\0A\00"
@.str.2 = [17 x i8] c"asm - (%6lu) %s\0A\00"
@.str.3 = [17 x i8] c"std - (%6lu) %s\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = call i8* @malloc(i64 32769)
store i8* %8, i8** %1
%9 = call i8* @malloc(i64 32769)
store i8* %9, i8** %2
%10 = call i8* @malloc(i64 32769)
store i8* %10, i8** %3
%11 = call i8* @malloc(i64 32769)
store i8* %11, i8** %4
%12 = call i8* @malloc(i64 32769)
store i8* %12, i8** %5
%13 = load i8*, i8** %1
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %18, i64* %6
%19 = load i8*, i8** %1
%20 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @old_bzero to i32 (i8*, i32, ...)*)(i8* %19, i32 32768)
%21 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %21, i64* %7
%22 = load i64, i64* %7
%23 = load i64, i64* %6
%24 = sub i64 %22, %23
%25 = load i8*, i8** %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %24, i8* %25)
%27 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %27, i64* %6
%28 = load i8*, i8** %2
%29 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @old_bzero to i32 (i8*, i32, ...)*)(i8* %28, i32 32768)
%30 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %30, i64* %7
%31 = load i64, i64* %7
%32 = load i64, i64* %6
%33 = sub i64 %31, %32
%34 = load i8*, i8** %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %33, i8* %34)
%36 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %36, i64* %6
%37 = load i8*, i8** %3
%38 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @new_bzero to i32 (i8*, i32, ...)*)(i8* %37, i32 32768)
%39 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %39, i64* %7
%40 = load i64, i64* %7
%41 = load i64, i64* %6
%42 = sub i64 %40, %41
%43 = load i8*, i8** %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %42, i8* %43)
%45 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %45, i64* %6
%46 = load i8*, i8** %4
%47 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @asm_bzero to i32 (i8*, i32, ...)*)(i8* %46, i32 32768)
%48 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %48, i64* %7
%49 = load i64, i64* %7
%50 = load i64, i64* %6
%51 = sub i64 %49, %50
%52 = load i8*, i8** %4
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 %51, i8* %52)
%54 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %54, i64* %6
%55 = load i8*, i8** %5
%56 = call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
store i64 %56, i64* %7
%57 = load i64, i64* %7
%58 = load i64, i64* %6
%59 = sub i64 %57, %58
%60 = load i8*, i8** %5
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 %59, i8* %60)
%62 = load i8*, i8** %1
%63 = load i8*, i8** %2
%64 = load i8*, i8** %3
%65 = load i8*, i8** %4
%66 = load i8*, i8** %5
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"old - (%6lu) %s\0A\00"
@.str.1 = [17 x i8] c"new - (%6lu) %s\0A\00"
@.str.2 = [17 x i8] c"asm - (%6lu) %s\0A\00"
@.str.3 = [17 x i8] c"std - (%6lu) %s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(32769) i8* @malloc(i64 32769)
%2 = tail call dereferenceable_or_null(32769) i8* @malloc(i64 32769)
%3 = tail call dereferenceable_or_null(32769) i8* @malloc(i64 32769)
%4 = tail call dereferenceable_or_null(32769) i8* @malloc(i64 32769)
%5 = tail call dereferenceable_or_null(32769) i8* @malloc(i64 32769)
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(32768) %1, i8 38, i64 32768, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(32768) %2, i8 38, i64 32768, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(32768) %3, i8 38, i64 32768, i1 false)
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(32768) %4, i8 38, i64 32768, i1 false)
%6 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%7 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @old_bzero to i32 (i8*, i32, ...)*)(i8* %1, i32 32768)
%8 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%9 = sub i64 %8, %6
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %9, i8* %1)
%11 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%12 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @old_bzero to i32 (i8*, i32, ...)*)(i8* %2, i32 32768)
%13 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%14 = sub i64 %13, %11
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %14, i8* %2)
%16 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%17 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @new_bzero to i32 (i8*, i32, ...)*)(i8* %3, i32 32768)
%18 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%19 = sub i64 %18, %16
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %19, i8* %3)
%21 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%22 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @asm_bzero to i32 (i8*, i32, ...)*)(i8* %4, i32 32768)
%23 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%24 = sub i64 %23, %21
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 %24, i8* %4)
%26 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
tail call void @llvm.memset.p0i8.i64(i8* align 1 dereferenceable(32768) %5, i8 0, i64 32768, i1 false)
%27 = tail call i64 asm sideeffect "rdtsc", "=A,~{dirflag},~{fpsr},~{flags}"()
%28 = sub i64 %27, %26
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 %28, i8* %5)
tail call void @free(i8* %1)
tail call void @free(i8* %2)
tail call void @free(i8* %3)
tail call void @free(i8* %4)
tail call void @free(i8* %5)
ret i32 0
}