#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*/ normvec3i(double *, int, int, int, double *);
double sqrt(double);
void normvec(double *vertex, int v1, int v2, int v3, double *px) {
  double r;
  normvec3i(vertex, v1, v2, v3, px);
  r = sqrt(px[0] * px[0] + px[1] * px[1] + px[2] * px[2]);
  if (r > 0)
    r = 1.0 / r;
  px[0] *= r, px[1] *= r, px[2] *= r;
}


x86 assembly (clang, -O0):
<normvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1030 <normvec3i@plt>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11c1 <normvec+0xa1>
movsd  0xe49(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normvec>:
push   %rbx
mov    %r8,%rbx
call   1030 <normvec3i@plt>
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rbx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1161 <normvec+0x41>
sqrtsd %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     1170 <normvec+0x50>
jmp    1180 <normvec+0x60>
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1180 <normvec+0x60>
movsd  0xe88(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movupd (%rbx),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
mulpd  %xmm1,%xmm2
movupd %xmm2,(%rbx)
mulsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x10(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @normvec(double* %0, i32 %1, i32 %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double
store double* %0, double** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double* %4, double** %10
%12 = load double*, double** %6
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = load double*, double** %10
%17 = call i32 @normvec3i(double* %12, i32 %13, i32 %14, i32 %15, double* %16)
%18 = load double*, double** %10
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = load double*, double** %10
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double*, double** %10
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = load double*, double** %10
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = fmul double %26, %29
%31 = call double @llvm.fmuladd.f64(double %20, double %23, double %30)
%32 = load double*, double** %10
%33 = getelementptr inbounds double, double* %32, i64 2
%34 = load double, double* %33
%35 = load double*, double** %10
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = call double @llvm.fmuladd.f64(double %34, double %37, double %31)
%39 = call double @sqrt(double %38)
store double %39, double* %11
%40 = load double, double* %11
%41 = fcmp ogt double %40, 0.000000e+00
br i1 %41, label %42, label %45
42: ; preds = %5
%43 = load double, double* %11
%44 = fdiv double 1.000000e+00, %43
store double %44, double* %11
br label %45
45: ; preds = %42, %5
%46 = load double, double* %11
%47 = load double*, double** %10
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = fmul double %49, %46
store double %50, double* %48
%51 = load double, double* %11
%52 = load double*, double** %10
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fmul double %54, %51
store double %55, double* %53
%56 = load double, double* %11
%57 = load double*, double** %10
%58 = getelementptr inbounds double, double* %57, i64 2
%59 = load double, double* %58
%60 = fmul double %59, %56
store double %60, double* %58
ret void
}

LLVM IR (-O2):
define void @normvec(double* %0, i32 %1, i32 %2, i32 %3, double* %4) {
%6 = tail call i32 @normvec3i(double* %0, i32 %1, i32 %2, i32 %3, double* %4)
%7 = load double, double* %4
%8 = getelementptr inbounds double, double* %4, i64 1
%9 = load double, double* %8
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %10)
%12 = getelementptr inbounds double, double* %4, i64 2
%13 = load double, double* %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %11)
%15 = tail call double @sqrt(double %14)
%16 = fcmp ogt double %15, 0.000000e+00
%17 = fdiv double 1.000000e+00, %15
%18 = select i1 %16, double %17, double %15
%19 = bitcast double* %4 to <2 x double>*
%20 = load <2 x double>, <2 x double>* %19
%21 = insertelement <2 x double> poison, double %18, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fmul <2 x double> %20, %22
%24 = bitcast double* %4 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
%25 = load double, double* %12
%26 = fmul double %18, %25
store double %26, double* %12
ret void
}