#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*/ int8_t;
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ _sumArray(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             int /*<<< orphan*/ *);
scalar_t__ clock();
int /*<<< orphan*/ increasingArray(int /*<<< orphan*/ *);
int /*<<< orphan*/ populateArray(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printResults(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  clock_t begin = clock();
  printf("Test 1 running\n");
  int8_t array1[16];
  int8_t array2[16];
  int8_t result[16];
  populateArray(array1, 8);
  increasingArray(array2);
  printf("Calling ASM\n");
  _sumArray(array1, array2, result);
  printf("Finished ASM part\n");
  printResults(array1);
  printResults(array2);
  printResults(result);
  clock_t end = clock();
  printf("Finished execution. Duration: %f ms\n",
         (double)(end - begin) * 1000 / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x8,%esi
call   1070 <populateArray@plt>
lea    -0x90(%rbp),%rdi
call   1050 <increasingArray@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xd0(%rbp),%rdx
call   1040 <_sumArray@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1080 <printResults@plt>
lea    -0x90(%rbp),%rdi
call   1080 <printResults@plt>
lea    -0xd0(%rbp),%rdi
call   1080 <printResults@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  0xde1(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2dbe(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe03(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc8,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
lea    0x80(%rsp),%r15
mov    %r15,%rdi
mov    $0x8,%esi
call   1080 <populateArray@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <increasingArray@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <_sumArray@plt>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1090 <printResults@plt>
mov    %rbx,%rdi
call   1090 <printResults@plt>
mov    %r12,%rdi
call   1090 <printResults@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xdf2(%rip),%xmm0
mov    0x2dd3(%rip),%rax
divsd  (%rax),%xmm0
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Test 1 running\0A\00"
@.str.1 = [13 x i8] c"Calling ASM\0A\00"
@.str.2 = [19 x i8] c"Finished ASM part\0A\00"
@.str.3 = [37 x i8] c"Finished execution. Duration: %f ms\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [16 x i32]
%4 = alloca [16 x i32]
%5 = alloca [16 x i32]
%6 = alloca i64
store i32 0, i32* %1
%7 = call i64 (...) @clock()
store i64 %7, i64* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%10 = call i32 @populateArray(i32* %9, i32 8)
%11 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%12 = call i32 @increasingArray(i32* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%16 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%17 = call i32 @_sumArray(i32* %14, i32* %15, i32* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%20 = call i32 @printResults(i32* %19)
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%22 = call i32 @printResults(i32* %21)
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%24 = call i32 @printResults(i32* %23)
%25 = call i64 (...) @clock()
store i64 %25, i64* %6
%26 = load i64, i64* %6
%27 = load i64, i64* %2
%28 = sub nsw i64 %26, %27
%29 = sitofp i64 %28 to double
%30 = fmul double %29, 1.000000e+03
%31 = load double, double* @CLOCKS_PER_SEC
%32 = fdiv double %30, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), double %32)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [37 x i8] c"Finished execution. Duration: %f ms\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [15 x i8] c"Test 1 running\00"
@str.4 = [12 x i8] c"Calling ASM\00"
@str.5 = [18 x i8] c"Finished ASM part\00"
define i32 @main() {
%1 = alloca [16 x i32]
%2 = alloca [16 x i32]
%3 = alloca [16 x i32]
%4 = tail call i64 (...) @clock()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = bitcast [16 x i32]* %1 to i8*
%7 = bitcast [16 x i32]* %2 to i8*
%8 = bitcast [16 x i32]* %3 to i8*
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%10 = call i32 @populateArray(i32* %9, i32 8)
%11 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%12 = call i32 @increasingArray(i32* %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
%14 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%15 = call i32 @_sumArray(i32* %9, i32* %11, i32* %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
%17 = call i32 @printResults(i32* %9)
%18 = call i32 @printResults(i32* %11)
%19 = call i32 @printResults(i32* %14)
%20 = call i64 (...) @clock()
%21 = sub nsw i64 %20, %4
%22 = sitofp i64 %21 to double
%23 = fmul double %22, 1.000000e+03
%24 = load double, double* @CLOCKS_PER_SEC
%25 = fdiv double %23, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), double %25)
ret i32 0
}