#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 DotProd3fv(float const *, float *);
int /*<<< orphan*/ ScalarMult3fv(float *, float const *, float);
int /*<<< orphan*/ printf(char *);
float *World2ObjXform16fv(float *M, const float X[3], const float Y[3],
                          const float Z[3], const float O[3], float Scale) {
  if (Scale <= 0) {
    printf("Too small scale!\n");
    Scale = 1;
  }
  float invScale = 1 / Scale;
  float sX[3], sY[3], sZ[3];
  ScalarMult3fv(sX, X, invScale);
  ScalarMult3fv(sY, Y, invScale);
  ScalarMult3fv(sZ, Z, invScale);
  M[0] = sX[0];
  M[4] = sX[1];
  M[8] = sX[2];
  M[12] = -DotProd3fv(O, sX);
  M[1] = sY[0];
  M[5] = sY[1];
  M[9] = sY[2];
  M[13] = -DotProd3fv(O, sY);
  M[2] = sZ[0];
  M[6] = sZ[1];
  M[10] = sZ[2];
  M[14] = -DotProd3fv(O, sZ);
  M[3] = 0;
  M[7] = 0;
  M[11] = 0;
  M[15] = 1;
  return (M);
}


x86 assembly (clang, -O0):
<World2ObjXform16fv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movss  %xmm0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x2c(%rbp),%xmm0
jb     1177 <World2ObjXform16fv+0x47>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
movss  0xe8e(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xe81(%rip),%xmm0
divss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
lea    -0x3c(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movss  -0x30(%rbp),%xmm0
call   1040 <ScalarMult3fv@plt>
lea    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movss  -0x30(%rbp),%xmm0
call   1040 <ScalarMult3fv@plt>
lea    -0x54(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movss  -0x30(%rbp),%xmm0
call   1040 <ScalarMult3fv@plt>
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x10(%rax)
movss  -0x34(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x20(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
call   1050 <DotProd3fv@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x30(%rax)
movss  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x24(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <DotProd3fv@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x34(%rax)
movss  -0x54(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x18(%rax)
movss  -0x4c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   1050 <DotProd3fv@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x1c(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x2c(%rax)
mov    -0x8(%rbp),%rax
movss  0xd2b(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<World2ObjXform16fv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jb     1169 <World2ObjXform16fv+0x39>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
movss  0xe97(%rip),%xmm0
movss  0xe8f(%rip),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
lea    0x1c(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
movaps %xmm1,%xmm0
call   1040 <ScalarMult3fv@plt>
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
movss  (%rsp),%xmm0
call   1040 <ScalarMult3fv@plt>
lea    0x4(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
movss  (%rsp),%xmm0
call   1040 <ScalarMult3fv@plt>
movss  0x1c(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x20(%rsp),%xmm0
movss  %xmm0,0x10(%rbx)
movss  0x24(%rsp),%xmm0
movss  %xmm0,0x20(%rbx)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <DotProd3fv@plt>
xorps  0xe27(%rip),%xmm0
movss  %xmm0,0x30(%rbx)
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x14(%rbx)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x24(%rbx)
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <DotProd3fv@plt>
xorps  0xdef(%rip),%xmm0
movss  %xmm0,0x34(%rbx)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x18(%rbx)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x28(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <DotProd3fv@plt>
xorps  0xdb7(%rip),%xmm0
movss  %xmm0,0x38(%rbx)
movl   $0x0,0xc(%rbx)
movl   $0x0,0x1c(%rbx)
movl   $0x0,0x2c(%rbx)
movl   $0x3f800000,0x3c(%rbx)
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Too small scale!\0A\00"
define float* @World2ObjXform16fv(float* %0, float* %1, float* %2, float* %3, float* %4, float %5) {
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float
%13 = alloca float
%14 = alloca [3 x float]
%15 = alloca [3 x float]
%16 = alloca [3 x float]
store float* %0, float** %7
store float* %1, float** %8
store float* %2, float** %9
store float* %3, float** %10
store float* %4, float** %11
store float %5, float* %12
%17 = load float, float* %12
%18 = fcmp ole float %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store float 1.000000e+00, float* %12
br label %21
21: ; preds = %19, %6
%22 = load float, float* %12
%23 = fdiv float 1.000000e+00, %22
store float %23, float* %13
%24 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 0
%25 = load float*, float** %8
%26 = load float, float* %13
%27 = call i32 @ScalarMult3fv(float* %24, float* %25, float %26)
%28 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%29 = load float*, float** %9
%30 = load float, float* %13
%31 = call i32 @ScalarMult3fv(float* %28, float* %29, float %30)
%32 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
%33 = load float*, float** %10
%34 = load float, float* %13
%35 = call i32 @ScalarMult3fv(float* %32, float* %33, float %34)
%36 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 0
%37 = load float, float* %36
%38 = load float*, float** %7
%39 = getelementptr inbounds float, float* %38, i64 0
store float %37, float* %39
%40 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 1
%41 = load float, float* %40
%42 = load float*, float** %7
%43 = getelementptr inbounds float, float* %42, i64 4
store float %41, float* %43
%44 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 2
%45 = load float, float* %44
%46 = load float*, float** %7
%47 = getelementptr inbounds float, float* %46, i64 8
store float %45, float* %47
%48 = load float*, float** %11
%49 = getelementptr inbounds [3 x float], [3 x float]* %14, i64 0, i64 0
%50 = call float @DotProd3fv(float* %48, float* %49)
%51 = fneg float %50
%52 = load float*, float** %7
%53 = getelementptr inbounds float, float* %52, i64 12
store float %51, float* %53
%54 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%55 = load float, float* %54
%56 = load float*, float** %7
%57 = getelementptr inbounds float, float* %56, i64 1
store float %55, float* %57
%58 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 1
%59 = load float, float* %58
%60 = load float*, float** %7
%61 = getelementptr inbounds float, float* %60, i64 5
store float %59, float* %61
%62 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 2
%63 = load float, float* %62
%64 = load float*, float** %7
%65 = getelementptr inbounds float, float* %64, i64 9
store float %63, float* %65
%66 = load float*, float** %11
%67 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 0, i64 0
%68 = call float @DotProd3fv(float* %66, float* %67)
%69 = fneg float %68
%70 = load float*, float** %7
%71 = getelementptr inbounds float, float* %70, i64 13
store float %69, float* %71
%72 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
%73 = load float, float* %72
%74 = load float*, float** %7
%75 = getelementptr inbounds float, float* %74, i64 2
store float %73, float* %75
%76 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 1
%77 = load float, float* %76
%78 = load float*, float** %7
%79 = getelementptr inbounds float, float* %78, i64 6
store float %77, float* %79
%80 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 2
%81 = load float, float* %80
%82 = load float*, float** %7
%83 = getelementptr inbounds float, float* %82, i64 10
store float %81, float* %83
%84 = load float*, float** %11
%85 = getelementptr inbounds [3 x float], [3 x float]* %16, i64 0, i64 0
%86 = call float @DotProd3fv(float* %84, float* %85)
%87 = fneg float %86
%88 = load float*, float** %7
%89 = getelementptr inbounds float, float* %88, i64 14
store float %87, float* %89
%90 = load float*, float** %7
%91 = getelementptr inbounds float, float* %90, i64 3
store float 0.000000e+00, float* %91
%92 = load float*, float** %7
%93 = getelementptr inbounds float, float* %92, i64 7
store float 0.000000e+00, float* %93
%94 = load float*, float** %7
%95 = getelementptr inbounds float, float* %94, i64 11
store float 0.000000e+00, float* %95
%96 = load float*, float** %7
%97 = getelementptr inbounds float, float* %96, i64 15
store float 1.000000e+00, float* %97
%98 = load float*, float** %7
ret float* %98
}

LLVM IR (-O2):
@str = [17 x i8] c"Too small scale!\00"
define float* @World2ObjXform16fv(float* returned writeonly %0, float* %1, float* %2, float* %3, float* %4, float %5) {
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca [3 x float]
%10 = fcmp ugt float %5, 0.000000e+00
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = phi float [ 1.000000e+00, %11 ], [ %5, %6 ]
%15 = fdiv float 1.000000e+00, %14
%16 = bitcast [3 x float]* %7 to i8*
%17 = bitcast [3 x float]* %8 to i8*
%18 = bitcast [3 x float]* %9 to i8*
%19 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%20 = call i32 @ScalarMult3fv(float* %19, float* %1, float %15)
%21 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%22 = call i32 @ScalarMult3fv(float* %21, float* %2, float %15)
%23 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%24 = call i32 @ScalarMult3fv(float* %23, float* %3, float %15)
%25 = load float, float* %19
store float %25, float* %0
%26 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%27 = load float, float* %26
%28 = getelementptr inbounds float, float* %0, i64 4
store float %27, float* %28
%29 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%30 = load float, float* %29
%31 = getelementptr inbounds float, float* %0, i64 8
store float %30, float* %31
%32 = call float @DotProd3fv(float* %4, float* %19)
%33 = fneg float %32
%34 = getelementptr inbounds float, float* %0, i64 12
store float %33, float* %34
%35 = load float, float* %21
%36 = getelementptr inbounds float, float* %0, i64 1
store float %35, float* %36
%37 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 1
%38 = load float, float* %37
%39 = getelementptr inbounds float, float* %0, i64 5
store float %38, float* %39
%40 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 2
%41 = load float, float* %40
%42 = getelementptr inbounds float, float* %0, i64 9
store float %41, float* %42
%43 = call float @DotProd3fv(float* %4, float* %21)
%44 = fneg float %43
%45 = getelementptr inbounds float, float* %0, i64 13
store float %44, float* %45
%46 = load float, float* %23
%47 = getelementptr inbounds float, float* %0, i64 2
store float %46, float* %47
%48 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%49 = load float, float* %48
%50 = getelementptr inbounds float, float* %0, i64 6
store float %49, float* %50
%51 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%52 = load float, float* %51
%53 = getelementptr inbounds float, float* %0, i64 10
store float %52, float* %53
%54 = call float @DotProd3fv(float* %4, float* %23)
%55 = fneg float %54
%56 = getelementptr inbounds float, float* %0, i64 14
store float %55, float* %56
%57 = getelementptr inbounds float, float* %0, i64 3
store float 0.000000e+00, float* %57
%58 = getelementptr inbounds float, float* %0, i64 7
store float 0.000000e+00, float* %58
%59 = getelementptr inbounds float, float* %0, i64 11
store float 0.000000e+00, float* %59
%60 = getelementptr inbounds float, float* %0, i64 15
store float 1.000000e+00, float* %60
ret float* %0
}