#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*/ geoMagInit();
int /*<<< orphan*/ geomg1(double, double, double, double, double *, double *,
                          double *, double *);
int geoMagGetDec(double lat, double lon, double hgt, int month, int day,
                 int year, double *dec) {
  int jday[] = {0, 0, 31, 59, 90, 120, 151, 180, 211, 242, 272, 303, 333};
  double time, dip, ti, gv;
  time = ((jday[month] + day) / 365.0) + year;
  geoMagInit();
  geomg1(hgt, lat, lon, time, dec, &dip, &ti, &gv);
  return (0);
}


x86 assembly (clang, -O0):
<geoMagGetDec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeae(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
add    -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe7d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    $0x0,%al
call   1040 <geoMagInit@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm3
mov    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x88(%rbp),%rdx
lea    -0x90(%rbp),%rcx
call   1030 <geomg1@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geoMagGetDec>:
push   %rbx
sub    $0x40,%rsp
movslq %edi,%rax
lea    0xee1(%rip),%rdi
add    (%rdi,%rax,4),%esi
cvtsi2sd %esi,%xmm3
divsd  0xec2(%rip),%xmm3
mov    %rcx,%rbx
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1040 <geoMagInit@plt>
lea    0x38(%rsp),%rsi
lea    0x30(%rsp),%rdx
lea    0x28(%rsp),%rcx
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
mov    %rbx,%rdi
call   1030 <geomg1@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.geoMagGetDec.jday = [13 x i32] [i32 0, i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 180, i32 211, i32 242, i32 272, i32 303, i32 333]
define i32 @geoMagGetDec(double %0, double %1, double %2, i32 %3, i32 %4, i32 %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca [13 x i32]
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store double* %6, double** %14
%20 = bitcast [13 x i32]* %15 to i8*
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [13 x i32], [13 x i32]* %15, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = load i32, i32* %12
%26 = add nsw i32 %24, %25
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 3.650000e+02
%29 = load i32, i32* %13
%30 = sitofp i32 %29 to double
%31 = fadd double %28, %30
store double %31, double* %16
%32 = call i32 (...) @geoMagInit()
%33 = load double, double* %10
%34 = load double, double* %8
%35 = load double, double* %9
%36 = load double, double* %16
%37 = load double*, double** %14
%38 = call i32 @geomg1(double %33, double %34, double %35, double %36, double* %37, double* %17, double* %18, double* %19)
ret i32 0
}

LLVM IR (-O2):
@__const.geoMagGetDec.jday = [13 x i32] [i32 0, i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 180, i32 211, i32 242, i32 272, i32 303, i32 333]
define i32 @geoMagGetDec(double %0, double %1, double %2, i32 %3, i32 %4, i32 %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = bitcast double* %8 to i8*
%12 = bitcast double* %9 to i8*
%13 = bitcast double* %10 to i8*
%14 = sext i32 %3 to i64
%15 = getelementptr inbounds [13 x i32], [13 x i32]* @__const.geoMagGetDec.jday, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = add nsw i32 %16, %4
%18 = sitofp i32 %17 to double
%19 = fdiv double %18, 3.650000e+02
%20 = sitofp i32 %5 to double
%21 = fadd double %19, %20
%22 = tail call i32 (...) @geoMagInit()
%23 = call i32 @geomg1(double %2, double %0, double %1, double %21, double* %6, double* %8, double* %9, double* %10)
ret i32 0
}