#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 */
double dot(double *, double *);
void plane_xyz(long num, double **xyz, double *ppos, double *nml,
               double **nxyz) {
  long i, j;
  double temp, d[4];
  for (i = 1; i <= num; i++) {
    for (j = 1; j <= 3; j++)
      d[j] = xyz[i][j] - ppos[j];
    temp = dot(d, nml);
    for (j = 1; j <= 3; j++)
      nxyz[i][j] = ppos[j] + d[j] - temp * nml[j];
  }
}


x86 assembly (clang, -O0):
<plane_xyz>:
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)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x8(%rbp),%rax
jg     123b <plane_xyz+0x12b>
movq   $0x1,-0x38(%rbp)
cmpq   $0x3,-0x38(%rbp)
jg     1192 <plane_xyz+0x82>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    114a <plane_xyz+0x3a>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <dot@plt>
movsd  %xmm0,-0x40(%rbp)
movq   $0x1,-0x38(%rbp)
cmpq   $0x3,-0x38(%rbp)
jg     1225 <plane_xyz+0x115>
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x38(%rbp),%rax
addsd  -0x60(%rbp,%rax,8),%xmm1
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11ac <plane_xyz+0x9c>
jmp    122a <plane_xyz+0x11a>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1134 <plane_xyz+0x24>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plane_xyz>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdi,%rdi
jle    11dc <plane_xyz+0xcc>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x8(%r12,%rbp,8),%rax
movupd 0x8(%rax),%xmm0
movupd 0x8(%rbx),%xmm1
subpd  %xmm1,%xmm0
movupd %xmm0,0x8(%rsp)
movsd  0x18(%rax),%xmm0
subsd  0x18(%rbx),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %rsp,%rdi
mov    %r15,%rsi
call   1030 <dot@plt>
mov    0x8(%r14,%rbp,8),%rax
movsd  0x8(%rbx),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x8(%r15),%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rax)
movsd  0x10(%rbx),%xmm1
movsd  0x10(%r15),%xmm2
addsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rax)
movsd  0x18(%rbx),%xmm1
mulsd  0x18(%r15),%xmm0
addsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rax)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1140 <plane_xyz+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @plane_xyz(i64 %0, double** %1, double* %2, double* %3, double** %4) {
%6 = alloca i64
%7 = alloca double**
%8 = alloca double*
%9 = alloca double*
%10 = alloca double**
%11 = alloca i64
%12 = alloca i64
%13 = alloca double
%14 = alloca [4 x double]
store i64 %0, i64* %6
store double** %1, double*** %7
store double* %2, double** %8
store double* %3, double** %9
store double** %4, double*** %10
store i64 1, i64* %11
br label %15
15: ; preds = %74, %5
%16 = load i64, i64* %11
%17 = load i64, i64* %6
%18 = icmp sle i64 %16, %17
br i1 %18, label %19, label %77
19: ; preds = %15
store i64 1, i64* %12
br label %20
20: ; preds = %38, %19
%21 = load i64, i64* %12
%22 = icmp sle i64 %21, 3
br i1 %22, label %23, label %41
23: ; preds = %20
%24 = load double**, double*** %7
%25 = load i64, i64* %11
%26 = getelementptr inbounds double*, double** %24, i64 %25
%27 = load double*, double** %26
%28 = load i64, i64* %12
%29 = getelementptr inbounds double, double* %27, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %8
%32 = load i64, i64* %12
%33 = getelementptr inbounds double, double* %31, i64 %32
%34 = load double, double* %33
%35 = fsub double %30, %34
%36 = load i64, i64* %12
%37 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 %36
store double %35, double* %37
br label %38
38: ; preds = %23
%39 = load i64, i64* %12
%40 = add nsw i64 %39, 1
store i64 %40, i64* %12
br label %20
41: ; preds = %20
%42 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 0
%43 = load double*, double** %9
%44 = call double @dot(double* %42, double* %43)
store double %44, double* %13
store i64 1, i64* %12
br label %45
45: ; preds = %70, %41
%46 = load i64, i64* %12
%47 = icmp sle i64 %46, 3
br i1 %47, label %48, label %73
48: ; preds = %45
%49 = load double*, double** %8
%50 = load i64, i64* %12
%51 = getelementptr inbounds double, double* %49, i64 %50
%52 = load double, double* %51
%53 = load i64, i64* %12
%54 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0, i64 %53
%55 = load double, double* %54
%56 = fadd double %52, %55
%57 = load double, double* %13
%58 = load double*, double** %9
%59 = load i64, i64* %12
%60 = getelementptr inbounds double, double* %58, i64 %59
%61 = load double, double* %60
%62 = fneg double %57
%63 = call double @llvm.fmuladd.f64(double %62, double %61, double %56)
%64 = load double**, double*** %10
%65 = load i64, i64* %11
%66 = getelementptr inbounds double*, double** %64, i64 %65
%67 = load double*, double** %66
%68 = load i64, i64* %12
%69 = getelementptr inbounds double, double* %67, i64 %68
store double %63, double* %69
br label %70
70: ; preds = %48
%71 = load i64, i64* %12
%72 = add nsw i64 %71, 1
store i64 %72, i64* %12
br label %45
73: ; preds = %45
br label %74
74: ; preds = %73
%75 = load i64, i64* %11
%76 = add nsw i64 %75, 1
store i64 %76, i64* %11
br label %15
77: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @plane_xyz(i64 %0, double** nocapture %1, double* nocapture %2, double* %3, double** nocapture %4) {
%6 = alloca [4 x double]
%7 = bitcast [4 x double]* %6 to i8*
%8 = icmp slt i64 %0, 1
br i1 %8, label %59, label %9
9: ; preds = %5
%10 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%11 = getelementptr inbounds double, double* %2, i64 1
%12 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 1
%13 = getelementptr inbounds double, double* %2, i64 2
%14 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 2
%15 = getelementptr inbounds double, double* %2, i64 3
%16 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 3
%17 = getelementptr inbounds double, double* %3, i64 1
%18 = getelementptr inbounds double, double* %3, i64 2
%19 = getelementptr inbounds double, double* %3, i64 3
%20 = bitcast double* %11 to <2 x double>*
%21 = bitcast double* %12 to <2 x double>*
br label %22
22: ; preds = %9, %22
%23 = phi i64 [ 1, %9 ], [ %57, %22 ]
%24 = getelementptr inbounds double*, double** %1, i64 %23
%25 = load double*, double** %24
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = load <2 x double>, <2 x double>* %20
%30 = fsub <2 x double> %28, %29
store <2 x double> %30, <2 x double>* %21
%31 = getelementptr inbounds double, double* %25, i64 3
%32 = load double, double* %31
%33 = load double, double* %15
%34 = fsub double %32, %33
store double %34, double* %16
%35 = call double @dot(double* %10, double* %3)
%36 = fneg double %35
%37 = getelementptr inbounds double*, double** %4, i64 %23
%38 = load double*, double** %37
%39 = load double, double* %11
%40 = load double, double* %12
%41 = fadd double %39, %40
%42 = load double, double* %17
%43 = call double @llvm.fmuladd.f64(double %36, double %42, double %41)
%44 = getelementptr inbounds double, double* %38, i64 1
store double %43, double* %44
%45 = load double, double* %13
%46 = load double, double* %14
%47 = fadd double %45, %46
%48 = load double, double* %18
%49 = call double @llvm.fmuladd.f64(double %36, double %48, double %47)
%50 = getelementptr inbounds double, double* %38, i64 2
store double %49, double* %50
%51 = load double, double* %15
%52 = load double, double* %16
%53 = fadd double %51, %52
%54 = load double, double* %19
%55 = call double @llvm.fmuladd.f64(double %36, double %54, double %53)
%56 = getelementptr inbounds double, double* %38, i64 3
store double %55, double* %56
%57 = add nuw i64 %23, 1
%58 = icmp eq i64 %23, %0
br i1 %58, label %59, label %22
59: ; preds = %22, %5
ret void
}