#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 */
void cp_normalize_point(double result[3], const double x[3], double (*dx)[3]) {
  int i;
  for (i = 0; i < 3; ++i) {
    result[i] = x[i] / x[2];
  }
  if (dx != NULL) {
    dx[0][0] = 1.0 / x[2];
    dx[0][1] = 0.0;
    dx[0][2] = 0.0;
    dx[1][0] = 0.0;
    dx[1][1] = 1.0 / x[2];
    dx[1][2] = 0.0;
    dx[2][0] = -x[0] / x[2] / x[2];
    dx[2][1] = -x[1] / x[2] / x[2];
    dx[2][2] = 0.0;
  }
}


x86 assembly (clang, -O0):
<cp_normalize_point>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1152 <cp_normalize_point+0x52>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <cp_normalize_point+0x17>
cmpq   $0x0,-0x18(%rbp)
je     1241 <cp_normalize_point+0x141>
mov    -0x10(%rbp),%rax
movsd  0xe97(%rip),%xmm0
divsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe5a(%rip),%xmm0
divsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cp_normalize_point>:
movsd  (%rsi),%xmm0
divsd  0x10(%rsi),%xmm0
movsd  %xmm0,(%rdi)
movsd  0x8(%rsi),%xmm0
divsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x8(%rdi)
movsd  0x10(%rsi),%xmm0
divsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rdi)
test   %rdx,%rdx
je     11ac <cp_normalize_point+0xac>
movsd  0xec9(%rip),%xmm0
movapd %xmm0,%xmm1
divsd  0x10(%rsi),%xmm1
movsd  %xmm1,(%rdx)
xorpd  %xmm1,%xmm1
movupd %xmm1,0x8(%rdx)
movq   $0x0,0x18(%rdx)
divsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx)
movq   $0x0,0x28(%rdx)
movsd  (%rsi),%xmm0
movapd 0xe9d(%rip),%xmm1
xorpd  %xmm1,%xmm0
movsd  0x10(%rsi),%xmm2
divsd  %xmm2,%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x30(%rdx)
movsd  0x8(%rsi),%xmm0
xorpd  %xmm1,%xmm0
movsd  0x10(%rsi),%xmm1
divsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x38(%rdx)
movq   $0x0,0x40(%rdx)
ret

LLVM IR (-O0):
define void @cp_normalize_point(double* %0, double* %1, [3 x double]* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca [3 x double]*
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store [3 x double]* %2, [3 x double]** %6
store i32 0, i32* %7
br label %8
8: ; preds = %25, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load double*, double** %5
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = fdiv double %16, %19
%21 = load double*, double** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
store double %20, double* %24
br label %25
25: ; preds = %11
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %8
28: ; preds = %8
%29 = load [3 x double]*, [3 x double]** %6
%30 = icmp ne [3 x double]* %29, null
br i1 %30, label %31, label %91
31: ; preds = %28
%32 = load double*, double** %5
%33 = getelementptr inbounds double, double* %32, i64 2
%34 = load double, double* %33
%35 = fdiv double 1.000000e+00, %34
%36 = load [3 x double]*, [3 x double]** %6
%37 = getelementptr inbounds [3 x double], [3 x double]* %36, i64 0
%38 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 0, i64 0
store double %35, double* %38
%39 = load [3 x double]*, [3 x double]** %6
%40 = getelementptr inbounds [3 x double], [3 x double]* %39, i64 0
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 0, i64 1
store double 0.000000e+00, double* %41
%42 = load [3 x double]*, [3 x double]** %6
%43 = getelementptr inbounds [3 x double], [3 x double]* %42, i64 0
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 0, i64 2
store double 0.000000e+00, double* %44
%45 = load [3 x double]*, [3 x double]** %6
%46 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 1
%47 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 0, i64 0
store double 0.000000e+00, double* %47
%48 = load double*, double** %5
%49 = getelementptr inbounds double, double* %48, i64 2
%50 = load double, double* %49
%51 = fdiv double 1.000000e+00, %50
%52 = load [3 x double]*, [3 x double]** %6
%53 = getelementptr inbounds [3 x double], [3 x double]* %52, i64 1
%54 = getelementptr inbounds [3 x double], [3 x double]* %53, i64 0, i64 1
store double %51, double* %54
%55 = load [3 x double]*, [3 x double]** %6
%56 = getelementptr inbounds [3 x double], [3 x double]* %55, i64 1
%57 = getelementptr inbounds [3 x double], [3 x double]* %56, i64 0, i64 2
store double 0.000000e+00, double* %57
%58 = load double*, double** %5
%59 = getelementptr inbounds double, double* %58, i64 0
%60 = load double, double* %59
%61 = fneg double %60
%62 = load double*, double** %5
%63 = getelementptr inbounds double, double* %62, i64 2
%64 = load double, double* %63
%65 = fdiv double %61, %64
%66 = load double*, double** %5
%67 = getelementptr inbounds double, double* %66, i64 2
%68 = load double, double* %67
%69 = fdiv double %65, %68
%70 = load [3 x double]*, [3 x double]** %6
%71 = getelementptr inbounds [3 x double], [3 x double]* %70, i64 2
%72 = getelementptr inbounds [3 x double], [3 x double]* %71, i64 0, i64 0
store double %69, double* %72
%73 = load double*, double** %5
%74 = getelementptr inbounds double, double* %73, i64 1
%75 = load double, double* %74
%76 = fneg double %75
%77 = load double*, double** %5
%78 = getelementptr inbounds double, double* %77, i64 2
%79 = load double, double* %78
%80 = fdiv double %76, %79
%81 = load double*, double** %5
%82 = getelementptr inbounds double, double* %81, i64 2
%83 = load double, double* %82
%84 = fdiv double %80, %83
%85 = load [3 x double]*, [3 x double]** %6
%86 = getelementptr inbounds [3 x double], [3 x double]* %85, i64 2
%87 = getelementptr inbounds [3 x double], [3 x double]* %86, i64 0, i64 1
store double %84, double* %87
%88 = load [3 x double]*, [3 x double]** %6
%89 = getelementptr inbounds [3 x double], [3 x double]* %88, i64 2
%90 = getelementptr inbounds [3 x double], [3 x double]* %89, i64 0, i64 2
store double 0.000000e+00, double* %90
br label %91
91: ; preds = %31, %28
ret void
}

LLVM IR (-O2):
define void @cp_normalize_point(double* nocapture writeonly %0, double* nocapture %1, [3 x double]* writeonly %2) {
%4 = getelementptr inbounds double, double* %1, i64 2
%5 = load double, double* %1
%6 = load double, double* %4
%7 = fdiv double %5, %6
store double %7, double* %0
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = load double, double* %4
%11 = fdiv double %9, %10
%12 = getelementptr inbounds double, double* %0, i64 1
store double %11, double* %12
%13 = load double, double* %4
%14 = fdiv double %13, %13
%15 = getelementptr inbounds double, double* %0, i64 2
store double %14, double* %15
%16 = icmp eq [3 x double]* %2, null
br i1 %16, label %40, label %17
17: ; preds = %3
%18 = load double, double* %4
%19 = fdiv double 1.000000e+00, %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
store double %19, double* %20
%21 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%22 = bitcast double* %21 to i8*
%23 = load double, double* %4
%24 = fdiv double 1.000000e+00, %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 1
store double %24, double* %25
%26 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 2
store double 0.000000e+00, double* %26
%27 = load double, double* %1
%28 = fneg double %27
%29 = load double, double* %4
%30 = fdiv double %28, %29
%31 = fdiv double %30, %29
%32 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 0
store double %31, double* %32
%33 = load double, double* %8
%34 = fneg double %33
%35 = load double, double* %4
%36 = fdiv double %34, %35
%37 = fdiv double %36, %35
%38 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 1
store double %37, double* %38
%39 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 2
store double 0.000000e+00, double* %39
br label %40
40: ; preds = %17, %3
ret void
}