#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  float x[100];
  float y[100];
  int n;
  float dot;
  void Read_vector(char *prompt, float v[], int n);
  float Serial_dot(float x[], float y[], int n);
  printf("Enter the order of the vectors\n");
  scanf("%d", &n);
  Read_vector("the first vector", x, n);
  Read_vector("the second vector", y, n);
  dot = Serial_dot(x, y, n);
  printf("The dot product is %f\n", dot);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x330,%rsp
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x324(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x190(%rbp),%rsi
mov    -0x324(%rbp),%edx
lea    0xea3(%rip),%rdi
call   1060 <Read_vector@plt>
lea    -0x320(%rbp),%rsi
mov    -0x324(%rbp),%edx
lea    0xe9b(%rip),%rdi
call   1060 <Read_vector@plt>
lea    -0x190(%rbp),%rdi
lea    -0x320(%rbp),%rsi
mov    -0x324(%rbp),%edx
call   1030 <Serial_dot@plt>
movss  %xmm0,-0x328(%rbp)
ff
movss  -0x328(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x338,%rsp
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edx
lea    0xe81(%rip),%rdi
lea    0x1a0(%rsp),%r14
mov    %r14,%rsi
call   1070 <Read_vector@plt>
mov    0xc(%rsp),%edx
lea    0xe77(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <Read_vector@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <Serial_dot@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x338,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter the order of the vectors\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"the first vector\00"
@.str.3 = [18 x i8] c"the second vector\00"
@.str.4 = [23 x i8] c"The dot product is %f\0A\00"
define i32 @main() {
%1 = alloca [100 x float]
%2 = alloca [100 x float]
%3 = alloca i32
%4 = alloca float
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 0
%8 = load i32, i32* %3
%9 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%10 = load i32, i32* %3
%11 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 0
%12 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call float @Serial_dot(float* %11, float* %12, i32 %13)
store float %14, float* %4
%15 = load float, float* %4
%16 = fpext float %15 to double
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %16)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"the first vector\00"
@.str.3 = [18 x i8] c"the second vector\00"
@.str.4 = [23 x i8] c"The dot product is %f\0A\00"
@str = [31 x i8] c"Enter the order of the vectors\00"
define i32 @main() {
%1 = alloca [100 x float]
%2 = alloca [100 x float]
%3 = alloca i32
%4 = bitcast [100 x float]* %1 to i8*
%5 = bitcast [100 x float]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 0
%10 = load i32, i32* %3
%11 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%12 = load i32, i32* %3
%13 = load i32, i32* %3
%14 = call float @Serial_dot(float* %9, float* %11, i32 %13)
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %15)
ret i32 0
}