#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 */
float cos(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
void dotvecc(int MAX) {
  float x, a, newscalar, deg, rad;
  printf("Enter the absolute value of the first vector: \n");
  scanf("%f", &x);
  printf("Enter the absolute value of the second vector: \n");
  scanf("%f", &a);
  printf("Enter the angle, in degrees, between the two vectors: \n");
  scanf("%f", &deg);
  printf("The numbers you have input are %.2f, %.2f, and %.2f. \n", x, a, deg);
  for (int i = 0; i < MAX; i++) {
    rad = deg * (3.14 / 180.0);
    newscalar = x * a * cos(rad);
  }
  printf("The dot product of vector A and vector B is %.2f. \n", newscalar);
}


x86 assembly (clang, -O0):
<dotvecc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xeed(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1227 <dotvecc+0xf7>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c5 <dotvecc+0x95>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotvecc>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x4(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe4c(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
cmp    $0x1,%ebp
je     1243 <dotvecc+0x103>
mov    %ebp,%ebx
and    $0x7ffffffe,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <cos@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xdef(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x14(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x10(%rsp),%xmm1
movss  %xmm1,0x8(%rsp)
call   1060 <cos@plt>
add    $0xfffffffe,%ebx
jne    11e0 <dotvecc+0xa0>
movss  0xc(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
test   $0x1,%bpl
je     1288 <dotvecc+0x148>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xda5(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x14(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x10(%rsp),%xmm1
movss  %xmm1,0x8(%rsp)
call   1060 <cos@plt>
movss  0x8(%rsp),%xmm2
movss  0xc(%rsp),%xmm1
mulss  %xmm2,%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xda4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.4 = [55 x i8] c"The numbers you have input are %.2f, %.2f, and %.2f. \0A\00"
@.str.5 = [52 x i8] c"The dot product of vector A and vector B is %.2f. \0A\00"
@str = [47 x i8] c"Enter the absolute value of the first vector: \00"
@str.6 = [48 x i8] c"Enter the absolute value of the second vector: \00"
@str.7 = [55 x i8] c"Enter the angle, in degrees, between the two vectors: \00"
define void @dotvecc(i32 %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = bitcast float* %4 to i8*
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.7, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%14 = load float, float* %2
%15 = fpext float %14 to double
%16 = load float, float* %3
%17 = fpext float %16 to double
%18 = load float, float* %4
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), double %15, double %17, double %19)
%21 = icmp sgt i32 %0, 0
%22 = and i32 %0, 1
%23 = icmp eq i32 %0, 1
br i1 %23, label %26, label %24
24: ; preds = %1
%25 = and i32 %0, 2147483646
br label %47
26: ; preds = %47, %1
%27 = phi float [ undef, %1 ], [ %58, %47 ]
%28 = phi float [ undef, %1 ], [ %59, %47 ]
%29 = phi float [ undef, %1 ], [ %60, %47 ]
%30 = icmp eq i32 %22, 0
br i1 %30, label %39, label %31
31: ; preds = %26
%32 = load float, float* %4
%33 = fpext float %32 to double
%34 = fmul double %33, 0x3F91DCF4D98B0955
%35 = fptrunc double %34 to float
%36 = load float, float* %2
%37 = load float, float* %3
%38 = call float @cos(float %35)
br label %39
39: ; preds = %26, %31
%40 = phi float [ %27, %26 ], [ %36, %31 ]
%41 = phi float [ %28, %26 ], [ %37, %31 ]
%42 = phi float [ %29, %26 ], [ %38, %31 ]
%43 = fmul float %40, %41
%44 = fmul float %43, %42
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), double %45)
ret void
47: ; preds = %47, %24
%48 = phi i32 [ 0, %24 ], [ %61, %47 ]
%49 = load float, float* %4
%50 = fpext float %49 to double
%51 = fmul double %50, 0x3F91DCF4D98B0955
%52 = fptrunc double %51 to float
%53 = call float @cos(float %52)
%54 = load float, float* %4
%55 = fpext float %54 to double
%56 = fmul double %55, 0x3F91DCF4D98B0955
%57 = fptrunc double %56 to float
%58 = load float, float* %2
%59 = load float, float* %3
%60 = call float @cos(float %57)
%61 = add i32 %48, 2
%62 = icmp eq i32 %61, %25
br i1 %62, label %26, label %47
}