// File: /workspace/github_c_makefile_star2_O3/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
movl $0x18, %esi
callq 0xe8b2b
movq %rax, %r15
movq $0x0, 0x8(%rax)
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0xeebc8
movq %rax, (%r15)
cmpq $0x706c, %rax           # imm = 0x706C
je 0xc5b14
cmpq $0x506c, %rax           # imm = 0x506C
jne 0xc5b25
leaq 0x7580e(%rip), %rsi     # 0x13b320
jmp 0xc5b1b
leaq 0x5b70a(%rip), %rsi     # 0x121225
movq %rbx, %rdi
callq 0xeb125
jmp 0xc5b36
leaq 0x757f8(%rip), %rsi     # 0x13b324
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
movq 0x18(%rbx), %rdi
movq 0x8(%r15), %rsi
addq $0x2, %rsi
callq 0xeebc8
movq %rax, 0x10(%r15)
leaq 0x757f8(%rip), %rsi     # 0x13b34a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xf1e9d
testl %eax, %eax
je 0xc6583
cmpq $0x0, 0x10(%r15)
jle 0xc6583
movl $0x4, %r13d
xorl %r14d, %r14d
movq %r15, 0x10(%rsp)
movl $0x70, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r12
movq %rbx, %rdi
leaq 0x757c4(%rip), %rsi     # 0x13b369
movl %r14d, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq 0x8(%r15), %rsi
addq %r13, %rsi
callq 0xeed61
movq %rax, %rbp
addq 0x8(%r15), %rbp
movq %rbx, %rdi
leaq 0x75798(%rip), %rsi     # 0x13b375
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rbp
jge 0xc656b
movq %rbp, %rsi
callq 0xeead3
movb %al, (%r12)
movq 0x18(%rbx), %rdi
leaq 0x1(%rbp), %rsi
callq 0xeead3
movb %al, 0x1(%r12)
movzbl (%r12), %edx
leal -0x5(%rdx), %eax
leaq 0x66530(%rip), %rcx     # 0x12c151
cmpb $0x3, %al
ja 0xc5c36
movzbl %al, %eax
leaq 0x759f9(%rip), %rsi     # 0x13b628
movslq (%rsi,%rax,4), %rcx
addq %rsi, %rcx
movq %rbx, %rdi
leaq 0x75751(%rip), %rsi     # 0x13b391
xorl %eax, %eax
callq 0xe8617
movzbl 0x1(%r12), %edx
movq %rbx, %rdi
leaq 0x75750(%rip), %rsi     # 0x13b3a7
xorl %eax, %eax
callq 0xe8617
movzbl (%r12), %edx
leal -0x5(%rdx), %eax
cmpl $0x2, %eax
jae 0xc5cd6
leaq 0x2(%rbp), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x30(%rsp), %r15
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x8(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x10(%r12)
movl 0x8(%r12), %edx
movq %rbx, %rdi
leaq 0x63660(%rip), %rsi     # 0x12930a
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x8(%r12), %rax
cmpq $0xa, %rax
jge 0xc5e13
movq %r12, %rax
addq $0x8, %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
jmp 0xc5e3a
cmpl $0x8, %edx
jne 0xc6052
movq %r14, 0x8(%rsp)
movq %r13, (%rsp)
leaq 0x2(%rbp), %rax
movq %rax, 0x48(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x48(%rsp), %r13
movq %r13, %rsi
callq 0xf99d5
movq %rax, %r14
movq 0x18(%rbx), %rdi
movq 0x48(%rsp), %rsi
callq 0xeebc8
movq %rax, %r15
movq 0x48(%rsp), %rsi
addq $0x2, %rsi
movq %rsi, 0x48(%rsp)
movq 0x18(%rbx), %rdi
callq 0xeebc8
addq $0x2, 0x48(%rsp)
movq %rbx, %rdi
leaq 0x7583d(%rip), %rsi     # 0x13b57a
movl %r14d, %edx
movl %r15d, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xf9a54
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
movq %r13, %r14
callq 0xf9a54
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xf9a54
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdi
movq 0x48(%rsp), %rsi
callq 0xeed61
movq %rax, %r14
movq 0x48(%rsp), %rsi
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
addq %rbp, %r14
movq 0x18(%rbx), %rdi
callq 0xeed61
addq $0x4, 0x48(%rsp)
addl %eax, %ebp
movq %rbx, %rdi
leaq 0x757eb(%rip), %rsi     # 0x13b5a7
movl %r14d, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
leaq 0x757eb(%rip), %rsi     # 0x13b5be
movl %ebp, %edx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
callq 0xe8617
leaq (%r14,%r13), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xc60b2
movq %rbx, %rdi
leaq 0x757dc(%rip), %rsi     # 0x13b5d9
xorl %eax, %eax
callq 0xe9295
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
jmp 0xc6393
cmpq $0x7530, %rax           # imm = 0x7530
ja 0xc5cc2
movq 0x10(%r12), %rax
movq $-0x7531, %rcx          # imm = 0x8ACF
addq %rcx, %rax
cmpq $-0x7528, %rax          # imm = 0x8AD8
jbe 0xc5cc2
movq %r14, 0x8(%rsp)
movq %r13, (%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf99d5
movq %rax, 0x18(%r12)
movq %rbx, %rdi
leaq 0x75651(%rip), %rsi     # 0x13b4af
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf99d5
movq %rax, 0x20(%r12)
movq %rbx, %rdi
leaq 0x75555(%rip), %rsi     # 0x13b3d7
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x30(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x38(%r12)
movq 0x30(%r12), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe8f88
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x58(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x60(%r12)
movl 0x58(%r12), %edx
movq %rbx, %rdi
leaq 0x754f6(%rip), %rsi     # 0x13b3e4
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
cmpq $0x1, 0x60(%r12)
jne 0xc5f19
movq %rbx, %rdi
leaq 0x754f8(%rip), %rsi     # 0x13b401
xorl %eax, %eax
callq 0xe8faa
movq $0x0, 0x60(%r12)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %r12, 0x28(%rsp)
movq %rax, %r12
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xf9a54
movq %rax, 0x40(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
movq %rax, %r14
leaq (%rax,%rbp), %r13
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
movq %rax, %r15
addq %rbp, %rax
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
leaq 0x754ca(%rip), %rsi     # 0x13b43c
movq %r14, %rdx
movq %rbp, %rcx
movq %r13, 0x18(%rsp)
movq %r13, %r8
movq %r12, 0x20(%rsp)
movq %r12, %r9
movq 0x28(%rsp), %r12
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
leaq 0x754c3(%rip), %rsi     # 0x13b461
movq %r15, %rdx
movq %rbp, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
xorl %eax, %eax
callq 0xe8617
movzbl (%r12), %eax
cmpl $0x6, %eax
je 0xc6068
cmpl $0x5, %eax
movq 0x10(%rsp), %r15
movq (%rsp), %r13
movq 0x8(%rsp), %r14
jne 0xc6007
movq 0x20(%r12), %rdx
cmpq $0x8, %rdx
ja 0xc6373
movl $0x112, %eax            # imm = 0x112
btq %rdx, %rax
jae 0xc6373
movq 0x18(%r12), %rdx
leaq -0x9(%rdx), %rax
cmpq $-0x9, %rax
jbe 0xc60a3
movq 0x30(%r12), %rsi
movq 0x38(%r12), %rdx
movq %rbx, %rdi
callq 0xf1db1
testl %eax, %eax
je 0xc6384
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
addq %rcx, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xc6141
movq %rbx, %rdi
leaq 0x75474(%rip), %rsi     # 0x13b4ba
xorl %eax, %eax
callq 0xe9295
jmp 0xc6384
movq %rbx, %rdi
leaq 0x7535e(%rip), %rsi     # 0x13b3ba
xorl %eax, %eax
callq 0xe8faa
jmp 0xc63ac
movq 0x20(%r12), %rdx
cmpq $0x18, %rdx
movq 0x10(%rsp), %r15
movq (%rsp), %r13
movq 0x8(%rsp), %r14
ja 0xc6373
movl $0x1010112, %eax        # imm = 0x1010112
btq %rdx, %rax
jae 0xc6373
movq 0x18(%r12), %rdx
cmpq $0x1, %rdx
je 0xc6007
movq %rbx, %rdi
leaq 0x753f6(%rip), %rsi     # 0x13b4a3
jmp 0xc637d
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %rbp
movq %rax, %rdi
callq 0xf0855
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %r15, %r14
movq %r15, %r9
callq 0xc65db
testl %eax, %eax
movq 0x10(%rsp), %r15
je 0xc6390
movq 0x18(%rbp), %rcx
cmpq %r14, %rcx
movq (%rsp), %r13
je 0xc6115
movq %rbx, %rdi
leaq 0x754ef(%rip), %rsi     # 0x13b5fa
movl %r14d, %edx
xorl %eax, %eax
callq 0xe8faa
movq %rbx, %rdi
leaq 0x56458(%rip), %rsi     # 0x11c577
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r14
movq 0x18(%rbp), %rdx
movq %rbp, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xef481
jmp 0xc6397
movq 0x30(%rsp), %rax
movq %rax, 0x68(%r12)
cmpb $0x5, (%r12)
je 0xc6161
movq 0x20(%r12), %rcx
cmpq $0x8, %rcx
jle 0xc63da
xorl %eax, %eax
movq %rax, 0x40(%r12)
movq %rbx, %rdi
leaq 0x75366(%rip), %rsi     # 0x13b4d8
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0xe8617
movq 0x40(%r12), %rax
shlq $0x2, %rax
movq %rax, 0x48(%r12)
xorl %ecx, %ecx
cmpb $0x5, (%r12)
sete %sil
setne %cl
shll $0x4, %ecx
movq 0x20(%r12), %rax
imulq 0x30(%r12), %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(%r12)
imulq 0x38(%r12), %rax
imulq 0x18(%r12), %rax
movq %rax, 0x50(%r12)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, %rbp
movq %rax, %rdi
callq 0xf0855
movq 0x50(%r12), %r9
movq %rbx, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rbp, %r8
callq 0xc65db
testl %eax, %eax
je 0xc6386
movzbl (%r12), %eax
cmpl $0x6, %eax
je 0xc640b
cmpl $0x5, %eax
jne 0xc6386
movq 0x50(%r12), %rsi
addq $0xe, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf09c5
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0xf0f95
movq 0x30(%r12), %rsi
movq %r14, %rdi
callq 0xf0f95
movq 0x38(%r12), %rsi
movq %r14, %rdi
callq 0xf0f95
movq 0x28(%r12), %rsi
movq %r14, %rdi
callq 0xf0f95
movzbl 0x18(%r12), %esi
movq %r14, %rdi
callq 0xf0bd6
movzbl 0x20(%r12), %esi
movq %r14, %rdi
callq 0xf0bd6
movq %r14, %rdi
xorl %esi, %esi
callq 0xf1042
movq 0x50(%r12), %rdx
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0xef481
movq %rbx, %rdi
leaq 0x752a7(%rip), %rsi     # 0x13b55e
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rbx, %rdi
callq 0xea504
movq %rax, %r13
movl $0x2, 0x78(%rax)
cvtsi2sdq 0x8(%r12), %xmm0
movsd %xmm0, 0x80(%rax)
xorps %xmm0, %xmm0
cvtsi2sdq 0x10(%r12), %xmm0
movsd %xmm0, 0x88(%rax)
movl $0x70, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
leaq 0x4dbb2(%rip), %rax     # 0x113ec7
movq %rax, (%r15)
movq %r13, 0x28(%r15)
movq 0x18(%r14), %r9
movq %rbx, %rdi
leaq 0x5d0a3(%rip), %rsi     # 0x1233cd
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xe9aa3
movq %rbx, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %r15
callq 0xe8be2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %r14, %rdi
movq 0x8(%rsp), %r14
callq 0xf052b
movq %rbx, %rdi
movq %r13, %rsi
movq (%rsp), %r13
callq 0xea50e
jmp 0xc6386
movq %rbx, %rdi
leaq 0x7510c(%rip), %rsi     # 0x13b489
xorl %eax, %eax
callq 0xe9295
xorl %ebp, %ebp
movq %rbp, %rdi
callq 0xf052b
jmp 0xc63ac
xorl %r14d, %r14d
movq (%rsp), %r13
movq %r14, %rdi
callq 0xf052b
movq %rbp, %rdi
callq 0xf052b
movq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8be2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %r14
addq $0x4, %r13
cmpq 0x10(%r15), %r14
jl 0xc5b8b
jmp 0xc6583
movq 0x58(%r12), %rax
testq %rax, %rax
je 0xc655e
setle %dl
movl $0x1, %esi
shlq %cl, %rsi
movq %rax, 0x40(%r12)
cmpq %rsi, %rax
setg %al
orb %dl, %al
je 0xc6168
jmp 0xc6384
movq %rbx, %rdi
leaq 0x5ad4d(%rip), %rsi     # 0x121162
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r14
movl $0xa0, %edx
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x18140
movq 0x48(%r12), %rax
addq $0x28, %rax
movq %rax, 0xd0(%rsp)
addq 0x50(%r12), %rax
movq %rax, 0xd8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x48(%rsp), %rdx
xorl %ecx, %ecx
callq 0xf78fa
movl $0x28, %esi
movq %r14, %rdi
callq 0xf1042
movq 0x30(%r12), %rsi
movq %r14, %rdi
callq 0xf1042
movq 0x38(%r12), %rsi
movq %r14, %rdi
callq 0xf1042
movq 0x18(%r12), %rsi
movq %r14, %rdi
callq 0xf0f95
movq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0xf0f95
movq %r14, %rdi
xorl %esi, %esi
callq 0xf1042
movq %r14, %rdi
xorl %esi, %esi
callq 0xf1042
cvtsi2sdq 0x8(%r12), %xmm0
movsd 0x74dfa(%rip), %xmm1    # 0x13b2c0
mulsd %xmm1, %xmm0
movsd 0x5135e(%rip), %xmm1    # 0x117830
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
movq %r14, %rdi
callq 0xf1042
xorps %xmm0, %xmm0
cvtsi2sdq 0x10(%r12), %xmm0
mulsd 0x74dcb(%rip), %xmm0    # 0x13b2c0
addsd 0x51333(%rip), %xmm0    # 0x117830
cvttsd2si %xmm0, %rsi
movq %r14, %rdi
callq 0xf1042
movq 0x58(%r12), %rsi
movq %r14, %rdi
callq 0xf1042
movq 0x60(%r12), %rsi
movq %r14, %rdi
callq 0xf1042
movq 0x18(%rbx), %rdi
movq 0x48(%r12), %rdx
movq 0x68(%r12), %rsi
movq %r14, %rcx
callq 0xef481
movq 0x50(%r12), %rdx
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0xef481
movq %r14, %rdi
movq 0x8(%rsp), %r14
callq 0xf052b
jmp 0xc6386
movl $0x1, %eax
shlq %cl, %rax
jmp 0xc6163
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8be2
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq