// File: chhylp123[P]hifiasm/inter.cpp
// Function: gen_trans_ovlp_scaf(ma_ug_t*, u_trans_t*, uc_block_t*, uc_block_t*, ul_ov_t*)
uint64_t gen_trans_ovlp_scaf(ma_ug_t *gfa, u_trans_t *map, uc_block_t *qin, uc_block_t *rin, ul_ov_t *res)
{
	uint64_t s, e, s0, e0; uc_block_t *z;

	z = qin; s0 = map->qs; e0 = map->qe;
	if(s0 > gfa->u.a[z->hid].len || e0 > gfa->u.a[z->hid].len) return 0;
	if(!(z->rev)) {
		s = s0; e = e0;
	} else {
		s = gfa->u.a[z->hid].len - e0; 
		e = gfa->u.a[z->hid].len - s0;
	}
	s += z->qs; e += z->qs;
	if(s >= e) return 0;
	res->qs = s; res->qe = e;


	z = rin; s0 = map->ts; e0 = map->te;
	if(s0 > gfa->u.a[z->hid].len || e0 > gfa->u.a[z->hid].len) return 0;
	if(!(z->rev)) {
		s = s0; e = e0;
	} else {
		s = gfa->u.a[z->hid].len - e0; 
		e = gfa->u.a[z->hid].len - s0;
	}
	s += z->qs; e += z->qs;
	if(s >= e) return 0;
	res->ts = s; res->te = e;

	res->rev = map->rev^(qin->rev^rin->rev); 

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x58(%rbp), %rdx
movl (%rdx), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
ja 0x2e0485
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x58(%rbp), %rdx
movl (%rdx), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x2e0492
movq $0x0, -0x8(%rbp)
jmp 0x2e06d6
movq -0x58(%rbp), %rax
movb 0x20(%rax), %al
shrb $0x5, %al
andb $0x1, %al
cmpb $0x0, %al
jne 0x2e04b4
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x2e0500
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0x2e0535
movq $0x0, -0x8(%rbp)
jmp 0x2e06d6
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x58(%rbp), %rdx
movl (%rdx), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
ja 0x2e05bd
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x58(%rbp), %rdx
movl (%rdx), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x2e05ca
movq $0x0, -0x8(%rbp)
jmp 0x2e06d6
movq -0x58(%rbp), %rax
movb 0x20(%rax), %al
shrb $0x5, %al
andb $0x1, %al
cmpb $0x0, %al
jne 0x2e05ec
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x2e0638
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0x2e066a
movq $0x0, -0x8(%rbp)
jmp 0x2e06d6
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x18(%rbp), %rax
movb 0x28(%rax), %al
shrb $0x6, %al
andb $0x1, %al
movzbl %al, %edx
movq -0x20(%rbp), %rax
movb 0x20(%rax), %al
shrb $0x5, %al
andb $0x1, %al
movzbl %al, %eax
movq -0x28(%rbp), %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
xorl %ecx, %eax
xorl %eax, %edx
movq -0x30(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movq $0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopl (%rax)