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

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
double time_strcpy(char *(*cpy)(char *, const char *), char *d, const char *s) {
  clock_t starttime, time;
  int i;
  starttime = clock();
  for (i = 0; i < 1000000; i++)
    cpy(d, s);
  time = clock() - starttime;
  return (1.0) * time / CLOCKS_PER_SEC;
}


x86 assembly (clang, -O0):
<time_strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xf4240,-0x2c(%rbp)
jge    1160 <time_strcpy+0x50>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   *%rax
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1137 <time_strcpy+0x27>
mov    $0x0,%al
call   1030 <clock@plt>
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe87(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    0x2e63(%rip),%rax
divsd  (%rax),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_strcpy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
movsd  %xmm0,(%rsp)
mov    $0xf4240,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   *%rbx
add    $0xffffffff,%ebp
jne    1140 <time_strcpy+0x30>
xor    %eax,%eax
call   1030 <clock@plt>
subsd  (%rsp),%xmm0
mov    0x2e88(%rip),%rax
divsd  (%rax),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @time_strcpy(i8* (i8*, i8*)* %0, i8* %1, i8* %2) {
%4 = alloca i8* (i8*, i8*)*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i8* (i8*, i8*)* %0, i8* (i8*, i8*)** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = call double (...) @clock()
store double %10, double* %7
store i32 0, i32* %9
br label %11
11: ; preds = %19, %3
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 1000000
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8* (i8*, i8*)*, i8* (i8*, i8*)** %4
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = call i8* %15(i8* %16, i8* %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %9
%21 = add nsw i32 %20, 1
store i32 %21, i32* %9
br label %11
22: ; preds = %11
%23 = call double (...) @clock()
%24 = load double, double* %7
%25 = fsub double %23, %24
store double %25, double* %8
%26 = load double, double* %8
%27 = fmul double 1.000000e+00, %26
%28 = load double, double* @CLOCKS_PER_SEC
%29 = fdiv double %27, %28
ret double %29
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @time_strcpy(i8* (i8*, i8*)* nocapture %0, i8* %1, i8* %2) {
%4 = tail call double (...) @clock()
br label %5
5: ; preds = %3, %5
%6 = phi i32 [ 0, %3 ], [ %8, %5 ]
%7 = tail call i8* %0(i8* %1, i8* %2)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 1000000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = tail call double (...) @clock()
%12 = fsub double %11, %4
%13 = load double, double* @CLOCKS_PER_SEC
%14 = fdiv double %12, %13
ret double %14
}