#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 *, float *, float *, float *);
void dotvec(int MAX) {
  float x, y, z, a, b, c, scalarx, scalary, scalarz, newscalar;
  printf(
      "Enter the x, y, and z components of the first vector, respectively: \n");
  scanf("%f %f %f", &x, &y, &z);
  printf("Enter the x, y, and z components of the second vector, respectively: "
         "\n");
  scanf("%f %f %f", &a, &b, &c);
  printf("The numbers you have input are %.2f, %.2f, %.2f, %.2f, %.2f, and "
         "%.2f. \n",
         x, y, z, a, b, c);
  for (int i = 0; i < MAX; i++) {
    scalarx = x * a;
    scalary = y * b;
    scalarz = z * c;
    newscalar = scalarx + scalary + scalarz;
  }
  printf("The dot product of vector A and vector B is %.2f. \n", newscalar);
}


x86 assembly (clang, -O0):
<dotvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x14(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  -0x18(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  -0x1c(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xee2(%rip),%rdi
mov    $0x6,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121d <dotvec+0xfd>
movss  -0x8(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c2 <dotvec+0xa2>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotvec>:
push   %rbx
sub    $0x20,%rsp
lea    0xf4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rbx
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0x10(%rsp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  0xc(%rsp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  0x8(%rsp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xe44(%rip),%rdi
mov    $0x6,%al
call   1040 <printf@plt>
movss  0x1c(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
mulss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [70 x i8] c"Enter the x, y, and z components of the first vector, respectively: \0A\00"
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.2 = [71 x i8] c"Enter the x, y, and z components of the second vector, respectively: \0A\00"
@.str.3 = [73 x i8] c"The numbers you have input are %.2f, %.2f, %.2f, %.2f, %.2f, and %.2f. \0A\00"
@.str.4 = [52 x i8] c"The dot product of vector A and vector B is %.2f. \0A\00"
define void @dotvec(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca i32
store i32 %0, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %4, float* %5)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %6, float* %7, float* %8)
%18 = load float, float* %3
%19 = fpext float %18 to double
%20 = load float, float* %4
%21 = fpext float %20 to double
%22 = load float, float* %5
%23 = fpext float %22 to double
%24 = load float, float* %6
%25 = fpext float %24 to double
%26 = load float, float* %7
%27 = fpext float %26 to double
%28 = load float, float* %8
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), double %19, double %21, double %23, double %25, double %27, double %29)
store i32 0, i32* %13
br label %31
31: ; preds = %50, %1
%32 = load i32, i32* %13
%33 = load i32, i32* %2
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %53
35: ; preds = %31
%36 = load float, float* %3
%37 = load float, float* %6
%38 = fmul float %36, %37
store float %38, float* %9
%39 = load float, float* %4
%40 = load float, float* %7
%41 = fmul float %39, %40
store float %41, float* %10
%42 = load float, float* %5
%43 = load float, float* %8
%44 = fmul float %42, %43
store float %44, float* %11
%45 = load float, float* %9
%46 = load float, float* %10
%47 = fadd float %45, %46
%48 = load float, float* %11
%49 = fadd float %47, %48
store float %49, float* %12
br label %50
50: ; preds = %35
%51 = load i32, i32* %13
%52 = add nsw i32 %51, 1
store i32 %52, i32* %13
br label %31
53: ; preds = %31
%54 = load float, float* %12
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), double %55)
ret void
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.3 = [73 x i8] c"The numbers you have input are %.2f, %.2f, %.2f, %.2f, %.2f, and %.2f. \0A\00"
@.str.4 = [52 x i8] c"The dot product of vector A and vector B is %.2f. \0A\00"
@str = [69 x i8] c"Enter the x, y, and z components of the first vector, respectively: \00"
@str.5 = [70 x i8] c"Enter the x, y, and z components of the second vector, respectively: \00"
define void @dotvec(i32 %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = bitcast float* %2 to i8*
%9 = bitcast float* %3 to i8*
%10 = bitcast float* %4 to i8*
%11 = bitcast float* %5 to i8*
%12 = bitcast float* %6 to i8*
%13 = bitcast float* %7 to i8*
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.5, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %5, float* %6, float* %7)
%18 = load float, float* %2
%19 = fpext float %18 to double
%20 = load float, float* %3
%21 = fpext float %20 to double
%22 = load float, float* %4
%23 = fpext float %22 to double
%24 = load float, float* %5
%25 = fpext float %24 to double
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = load float, float* %7
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), double %19, double %21, double %23, double %25, double %27, double %29)
%31 = icmp sgt i32 %0, 0
%32 = load float, float* %2
%33 = load float, float* %5
%34 = fmul float %32, %33
%35 = load float, float* %3
%36 = load float, float* %6
%37 = fmul float %35, %36
%38 = load float, float* %4
%39 = load float, float* %7
%40 = fmul float %38, %39
%41 = fadd float %34, %37
%42 = fadd float %41, %40
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), double %43)
ret void
}