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

/* Variables and functions */
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, int);
int main() {
  clock_t start;
  clock_t end;
  int a[100000];
  int b[100000];
  int *pEnd = &a[100000];
  int *pa = NULL;
  int *pb = NULL;
  int i = 0;
  int k = 0;
  start = clock();
  for (k = 0; k < 100000; k++)
    for (i = 0; i < 100000; i++)
      b[i] = a[i];
  end = clock();
  printf("Index Timing: %d\n", (int)(end - start));
  start = clock();
  for (k = 0; k < 100000; k++)
    for (pa = a, pb = b; pa < pEnd;)
      *pb++ = *pa++;
  end = clock();
  printf("Pointer Timing: %d\n", (int)(end - start));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3540,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x61aa0(%rbp),%rax
add    $0x61a80,%rax
mov    %rax,-0xc3528(%rbp)
movq   $0x0,-0xc3530(%rbp)
movq   $0x0,-0xc3538(%rbp)
movl   $0x0,-0xc353c(%rbp)
movl   $0x0,-0xc3540(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0xc3540(%rbp)
cmpl   $0x186a0,-0xc3540(%rbp)
jge    11f8 <main+0xd8>
movl   $0x0,-0xc353c(%rbp)
cmpl   $0x186a0,-0xc353c(%rbp)
jge    11df <main+0xbf>
movslq -0xc353c(%rbp),%rax
mov    -0x61aa0(%rbp,%rax,4),%ecx
movslq -0xc353c(%rbp),%rax
mov    %ecx,-0xc3520(%rbp,%rax,4)
mov    -0xc353c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc353c(%rbp)
jmp    119f <main+0x7f>
jmp    11e4 <main+0xc4>
mov    -0xc3540(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3540(%rbp)
jmp    1185 <main+0x65>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0xc3540(%rbp)
cmpl   $0x186a0,-0xc3540(%rbp)
jge    12ba <main+0x19a>
lea    -0x61aa0(%rbp),%rax
mov    %rax,-0xc3530(%rbp)
lea    -0xc3520(%rbp),%rax
mov    %rax,-0xc3538(%rbp)
mov    -0xc3530(%rbp),%rax
cmp    -0xc3528(%rbp),%rax
jae    12a1 <main+0x181>
mov    -0xc3530(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0xc3530(%rbp)
mov    (%rax),%ecx
mov    -0xc3538(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0xc3538(%rbp)
mov    %ecx,(%rax)
jmp    125a <main+0x13a>
jmp    12a6 <main+0x186>
mov    -0xc3540(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3540(%rbp)
jmp    122e <main+0x10e>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xd3c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc3540,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebx,%eax
lea    0xec5(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebx,%eax
lea    0xeb6(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"Index Timing: %d\0A\00"
@.str.1 = [20 x i8] c"Pointer Timing: %d\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = tail call i64 (...) @clock()
%3 = sub nsw i64 %2, %1
%4 = trunc i64 %3 to i32
%5 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i64 (...) @clock()
%7 = call i64 (...) @clock()
%8 = sub nsw i64 %7, %6
%9 = trunc i64 %8 to i32
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %9)
ret i32 0
}