// File: 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
subq $0xb0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl -0x8(%rbp), %eax
subl $0x1, %eax
imull $0x3b, %eax, %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0xc(%rbp), %eax
cltq
movq %rax, -0x50(%rbp)
movl -0x4(%rbp), %eax
movl $0x1e, %ecx
cltd
idivl %ecx
cltq
movq %rax, -0x58(%rbp)
movslq -0x4(%rbp), %rax
imulq $0x1e, -0x58(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x60(%rbp)
imulq $0xb, -0x60(%rbp), %rax
addq $0x3, %rax
movl $0x1e, %ecx
cqto
idivq %rcx
movq %rax, -0x68(%rbp)
imulq $0x194, -0x58(%rbp), %rax # imm = 0x194
imulq $0x162, -0x60(%rbp), %rcx # imm = 0x162
addq %rcx, %rax
addq $0xd0, %rax
addq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl $0x5b5, %ecx            # imm = 0x5B5
cqto
idivq %rcx
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
imulq $0x5b5, -0x78(%rbp), %rcx # imm = 0x5B5
subq %rcx, %rax
movq %rax, -0x80(%rbp)
imulq $0x7, -0x58(%rbp), %rax
addq -0x78(%rbp), %rax
shlq $0x2, %rax
addq $0x26d, %rax            # imm = 0x26D
movq %rax, -0x88(%rbp)
cvtsi2sdq -0x80(%rbp), %xmm0
movsd 0x46db1(%rip), %xmm1    # 0x18e588
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x90(%rbp)
cvtsi2sdq -0x90(%rbp), %xmm0
movsd 0x46d90(%rip), %xmm1    # 0x18e588
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rax
subq -0x98(%rbp), %rax
addq -0x50(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0x88(%rbp), %rax
addq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x16e, -0xa0(%rbp) # imm = 0x16E
jle 0x14787b
movq -0xa8(%rbp), %rax
andq $0x3, %rax
cmpq $0x0, %rax
jne 0x14787b
movq -0xa0(%rbp), %rax
subq $0x16e, %rax            # imm = 0x16E
movq %rax, -0xa0(%rbp)
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
cmpq $0x16d, -0xa0(%rbp) # imm = 0x16D
jle 0x1478bf
movq -0xa8(%rbp), %rax
andq $0x3, %rax
cmpq $0x0, %rax
je 0x1478bf
movq -0xa0(%rbp), %rax
subq $0x16d, %rax            # imm = 0x16D
movq %rax, -0xa0(%rbp)
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
subq $0x1, %rax
cvtsi2sd %rax, %xmm1
movsd 0x46a11(%rip), %xmm0    # 0x18e2e8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x18(%rbp)
movq -0xa0(%rbp), %rax
addq $0x1a444f, %rax         # imm = 0x1A444F
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
cvtsi2sdq -0x18(%rbp), %xmm0
movsd 0x469f9(%rip), %xmm1    # 0x18e300
subsd %xmm1, %xmm0
movsd 0x469e5(%rip), %xmm1    # 0x18e2f8
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
addq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0xb0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x231519, -0x18(%rbp)  # imm = 0x231519
jge 0x147964
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x5f4, %rax            # imm = 0x5F4
movq %rax, -0x30(%rbp)
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x46970(%rip), %xmm1    # 0x18e2f0
subsd %xmm1, %xmm0
movsd 0x4695c(%rip), %xmm1    # 0x18e2e8
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x38(%rbp)
cvtsi2sdq -0x38(%rbp), %xmm1
movsd 0x46941(%rip), %xmm0    # 0x18e2e8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
subq -0x40(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x46917(%rip), %xmm1    # 0x18e2e0
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
subq -0x40(%rbp), %rax
movl %eax, %ecx
leaq 0x224e99(%rip), %rax    # 0x36c880
movl %ecx, (%rax)
cvtsi2sdq -0x48(%rbp), %xmm1
movsd 0x468e9(%rip), %xmm0    # 0x18e2e0
mulsd %xmm1, %xmm0
callq 0x9660
cvttsd2si %xmm0, %rcx
leaq 0x224e74(%rip), %rax    # 0x36c880
movslq (%rax), %rax
subq %rcx, %rax
movl %eax, %ecx
leaq 0x224e65(%rip), %rax    # 0x36c880
movl %ecx, (%rax)
cmpq $0xe, -0x48(%rbp)
jge 0x147a39
movq -0x48(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
leaq 0x224e47(%rip), %rax    # 0x36c87c
movl %ecx, (%rax)
jmp 0x147a4c
movq -0x48(%rbp), %rax
subq $0xd, %rax
movl %eax, %ecx
leaq 0x224e32(%rip), %rax    # 0x36c87c
movl %ecx, (%rax)
leaq 0x224e29(%rip), %rax    # 0x36c87c
cmpl $0x2, (%rax)
jle 0x147a6f
movq -0x38(%rbp), %rax
subq $0x126c, %rax           # imm = 0x126C
movl %eax, %ecx
leaq 0x224e19(%rip), %rax    # 0x36c884
movl %ecx, (%rax)
jmp 0x147a84
movq -0x38(%rbp), %rax
subq $0x126b, %rax           # imm = 0x126B
movl %eax, %ecx
leaq 0x224e02(%rip), %rax    # 0x36c884
movl %ecx, (%rax)
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)