#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 getJx(int, int, int);
double getJy(int, int, int);
double getJz(int, int, int);
double sqrt(double);
double getJ(int i, int j, int k) {
  double val;
  double val_x, val_y, val_z;
  val_x = getJx(i, j, k);
  val_y = getJy(i, j, k);
  val_z = getJz(i, j, k);
  val = sqrt(val_x * val_x + val_y * val_y + val_z * val_z);
  return val;
}


x86 assembly (clang, -O0):
<getJ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <getJx@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <getJy@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <getJz@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getJ>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <getJx@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1060 <getJy@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <getJz@plt>
movsd  (%rsp),%xmm2
mulsd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ad <getJ+0x6d>
sqrtsd %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <sqrt@plt>

LLVM IR (-O0):
define double @getJ(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call double @getJx(i32 %11, i32 %12, i32 %13)
store double %14, double* %8
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = call double @getJy(i32 %15, i32 %16, i32 %17)
store double %18, double* %9
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call double @getJz(i32 %19, i32 %20, i32 %21)
store double %22, double* %10
%23 = load double, double* %8
%24 = load double, double* %8
%25 = load double, double* %9
%26 = load double, double* %9
%27 = fmul double %25, %26
%28 = call double @llvm.fmuladd.f64(double %23, double %24, double %27)
%29 = load double, double* %10
%30 = load double, double* %10
%31 = call double @llvm.fmuladd.f64(double %29, double %30, double %28)
%32 = call double @sqrt(double %31)
store double %32, double* %7
%33 = load double, double* %7
ret double %33
}

LLVM IR (-O2):
define double @getJ(i32 %0, i32 %1, i32 %2) {
%4 = tail call double @getJx(i32 %0, i32 %1, i32 %2)
%5 = tail call double @getJy(i32 %0, i32 %1, i32 %2)
%6 = tail call double @getJz(i32 %0, i32 %1, i32 %2)
%7 = fmul double %5, %5
%8 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %7)
%9 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %8)
%10 = tail call double @sqrt(double %9)
ret double %10
}