// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/shg.c
// Function: de_run_shg
static void de_run_shg(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;

	d = de_malloc(c, sizeof(lctx));

	d->shg_startpos = 0;
	d->signature = de_getu16le(d->shg_startpos);
	if(d->signature==0x506c) {
		de_declare_fmt(c, "SHG");
	}
	else if(d->signature==0x706c) {
		de_declare_fmt(c, "MRB");
	}
	else {
		de_warn(c, "This is probably not an SHG/MRB file.");
	}

	do_shg(c, d);

	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
pushq $0x18
popq %rsi
callq 0xdecaf
movq %rax, %r15
andq $0x0, 0x8(%rax)
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0xe3fa3
movq %rax, (%r15)
cmpq $0x706c, %rax           # imm = 0x706C
je 0xbdc1f
cmpq $0x506c, %rax           # imm = 0x506C
jne 0xbdc30
leaq 0x70413(%rip), %rsi     # 0x12e030
jmp 0xbdc26
leaq 0x5650f(%rip), %rsi     # 0x114135
movq %rbx, %rdi
callq 0xe07f7
jmp 0xbdc41
leaq 0x703fd(%rip), %rsi     # 0x12e034
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
movq 0x18(%rbx), %rdi
movq 0x8(%r15), %rsi
addq $0x2, %rsi
callq 0xe3fa3
movq %rax, 0x10(%r15)
leaq 0x703fd(%rip), %rsi     # 0x12e05a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xe6ccb
testl %eax, %eax
je 0xbe61f
pushq $0x4
popq %r12
xorl %r14d, %r14d
movq %r15, 0x8(%rsp)
cmpq 0x10(%r15), %r14
jge 0xbe61f
movq %rbx, %rdi
pushq $0x70
popq %rsi
callq 0xdecaf
movq %rax, %r13
movq %rbx, %rdi
leaq 0x703ce(%rip), %rsi     # 0x12e079
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq 0x8(%r15), %rsi
addq %r12, %rsi
callq 0xe409f
movq %rax, %rbp
addq 0x8(%r15), %rbp
movq %rbx, %rdi
leaq 0x703a4(%rip), %rsi     # 0x12e085
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rbp
jge 0xbe609
movq %rbp, %rsi
callq 0xe3eb4
movb %al, (%r13)
movq 0x18(%rbx), %rdi
leaq 0x1(%rbp), %rsi
callq 0xe3eb4
movb %al, 0x1(%r13)
movzbl (%r13), %edx
leal -0x5(%rdx), %eax
leaq 0x611bd(%rip), %rcx     # 0x11eee1
cmpb $0x3, %al
ja 0xbdd39
movzbl %al, %eax
leaq 0x70606(%rip), %rsi     # 0x12e338
movslq (%rsi,%rax,4), %rcx
addq %rsi, %rcx
movq %rbx, %rdi
leaq 0x7035e(%rip), %rsi     # 0x12e0a1
xorl %eax, %eax
callq 0xde896
movzbl 0x1(%r13), %edx
movq %rbx, %rdi
leaq 0x7035e(%rip), %rsi     # 0x12e0b7
xorl %eax, %eax
callq 0xde896
movzbl (%r13), %edx
leal -0x5(%rdx), %eax
cmpl $0x2, %eax
jae 0xbddd9
movq %r14, 0x10(%rsp)
leaq 0x2(%rbp), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x8(%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x10(%r13)
movl 0x8(%r13), %edx
movq %rbx, %rdi
leaq 0x5e31c(%rip), %rsi     # 0x11c0ca
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x8(%r13), %rax
cmpq $0xa, %rax
jge 0xbdf0c
movq %r13, %rax
addq $0x8, %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
jmp 0xbdf32
cmpl $0x8, %edx
jne 0xbe134
movq %r14, 0x10(%rsp)
movq %r12, (%rsp)
leaq 0x2(%rbp), %rax
movq %rax, 0x48(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x48(%rsp), %r12
movq %r12, %rsi
callq 0xee04e
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq 0x48(%rsp), %rsi
callq 0xe3fa3
movq %rax, %r15
movq 0x48(%rsp), %rsi
addq $0x2, %rsi
movq %rsi, 0x48(%rsp)
movq 0x18(%rbx), %rdi
callq 0xe3fa3
addq $0x2, 0x48(%rsp)
movq %rbx, %rdi
leaq 0x7044a(%rip), %rsi     # 0x12e28a
movl %r14d, %edx
movl %r15d, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xee0cd
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq %r12, %r14
callq 0xee0cd
movq %rax, %r12
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq 0x48(%rsp), %rsi
callq 0xe409f
movq %rax, %r15
movq 0x48(%rsp), %rsi
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
addq %rbp, %r15
movq 0x18(%rbx), %rdi
callq 0xe409f
addq $0x4, 0x48(%rsp)
addl %eax, %ebp
movq %rbx, %rdi
leaq 0x703f8(%rip), %rsi     # 0x12e2b7
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
leaq 0x703f8(%rip), %rsi     # 0x12e2ce
movl %ebp, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0xde896
leaq (%r15,%r12), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xbe192
movq %rbx, %rdi
leaq 0x703eb(%rip), %rsi     # 0x12e2e9
xorl %eax, %eax
callq 0xdf2a5
xorl %ebp, %ebp
jmp 0xbe21a
cmpq $0x7530, %rax           # imm = 0x7530
ja 0xbddc5
movq 0x10(%r13), %rax
movq $-0x7531, %rcx          # imm = 0x8ACF
addq %rcx, %rax
cmpq $-0x7528, %rax          # imm = 0x8AD8
jbe 0xbddc5
movq %r12, (%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee04e
movq %rax, 0x18(%r13)
movq %rbx, %rdi
leaq 0x7026f(%rip), %rsi     # 0x12e1bf
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee04e
movq %rax, 0x20(%r13)
movq %rbx, %rdi
leaq 0x70174(%rip), %rsi     # 0x12e0e7
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x30(%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x38(%r13)
movq 0x30(%r13), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdf038
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x58(%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x60(%r13)
movl 0x58(%r13), %edx
movq %rbx, %rdi
leaq 0x7011b(%rip), %rsi     # 0x12e0f4
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
cmpq $0x1, 0x60(%r13)
jne 0xbdfff
movq %rbx, %rdi
leaq 0x7011e(%rip), %rsi     # 0x12e111
xorl %eax, %eax
callq 0xdf05a
andq $0x0, 0x60(%r13)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %r13, 0x28(%rsp)
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xee0cd
movq %rax, 0x40(%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, %r12
leaq (%rax,%rbp), %r15
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, %r14
addq %rbp, %rax
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
leaq 0x700f4(%rip), %rsi     # 0x12e14c
movq %r12, %rdx
movq %rbp, %rcx
movq %r15, 0x18(%rsp)
movq %r15, %r8
movq %r13, 0x20(%rsp)
movq %r13, %r9
movq 0x28(%rsp), %r13
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
leaq 0x700ed(%rip), %rsi     # 0x12e171
movq %r14, %rdx
movq %rbp, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
xorl %eax, %eax
callq 0xde896
movzbl (%r13), %eax
cmpl $0x6, %eax
je 0xbe14a
cmpl $0x5, %eax
movq 0x8(%rsp), %r15
movq (%rsp), %r12
movq 0x10(%rsp), %r14
jne 0xbe0eb
movq 0x20(%r13), %rdx
cmpq $0x8, %rdx
ja 0xbe456
movl $0x112, %eax            # imm = 0x112
btq %rdx, %rax
jae 0xbe456
movq 0x18(%r13), %rdx
leaq -0x9(%rdx), %rax
cmpq $-0x9, %rax
jbe 0xbe183
movq 0x30(%r13), %rsi
movq 0x38(%r13), %rdx
movq %rbx, %rdi
callq 0xe6be1
testl %eax, %eax
je 0xbe467
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
addq %rcx, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xbe240
movq %rbx, %rdi
leaq 0x700a2(%rip), %rsi     # 0x12e1ca
xorl %eax, %eax
callq 0xdf2a5
jmp 0xbe467
movq %rbx, %rdi
leaq 0x6ff8c(%rip), %rsi     # 0x12e0ca
xorl %eax, %eax
callq 0xdf05a
jmp 0xbe471
movq 0x20(%r13), %rdx
cmpq $0x18, %rdx
movq 0x8(%rsp), %r15
movq (%rsp), %r12
movq 0x10(%rsp), %r14
ja 0xbe456
movl $0x1010112, %eax        # imm = 0x1010112
btq %rdx, %rax
jae 0xbe456
movq 0x18(%r13), %rdx
cmpq $0x1, %rdx
je 0xbe0eb
movq %rbx, %rdi
leaq 0x70026(%rip), %rsi     # 0x12e1b3
jmp 0xbe460
movq %rbx, %rdi
movq 0x28(%rsp), %r14
movq %r14, %rsi
pushq $0x1
popq %rdx
callq 0xe59cd
movq %rax, %rbp
movq %rax, %rdi
callq 0xe589c
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbp, %r8
movq %r14, %r9
callq 0xbe675
testl %eax, %eax
je 0xbe21a
movq 0x18(%rbp), %rcx
cmpq %r14, %rcx
movq 0x8(%rsp), %r15
movq (%rsp), %r12
je 0xbe1f1
movq %rbx, %rdi
leaq 0x70123(%rip), %rsi     # 0x12e30a
movl %r14d, %edx
xorl %eax, %eax
callq 0xdf05a
movq %rbx, %rdi
leaq 0x5128c(%rip), %rsi     # 0x10f487
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r14
movq 0x18(%rbp), %rdx
movq %rbp, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xe45f4
jmp 0xbe226
xorl %r14d, %r14d
movq 0x8(%rsp), %r15
movq (%rsp), %r12
movq %r14, %rdi
callq 0xe5591
movq %rbp, %rdi
callq 0xe5591
movq 0x10(%rsp), %r14
jmp 0xbe471
movq 0x30(%rsp), %rax
movq %rax, 0x68(%r13)
cmpb $0x5, (%r13)
je 0xbe25e
movq 0x20(%r13), %rcx
cmpq $0x8, %rcx
jle 0xbe493
xorl %eax, %eax
movq %rax, 0x40(%r13)
movq %rbx, %rdi
leaq 0x6ff7a(%rip), %rsi     # 0x12e1e8
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0xde896
movq 0x40(%r13), %rax
shlq $0x2, %rax
movq %rax, 0x48(%r13)
xorl %ecx, %ecx
cmpb $0x5, (%r13)
sete %sil
setne %cl
shll $0x4, %ecx
movq 0x20(%r13), %rax
imulq 0x30(%r13), %rax
addq %rcx, %rax
addq $0xf, %rax
addq $0x10, %rcx
cqto
idivq %rcx
movb $0x2, %cl
subb %sil, %cl
shlq %cl, %rax
movq %rax, 0x28(%r13)
imulq 0x38(%r13), %rax
imulq 0x18(%r13), %rax
movq %rax, 0x50(%r13)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, %rbp
movq %rax, %rdi
callq 0xe589c
movq 0x50(%r13), %r9
movq %rbx, %rdi
movq %r13, %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rbp, %r8
callq 0xbe675
testl %eax, %eax
je 0xbe469
movzbl (%r13), %eax
cmpl $0x6, %eax
je 0xbe4bd
cmpl $0x5, %eax
jne 0xbe469
movq 0x50(%r13), %rsi
addq $0xe, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe59cd
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0xe5f08
movq 0x30(%r13), %rsi
movq %r14, %rdi
callq 0xe5f08
movq 0x38(%r13), %rsi
movq %r14, %rdi
callq 0xe5f08
movq 0x28(%r13), %rsi
movq %r14, %rdi
callq 0xe5f08
movzbl 0x18(%r13), %esi
movq %r14, %rdi
callq 0xe5bc5
movzbl 0x20(%r13), %esi
movq %r14, %rdi
callq 0xe5bc5
movq %r14, %rdi
xorl %esi, %esi
callq 0xe5f7f
movq 0x50(%r13), %rdx
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0xe45f4
movq %rbx, %rdi
leaq 0x6fecb(%rip), %rsi     # 0x12e26e
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
callq 0xdfd1a
movq %rax, %r15
movl $0x2, 0x78(%rax)
cvtsi2sdq 0x8(%r13), %xmm0
movsd %xmm0, 0x80(%rax)
cvtsi2sdq 0x10(%r13), %xmm0
movsd %xmm0, 0x88(%rax)
movq %rbx, %rdi
pushq $0x70
popq %rsi
callq 0xdecaf
movq %rax, %r12
leaq 0x48a6f(%rip), %rax     # 0x106e67
movq %rax, (%r12)
movq %r15, 0x28(%r12)
movq 0x18(%r14), %r9
movq %rbx, %rdi
leaq 0x57dfe(%rip), %rsi     # 0x11620d
movq %r12, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xdf9b8
movq %rbx, %rdi
movq %r12, %rsi
movq (%rsp), %r12
callq 0xded32
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq %r14, %rdi
movq 0x10(%rsp), %r14
callq 0xe5591
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %r15
callq 0xdfd24
jmp 0xbe469
movq %rbx, %rdi
leaq 0x6fd39(%rip), %rsi     # 0x12e199
xorl %eax, %eax
callq 0xdf2a5
xorl %ebp, %ebp
movq %rbp, %rdi
callq 0xe5591
movq %rbx, %rdi
movq %r13, %rsi
callq 0xded32
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
incq %r14
addq $0x4, %r12
jmp 0xbdc89
movq 0x58(%r13), %rax
testq %rax, %rax
je 0xbe5fe
setle %dl
pushq $0x1
popq %rsi
shlq %cl, %rsi
movq %rax, 0x40(%r13)
cmpq %rsi, %rax
setg %al
orb %dl, %al
je 0xbe264
jmp 0xbe467
movq %rbx, %rdi
leaq 0x55bab(%rip), %rsi     # 0x114072
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r14
movl $0xa0, %edx
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x18140
movq 0x48(%r13), %rax
addq $0x28, %rax
movq %rax, 0xd0(%rsp)
addq 0x50(%r13), %rax
movq %rax, 0xd8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x48(%rsp), %rdx
xorl %ecx, %ecx
callq 0xec053
movq %r14, %rdi
pushq $0x28
popq %rsi
callq 0xe5f7f
movq 0x30(%r13), %rsi
movq %r14, %rdi
callq 0xe5f7f
movq 0x38(%r13), %rsi
movq %r14, %rdi
callq 0xe5f7f
movq 0x18(%r13), %rsi
movq %r14, %rdi
callq 0xe5f08
movq 0x20(%r13), %rsi
movq %r14, %rdi
callq 0xe5f08
movq %r14, %rdi
xorl %esi, %esi
callq 0xe5f7f
movq %r14, %rdi
xorl %esi, %esi
callq 0xe5f7f
cvtsi2sdq 0x8(%r13), %xmm0
movsd 0x6fa61(%rip), %xmm1    # 0x12dfd0
mulsd %xmm1, %xmm0
movsd 0x4c1c5(%rip), %xmm1    # 0x10a740
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
movq %r14, %rdi
callq 0xe5f7f
cvtsi2sdq 0x10(%r13), %xmm0
mulsd 0x6fa36(%rip), %xmm0    # 0x12dfd0
addsd 0x4c19e(%rip), %xmm0    # 0x10a740
cvttsd2si %xmm0, %rsi
movq %r14, %rdi
callq 0xe5f7f
movq 0x58(%r13), %rsi
movq %r14, %rdi
callq 0xe5f7f
movq 0x60(%r13), %rsi
movq %r14, %rdi
callq 0xe5f7f
movq 0x18(%rbx), %rdi
movq 0x48(%r13), %rdx
movq 0x68(%r13), %rsi
movq %r14, %rcx
callq 0xe45f4
movq 0x50(%r13), %rdx
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0xe45f4
movq %r14, %rdi
movq 0x10(%rsp), %r14
callq 0xe5591
jmp 0xbe469
pushq $0x1
popq %rax
shlq %cl, %rax
jmp 0xbe260
movq %rbx, %rdi
movq %r13, %rsi
callq 0xded32
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq