#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 acos(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *);
float sqrt(float);
void angl(int MAX) {
  float x, y, a, b, scalarx, scalary, newscalar, absa, absb, angle;
  printf("Enter the x and y elements of the first vector, respectively: \n");
  scanf("%f %f", &x, &y);
  printf("Enter the x and y elements of the second vector, respectively: \n");
  scanf("%f %f", &a, &b);
  printf("The numbers you have input are %.2f, %.2f, %.2f, and %.2f. \n", x, y,
         a, b);
  for (int i = 0; i < MAX; i++) {
    scalarx = x * a;
    scalary = y * b;
    newscalar = scalarx + scalary;
    absa = sqrt((x * x) + (y * y));
    absb = sqrt((a * a) + (b * b));
    angle = acos(newscalar / (absa * absb));
  }
  printf("The angle, in radians, between vector A and vector B is %.2f. \n",
         angle);
}


x86 assembly (clang, -O0):
<angl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <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
lea    0xecd(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1278 <angl+0x138>
movss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1060 <sqrt@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1060 <sqrt@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
divss  %xmm1,%xmm0
call   1040 <acos@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c8 <angl+0x88>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<angl>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%r14
lea    0x20(%rsp),%rsi
lea    0x1c(%rsp),%rdx
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
call   1060 <scanf@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x10(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0xc(%rsp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xe3f(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
jmp    121a <angl+0xca>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  %xmm3,0x24(%rsp)
call   1070 <sqrt@plt>
movss  0x24(%rsp),%xmm3
movss  0x18(%rsp),%xmm1
movss  0x14(%rsp),%xmm2
mulss  %xmm0,%xmm3
addss  %xmm2,%xmm1
divss  %xmm3,%xmm1
movaps %xmm1,%xmm0
call   1050 <acos@plt>
add    $0xffffffff,%ebx
je     12a6 <angl+0x156>
movss  0x20(%rsp),%xmm0
movss  0x10(%rsp),%xmm2
mulss  %xmm0,%xmm2
movss  0x1c(%rsp),%xmm1
movss  0xc(%rsp),%xmm3
mulss  %xmm1,%xmm3
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xdb3(%rip),%xmm0
movss  %xmm2,0x18(%rsp)
movss  %xmm3,0x14(%rsp)
jb     1270 <angl+0x120>
xorps  %xmm3,%xmm3
sqrtss %xmm0,%xmm3
jmp    1278 <angl+0x128>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1070 <sqrt@plt>
movaps %xmm0,%xmm3
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xd69(%rip),%xmm0
jb     11e0 <angl+0x90>
sqrtss %xmm0,%xmm0
jmp    11f1 <angl+0xa1>
cvtss2sd %xmm0,%xmm0
lea    0xd96(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Enter the x and y elements of the first vector, respectively: \0A\00"
@.str.1 = [6 x i8] c"%f %f\00"
@.str.2 = [65 x i8] c"Enter the x and y elements of the second vector, respectively: \0A\00"
@.str.3 = [61 x i8] c"The numbers you have input are %.2f, %.2f, %.2f, and %.2f. \0A\00"
@.str.4 = [64 x i8] c"The angle, in radians, between vector A and vector B is %.2f. \0A\00"
define void @angl(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 ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %4)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %5, float* %6)
%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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0), double %19, double %21, double %23, double %25)
store i32 0, i32* %13
br label %27
27: ; preds = %61, %1
%28 = load i32, i32* %13
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %64
31: ; preds = %27
%32 = load float, float* %3
%33 = load float, float* %5
%34 = fmul float %32, %33
store float %34, float* %7
%35 = load float, float* %4
%36 = load float, float* %6
%37 = fmul float %35, %36
store float %37, float* %8
%38 = load float, float* %7
%39 = load float, float* %8
%40 = fadd float %38, %39
store float %40, float* %9
%41 = load float, float* %3
%42 = load float, float* %3
%43 = load float, float* %4
%44 = load float, float* %4
%45 = fmul float %43, %44
%46 = call float @llvm.fmuladd.f32(float %41, float %42, float %45)
%47 = call float @sqrt(float %46)
store float %47, float* %10
%48 = load float, float* %5
%49 = load float, float* %5
%50 = load float, float* %6
%51 = load float, float* %6
%52 = fmul float %50, %51
%53 = call float @llvm.fmuladd.f32(float %48, float %49, float %52)
%54 = call float @sqrt(float %53)
store float %54, float* %11
%55 = load float, float* %9
%56 = load float, float* %10
%57 = load float, float* %11
%58 = fmul float %56, %57
%59 = fdiv float %55, %58
%60 = call float @acos(float %59)
store float %60, float* %12
br label %61
61: ; preds = %31
%62 = load i32, i32* %13
%63 = add nsw i32 %62, 1
store i32 %63, i32* %13
br label %27
64: ; preds = %27
%65 = load float, float* %12
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), double %66)
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%f %f\00"
@.str.3 = [61 x i8] c"The numbers you have input are %.2f, %.2f, %.2f, and %.2f. \0A\00"
@.str.4 = [64 x i8] c"The angle, in radians, between vector A and vector B is %.2f. \0A\00"
@str = [63 x i8] c"Enter the x and y elements of the first vector, respectively: \00"
@str.5 = [64 x i8] c"Enter the x and y elements of the second vector, respectively: \00"
define void @angl(i32 %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %4, float* %5)
%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 = load float, float* %5
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0), double %15, double %17, double %19, double %21)
%23 = icmp sgt i32 %0, 0
br label %27
24: ; preds = %27
%25 = fpext float %46 to double
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), double %25)
ret void
27: ; preds = %1, %27
%28 = phi i32 [ %47, %27 ], [ 0, %1 ]
%29 = load float, float* %2
%30 = load float, float* %4
%31 = fmul float %29, %30
%32 = load float, float* %3
%33 = load float, float* %5
%34 = fmul float %32, %33
%35 = fadd float %31, %34
%36 = fmul float %32, %32
%37 = call float @llvm.fmuladd.f32(float %29, float %29, float %36)
%38 = call float @sqrt(float %37)
%39 = load float, float* %4
%40 = load float, float* %5
%41 = fmul float %40, %40
%42 = call float @llvm.fmuladd.f32(float %39, float %39, float %41)
%43 = call float @sqrt(float %42)
%44 = fmul float %38, %43
%45 = fdiv float %35, %44
%46 = call float @acos(float %45)
%47 = add nuw nsw i32 %28, 1
%48 = icmp eq i32 %47, %0
br i1 %48, label %24, label %27
}