// File: /workspace/github_cpp_makefile_star2_O1/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
imull $0x3b, %esi, %eax
movl %eax, %ecx
addl $-0x3a, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
addl $-0x3a, %eax
sarl %eax
addl %edx, %eax
movslq %eax, %rcx
movslq %edi, %rax
imulq $-0x77777777, %rax, %rdx # imm = 0x88888889
shrq $0x20, %rdx
addl %eax, %edx
movl %edx, %esi
shrl $0x1f, %esi
sarl $0x4, %edx
addl %esi, %edx
movslq %edx, %rsi
imulq $-0x1e, %rsi, %rdi
addq %rax, %rdi
leaq (%rdi,%rdi,4), %rax
leaq (%rdi,%rax,2), %r8
leaq (%rdi,%rax,2), %rax
addq $0x3, %rax
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
imulq %rdx
leaq (%rdx,%r8), %rax
addq $0x3, %rax
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x4, %rax
addq %rdx, %rax
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
movabsq $-0x4c927c686ebd9737, %rdx # imm = 0xB36D8397914268C9
imulq %rdx
addq %r8, %rdx
addq $0xd0, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xa, %rdx
addq %rax, %rdx
imulq $-0x5b5, %rdx, %rax     # imm = 0xFA4B
addq %r8, %rax
addq $0xd0, %rax
leaq (,%rsi,8), %rdi
subq %rsi, %rdi
addq %rdx, %rdi
cvtsi2sd %rax, %xmm0
movsd 0x3d5ce(%rip), %xmm1    # 0x12b980
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdx
leaq (%rdx,%rdi,4), %rsi
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdx
subq %rdx, %rax
addq %rcx, %rax
addq $0x26d, %rsi            # imm = 0x26D
cmpq $0x170, %rax            # imm = 0x170
setge %cl
testb $0x3, %sil
sete %dl
andb %cl, %dl
movzbl %dl, %ecx
leal -0x1(%rcx), %edx
orq $-0x16f, %rdx           # imm = 0xFE91
leaq (%rdx,%rax), %rdi
orq %rsi, %rcx
cmpq $0x16e, %rdi            # imm = 0x16E
setge %sil
testb $0x3, %cl
setne %r8b
andb %sil, %r8b
leaq -0x16d(%rdx,%rax), %rax
cmoveq %rdi, %rax
movzbl %r8b, %edx
addq %rdx, %rcx
decq %rcx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
movsd 0x3d282(%rip), %xmm0    # 0x12b6c0
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
leaq 0x1a444f(%rax,%rcx), %rdx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
addsd 0x3d249(%rip), %xmm1    # 0x12b6a8
divsd 0x3d249(%rip), %xmm1    # 0x12b6b0
cvttsd2si %xmm1, %rsi
addq %rcx, %rax
leaq (%rsi,%rax), %r14
addq $0x1a444f, %r14         # imm = 0x1A444F
leaq 0x3(%rsi), %rax
testq %rsi, %rsi
cmovnsq %rsi, %rax
sarq $0x2, %rax
subq %rax, %r14
incq %r14
cmpq $0x231519, %rdx         # imm = 0x231519
cmovlq %rdx, %r14
addq $0x5f4, %r14            # imm = 0x5F4
xorps %xmm1, %xmm1
cvtsi2sd %r14, %xmm1
addsd 0x3d207(%rip), %xmm1    # 0x12b6b8
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %rbx
xorps %xmm1, %xmm1
cvtsi2sd %rbx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
subq %rax, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movsd 0x3d1ea(%rip), %xmm1    # 0x12b6c8
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %r15
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
mulsd %xmm1, %xmm0
callq 0x9680
cvttsd2si %xmm0, %rax
subl %eax, %r14d
leaq 0x21f199(%rip), %rax    # 0x30d6a0
movl %r14d, (%rax)
xorl %eax, %eax
cmpq $0xe, %r15
setl %al
negl %eax
orl $-0xd, %eax
addl %r15d, %eax
leaq 0x21f17a(%rip), %rcx    # 0x30d69c
movl %eax, (%rcx)
xorl %ecx, %ecx
cmpl $0x3, %eax
setge %cl
xorl $0xffffed95, %ecx       # imm = 0xFFFFED95
addl %ebx, %ecx
leaq 0x21f169(%rip), %rax    # 0x30d6a4
movl %ecx, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq