#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 crossvec(int MAX) {
  float x, y, z, a, b, c, vectorx, vectory, vectorz;
  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++) {
    vectorx = (y * c) - (z * b);
    vectory = (z * a) - (x * c);
    vectorz = (x * b) - (y * a);
  }
  printf("The cross product of vector A and vector B is (%.2f, %.2f, %.2f). \n",
         vectorx, vectory, vectorz);
}


x86 assembly (clang, -O0):
<crossvec>:
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,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1266 <crossvec+0x146>
movss  -0xc(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  -0x18(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c2 <crossvec+0xa2>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x28(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe57(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crossvec>:
push   %rbx
sub    $0x20,%rsp
lea    0xf5a(%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    0xf75(%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  0x18(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  0x14(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
movaps %xmm0,%xmm4
mulss  %xmm1,%xmm4
movss  0x1c(%rsp),%xmm5
mulss  %xmm5,%xmm1
mulss  %xmm3,%xmm5
mulss  %xmm2,%xmm3
subss  %xmm3,%xmm4
movss  0x10(%rsp),%xmm3
mulss  %xmm3,%xmm2
subss  %xmm1,%xmm2
mulss  %xmm0,%xmm3
subss  %xmm3,%xmm5
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm5,%xmm2
lea    0xe1f(%rip),%rdi
mov    $0x3,%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 = [68 x i8] c"The cross product of vector A and vector B is (%.2f, %.2f, %.2f). \0A\00"
define void @crossvec(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 i32
store i32 %0, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %4, float* %5)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %6, float* %7, float* %8)
%17 = load float, float* %3
%18 = fpext float %17 to double
%19 = load float, float* %4
%20 = fpext float %19 to double
%21 = load float, float* %5
%22 = fpext float %21 to double
%23 = load float, float* %6
%24 = fpext float %23 to double
%25 = load float, float* %7
%26 = fpext float %25 to double
%27 = load float, float* %8
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), double %18, double %20, double %22, double %24, double %26, double %28)
store i32 0, i32* %12
br label %30
30: ; preds = %56, %1
%31 = load i32, i32* %12
%32 = load i32, i32* %2
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %59
34: ; preds = %30
%35 = load float, float* %4
%36 = load float, float* %8
%37 = load float, float* %5
%38 = load float, float* %7
%39 = fmul float %37, %38
%40 = fneg float %39
%41 = call float @llvm.fmuladd.f32(float %35, float %36, float %40)
store float %41, float* %9
%42 = load float, float* %5
%43 = load float, float* %6
%44 = load float, float* %3
%45 = load float, float* %8
%46 = fmul float %44, %45
%47 = fneg float %46
%48 = call float @llvm.fmuladd.f32(float %42, float %43, float %47)
store float %48, float* %10
%49 = load float, float* %3
%50 = load float, float* %7
%51 = load float, float* %4
%52 = load float, float* %6
%53 = fmul float %51, %52
%54 = fneg float %53
%55 = call float @llvm.fmuladd.f32(float %49, float %50, float %54)
store float %55, float* %11
br label %56
56: ; preds = %34
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %30
59: ; preds = %30
%60 = load float, float* %9
%61 = fpext float %60 to double
%62 = load float, float* %10
%63 = fpext float %62 to double
%64 = load float, float* %11
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), double %61, double %63, double %65)
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 = [68 x i8] c"The cross product of vector A and vector B is (%.2f, %.2f, %.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 @crossvec(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* %3
%33 = load float, float* %7
%34 = load float, float* %4
%35 = load float, float* %6
%36 = fneg float %34
%37 = fmul float %35, %36
%38 = call float @llvm.fmuladd.f32(float %32, float %33, float %37)
%39 = load float, float* %5
%40 = load float, float* %2
%41 = fneg float %40
%42 = fmul float %33, %41
%43 = call float @llvm.fmuladd.f32(float %34, float %39, float %42)
%44 = fneg float %32
%45 = fmul float %39, %44
%46 = call float @llvm.fmuladd.f32(float %40, float %35, float %45)
%47 = fpext float %38 to double
%48 = fpext float %43 to double
%49 = fpext float %46 to double
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0), double %47, double %48, double %49)
ret void
}