#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 *Cross_f(float *, float *, float *);
int /*<<< orphan*/ Diff_f(float *, float *, float *, int);
double Norm_f(float *, int, int);
float *Normal_f(float *x, float *y, float *z, float *n_out) {
  float v0[3];
  float v1[3];
  float *normal;
  float inv_mag;
  normal = n_out;
  Diff_f(y, x, v0, 3);
  Diff_f(z, x, v1, 3);
  normal = Cross_f(v0, v1, normal);
  inv_mag = 1.0 / Norm_f(normal, 3, 2);
  normal[0] *= inv_mag;
  normal[1] *= inv_mag;
  normal[2] *= inv_mag;
  return normal;
}


x86 assembly (clang, -O0):
<Normal_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x3,%ecx
call   1030 <Diff_f@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x3,%ecx
call   1030 <Diff_f@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1050 <Cross_f@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x3,%esi
mov    $0x2,%edx
call   1040 <Norm_f@plt>
movaps %xmm0,%xmm1
movsd  0xe51(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mulss  (%rax),%xmm0
movss  %xmm0,(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mulss  0x4(%rax),%xmm0
movss  %xmm0,0x4(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mulss  0x8(%rax),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x40(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Normal_f>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
lea    0x14(%rsp),%r12
mov    %rsi,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    $0x3,%ecx
call   1030 <Diff_f@plt>
lea    0x8(%rsp),%r13
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0x3,%ecx
call   1030 <Diff_f@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <Cross_f@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
call   1040 <Norm_f@plt>
movsd  0xe5f(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  (%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  0x4(%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%rbx)
mulss  0x8(%rbx),%xmm0
movss  %xmm0,0x8(%rbx)
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @Normal_f(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = alloca float*
%12 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%13 = load float*, float** %8
store float* %13, float** %11
%14 = load float*, float** %6
%15 = load float*, float** %5
%16 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%17 = call i32 @Diff_f(float* %14, float* %15, float* %16, i32 3)
%18 = load float*, float** %7
%19 = load float*, float** %5
%20 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%21 = call i32 @Diff_f(float* %18, float* %19, float* %20, i32 3)
%22 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%23 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%24 = load float*, float** %11
%25 = call float* @Cross_f(float* %22, float* %23, float* %24)
store float* %25, float** %11
%26 = load float*, float** %11
%27 = call double @Norm_f(float* %26, i32 3, i32 2)
%28 = fdiv double 1.000000e+00, %27
%29 = fptrunc double %28 to float
store float %29, float* %12
%30 = load float, float* %12
%31 = load float*, float** %11
%32 = getelementptr inbounds float, float* %31, i64 0
%33 = load float, float* %32
%34 = fmul float %33, %30
store float %34, float* %32
%35 = load float, float* %12
%36 = load float*, float** %11
%37 = getelementptr inbounds float, float* %36, i64 1
%38 = load float, float* %37
%39 = fmul float %38, %35
store float %39, float* %37
%40 = load float, float* %12
%41 = load float*, float** %11
%42 = getelementptr inbounds float, float* %41, i64 2
%43 = load float, float* %42
%44 = fmul float %43, %40
store float %44, float* %42
%45 = load float*, float** %11
ret float* %45
}

LLVM IR (-O2):
define float* @Normal_f(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = bitcast [3 x float]* %5 to i8*
%8 = bitcast [3 x float]* %6 to i8*
%9 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%10 = call i32 @Diff_f(float* %1, float* %0, float* %9, i32 3)
%11 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%12 = call i32 @Diff_f(float* %2, float* %0, float* %11, i32 3)
%13 = call float* @Cross_f(float* %9, float* %11, float* %3)
%14 = call double @Norm_f(float* %13, i32 3, i32 2)
%15 = fdiv double 1.000000e+00, %14
%16 = fptrunc double %15 to float
%17 = load float, float* %13
%18 = fmul float %17, %16
store float %18, float* %13
%19 = getelementptr inbounds float, float* %13, i64 1
%20 = load float, float* %19
%21 = fmul float %20, %16
store float %21, float* %19
%22 = getelementptr inbounds float, float* %13, i64 2
%23 = load float, float* %22
%24 = fmul float %23, %16
store float %24, float* %22
ret float* %13
}