// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: islam_to_greg(int, int, int)
void islam_to_greg(int h, int m, int d)
{
long jd, al, be, b;
long c, d1, e1;

    // convert Islamic date to gregorian
    long n = (59*(m-1)+1)/2 + d;
    long q = h / 30;
    long r = h - q*30;
    long a = (11*r + 3) / 30;
    long w = 404*q + 354*r + 208+a;
    long q1 = w / 1461;
    long q2 = w - 1461*q1;
    long g = 621 + 4*(7*q+q1);
    long k = (long) (q2 / SOLAR_YEAR);
    long e = (long) (k * SOLAR_YEAR);
    long j = q2 - e + n - 1;
    long x = g + k;
    
    if ((j > 366) && !(x&3)) { j -= 366; ++x; }
    if ((j > 365) && (x&3))  { j -= 365; ++x; }
    
    jd = (long) (365.25*(x-1));
    jd += 1721423 + j;
    al = (long) ((jd - 1867216.25) / 36524.25);
    be = jd + 1 + al - al/4;
    if (jd < 2299161) be = jd;
    b = be + 1524;
    c = (long) ((b - 122.1) / 365.25);
    d1 = (long) (365.25 * c);
    e1 = (long) ((b - d1) / 30.6001);
    
    g_day = b - d1;
    g_day -= (long) floor(30.6001*e1);
    if(e1 < 14) g_month = e1 - 1;
    else        g_month = e1 - 13;
    
    if(g_month > 2) g_year = c - 4716;
    else            g_year = c - 4715;
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ecx
imull $0x3b, %esi, %eax
addl $-0x3a, %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
addl %ecx, %eax
movslq %eax, %rcx
pushq $0x1e
popq %rsi
movl %edi, %eax
cltd
idivl %esi
movslq %eax, %rsi
movslq %edi, %rax
imulq $-0x1e, %rsi, %rdi
addq %rax, %rdi
imulq $0xb, %rdi, %rax
addq $0x3, %rax
pushq $0x1e
popq %r8
cqto
idivq %r8
imulq $0x194, %rsi, %rdx      # imm = 0x194
imulq $0x162, %rdi, %rdi      # imm = 0x162
addq %rdx, %rdi
leaq (%rdi,%rax), %r8
addq %rdi, %rax
addq $0xd0, %rax
movl $0x5b5, %edi            # imm = 0x5B5
cqto
idivq %rdi
imulq $-0x5b5, %rax, %rdx     # imm = 0xFA4B
addq %r8, %rdx
addq $0xd0, %rdx
imulq $0x7, %rsi, %rsi
cvtsi2sd %rdx, %xmm0
movsd 0x3b90c(%rip), %xmm1    # 0x115998
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdi
addq %rax, %rsi
leaq (%rdi,%rsi,4), %rax
cvtsi2sd %rdi, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
subq %rsi, %rdx
addq %rcx, %rdx
addq $0x26d, %rax            # imm = 0x26D
cmpq $0x170, %rdx            # imm = 0x170
setge %cl
testb $0x3, %al
sete %sil
andb %cl, %sil
movzbl %sil, %ecx
leal -0x1(%rcx), %esi
orq $-0x16f, %rsi           # imm = 0xFE91
leaq (%rsi,%rdx), %rdi
orq %rax, %rcx
cmpq $0x16e, %rdi            # imm = 0x16E
setge %al
testb $0x3, %cl
setne %r8b
andb %al, %r8b
leaq -0x16d(%rsi,%rdx), %rax
cmoveq %rdi, %rax
movzbl %r8b, %edx
leaq -0x1(%rcx,%rdx), %rcx
cvtsi2sd %rcx, %xmm1
movsd 0x3b5d4(%rip), %xmm0    # 0x1156e8
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
leaq (%rax,%rcx), %rdx
leaq 0x1a444f(%rax,%rcx), %rcx
cvtsi2sd %rcx, %xmm1
addsd 0x3b59a(%rip), %xmm1    # 0x1156d0
divsd 0x3b59a(%rip), %xmm1    # 0x1156d8
cvttsd2si %xmm1, %rax
leaq 0x1a444f(%rax,%rdx), %rsi
pushq $-0x4
popq %rdi
cqto
idivq %rdi
leaq (%rax,%rsi), %r14
incq %r14
cmpq $0x231519, %rcx         # imm = 0x231519
cmovlq %rcx, %r14
addq $0x5f4, %r14            # imm = 0x5F4
cvtsi2sd %r14, %xmm1
addsd 0x3b567(%rip), %xmm1    # 0x1156e0
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %rbx
cvtsi2sd %rbx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
subq %rax, %r14
cvtsi2sd %r14, %xmm0
movsd 0x3b550(%rip), %xmm1    # 0x1156f0
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %r15
cvtsi2sd %r15, %xmm0
mulsd %xmm1, %xmm0
callq 0x9680
cvttsd2si %xmm0, %rax
subl %eax, %r14d
leaq 0x21d4da(%rip), %rax    # 0x2f76a0
movl %r14d, (%rax)
xorl %eax, %eax
cmpq $0xe, %r15
setl %al
negl %eax
orl $-0xd, %eax
addl %r15d, %eax
leaq 0x21d4bb(%rip), %rcx    # 0x2f769c
movl %eax, (%rcx)
xorl %ecx, %ecx
cmpl $0x3, %eax
setge %cl
xorl $0xffffed95, %ecx       # imm = 0xFFFFED95
addl %ebx, %ecx
leaq 0x21d4aa(%rip), %rax    # 0x2f76a4
movl %ecx, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq