#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*/ mult(double *, double *, int, int);
double norm(double *, int);
void reproject_vertices(double **vertices, int nv, int dim) {
  int i;
  for (i = 0; i < nv; i++) {
    double d = norm(vertices[i], dim);
    mult(vertices[i], vertices[i], 1 / d, dim);
  }
}


x86 assembly (clang, -O0):
<reproject_vertices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <reproject_vertices+0x7d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%esi
call   1030 <norm@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movsd  0xe82(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edx
mov    -0x10(%rbp),%ecx
call   1040 <mult@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <reproject_vertices+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reproject_vertices>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1174 <reproject_vertices+0x54>
mov    %edx,%r15d
mov    %rdi,%rbx
mov    %esi,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
mov    %r15d,%esi
call   1030 <norm@plt>
mov    (%rbx,%rbp,8),%rdi
movsd  0xea8(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
mov    %rdi,%rsi
mov    %r15d,%ecx
call   1040 <mult@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1140 <reproject_vertices+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @reproject_vertices(double** %0, i32 %1, i32 %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store double** %0, double*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %36, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
%14 = load double**, double*** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double*, double** %14, i64 %16
%18 = load double*, double** %17
%19 = load i32, i32* %6
%20 = call double @norm(double* %18, i32 %19)
store double %20, double* %8
%21 = load double**, double*** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
%25 = load double*, double** %24
%26 = load double**, double*** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double*, double** %26, i64 %28
%30 = load double*, double** %29
%31 = load double, double* %8
%32 = fdiv double 1.000000e+00, %31
%33 = fptosi double %32 to i32
%34 = load i32, i32* %6
%35 = call i32 @mult(double* %25, double* %30, i32 %33, i32 %34)
br label %36
36: ; preds = %13
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %9
39: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @reproject_vertices(double** nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %16, %7 ]
%9 = getelementptr inbounds double*, double** %0, i64 %8
%10 = load double*, double** %9
%11 = tail call double @norm(double* %10, i32 %2)
%12 = load double*, double** %9
%13 = fdiv double 1.000000e+00, %11
%14 = fptosi double %13 to i32
%15 = tail call i32 @mult(double* %12, double* %12, i32 %14, i32 %2)
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %7, %3
ret void
}