#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*/ printf(char *, double);
double skalarprodukt(float *, float *);
double skalarproduktAssembler(float *, float *);
double skalarproduktIntrinsics(float *, float *);
int main() {
  float x[4] = {1.0, 2.0, 3.0, 4.0};
  float y[4] = {5.0, 6.0, 7.0, 8.0};
  printf("3: %f\n", skalarproduktIntrinsics(x, y));
  printf("2: %f\n", skalarproduktAssembler(x, y));
  printf("1: %f\n", skalarprodukt(x, y));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <skalarproduktIntrinsics@plt>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <skalarproduktAssembler@plt>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <skalarprodukt@plt>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <skalarproduktIntrinsics@plt>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <skalarproduktAssembler@plt>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <skalarprodukt@plt>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.x = [4 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00]
@__const.main.y = [4 x float] [float 5.000000e+00, float 6.000000e+00, float 7.000000e+00, float 8.000000e+00]
@.str = [7 x i8] c"3: %f\0A\00"
@.str.1 = [7 x i8] c"2: %f\0A\00"
@.str.2 = [7 x i8] c"1: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x float]
%3 = alloca [4 x float]
store i32 0, i32* %1
%4 = bitcast [4 x float]* %2 to i8*
%5 = bitcast [4 x float]* %3 to i8*
%6 = getelementptr inbounds [4 x float], [4 x float]* %2, i64 0, i64 0
%7 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 0
%8 = call double @skalarproduktIntrinsics(float* %6, float* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %8)
%10 = getelementptr inbounds [4 x float], [4 x float]* %2, i64 0, i64 0
%11 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 0
%12 = call double @skalarproduktAssembler(float* %10, float* %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = getelementptr inbounds [4 x float], [4 x float]* %2, i64 0, i64 0
%15 = getelementptr inbounds [4 x float], [4 x float]* %3, i64 0, i64 0
%16 = call double @skalarprodukt(float* %14, float* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [4 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00]
@__const.main.y = [4 x float] [float 5.000000e+00, float 6.000000e+00, float 7.000000e+00, float 8.000000e+00]
@.str = [7 x i8] c"3: %f\0A\00"
@.str.1 = [7 x i8] c"2: %f\0A\00"
@.str.2 = [7 x i8] c"1: %f\0A\00"
define i32 @main() {
%1 = alloca [4 x float]
%2 = alloca [4 x float]
%3 = bitcast [4 x float]* %1 to i8*
%4 = bitcast [4 x float]* %2 to i8*
%5 = getelementptr inbounds [4 x float], [4 x float]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4 x float], [4 x float]* %2, i64 0, i64 0
%7 = call double @skalarproduktIntrinsics(float* %5, float* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %7)
%9 = call double @skalarproduktAssembler(float* %5, float* %6)
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = call double @skalarprodukt(float* %5, float* %6)
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %11)
ret i32 0
}