#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 IGRFCall(double, double, double, double, double *, double *, double *);
double sqrt(double);
int IGRFMagCmp(double date, double frho, double flat, double flon, double *bx,
               double *by, double *bz, double *b) {
  int s;
  frho = frho - 6372.;
  s = IGRFCall(date, flat, flon, frho, bx, by, bz);
  *b = sqrt(*bx * *bx + *by * *by + *bz * *bz);
  *bx = -*bx;
  *bz = -*bz;
  return s;
}


x86 assembly (clang, -O0):
<IGRFMagCmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <IGRFCall@plt>
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IGRFMagCmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
movapd %xmm1,%xmm4
addsd  0xec0(%rip),%xmm4
movaps %xmm2,%xmm1
movaps %xmm3,%xmm2
movapd %xmm4,%xmm3
call   1030 <IGRFCall@plt>
mov    %eax,%r12d
movsd  (%rbx),%xmm1
movsd  0x0(%rbp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  (%r14),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1184 <IGRFMagCmp+0x64>
sqrtsd %xmm0,%xmm0
jmp    1189 <IGRFMagCmp+0x69>
call   1040 <sqrt@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm0
movaps 0xe77(%rip),%xmm1
xorps  %xmm1,%xmm0
movlps %xmm0,(%rbx)
movsd  (%r14),%xmm0
xorps  %xmm1,%xmm0
movlps %xmm0,(%r14)
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @IGRFMagCmp(double %0, double %1, double %2, double %3, double* %4, double* %5, double* %6, double* %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store double* %7, double** %16
%18 = load double, double* %10
%19 = fsub double %18, 6.372000e+03
store double %19, double* %10
%20 = load double, double* %9
%21 = load double, double* %11
%22 = load double, double* %12
%23 = load double, double* %10
%24 = load double*, double** %13
%25 = load double*, double** %14
%26 = load double*, double** %15
%27 = call i32 @IGRFCall(double %20, double %21, double %22, double %23, double* %24, double* %25, double* %26)
store i32 %27, i32* %17
%28 = load double*, double** %13
%29 = load double, double* %28
%30 = load double*, double** %13
%31 = load double, double* %30
%32 = load double*, double** %14
%33 = load double, double* %32
%34 = load double*, double** %14
%35 = load double, double* %34
%36 = fmul double %33, %35
%37 = call double @llvm.fmuladd.f64(double %29, double %31, double %36)
%38 = load double*, double** %15
%39 = load double, double* %38
%40 = load double*, double** %15
%41 = load double, double* %40
%42 = call double @llvm.fmuladd.f64(double %39, double %41, double %37)
%43 = call double @sqrt(double %42)
%44 = load double*, double** %16
store double %43, double* %44
%45 = load double*, double** %13
%46 = load double, double* %45
%47 = fneg double %46
%48 = load double*, double** %13
store double %47, double* %48
%49 = load double*, double** %15
%50 = load double, double* %49
%51 = fneg double %50
%52 = load double*, double** %15
store double %51, double* %52
%53 = load i32, i32* %17
ret i32 %53
}

LLVM IR (-O2):
define i32 @IGRFMagCmp(double %0, double %1, double %2, double %3, double* %4, double* %5, double* %6, double* nocapture writeonly %7) {
%9 = fadd double %1, -6.372000e+03
%10 = tail call i32 @IGRFCall(double %0, double %2, double %3, double %9, double* %4, double* %5, double* %6)
%11 = load double, double* %4
%12 = load double, double* %5
%13 = fmul double %12, %12
%14 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %13)
%15 = load double, double* %6
%16 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %14)
%17 = tail call double @sqrt(double %16)
store double %17, double* %7
%18 = load double, double* %4
%19 = fneg double %18
store double %19, double* %4
%20 = load double, double* %6
%21 = fneg double %20
store double %21, double* %6
ret i32 %10
}