// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_chain_weight
int mem_chain_weight(const mem_chain_t *c)
{
	int64_t end;
	int j, w = 0, tmp;
	for (j = 0, end = 0; j < c->n; ++j) {
		const mem_seed_t *s = &c->seeds[j];
		if (s->qbeg >= end) w += s->len;
		else if (s->qbeg + s->len > end) w += s->qbeg + s->len - end;
		end = end > s->qbeg + s->len? end : s->qbeg + s->len;
	}
	tmp = w; w = 0;
	for (j = 0, end = 0; j < c->n; ++j) {
		const mem_seed_t *s = &c->seeds[j];
		if (s->rbeg >= end) w += s->len;
		else if (s->rbeg + s->len > end) w += s->rbeg + s->len - end;
		end = end > s->rbeg + s->len? end : s->rbeg + s->len;
	}
	w = w < tmp? w : tmp;
	return w < 1<<30? w : (1<<30)-1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movq $0x0, -0x10(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1cb66
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movslq 0x8(%rax), %rax
cmpq -0x10(%rbp), %rax
jl 0x1cae1
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x1cb18
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0xc(%rcx), %eax
cltq
cmpq -0x10(%rbp), %rax
jle 0x1cb16
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0xc(%rcx), %eax
movslq %eax, %rcx
subq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
jmp 0x1cb18
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x8(%rcx), %ecx
movq -0x28(%rbp), %rdx
addl 0xc(%rdx), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0x1cb3c
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x1cb50
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0xc(%rcx), %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1ca9e
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movq $0x0, -0x10(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1cc4f
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jl 0x1cbc4
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x1cbfe
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
cmpq -0x10(%rbp), %rax
jle 0x1cbfc
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movslq 0xc(%rax), %rax
addq %rax, %rcx
subq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
jmp 0x1cbfe
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq -0x30(%rbp), %rdx
movslq 0xc(%rdx), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jle 0x1cc23
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1cc39
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1cb82
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1cc5f
movl -0x18(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x1cc65
movl -0x1c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x40000000, -0x18(%rbp) # imm = 0x40000000
jge 0x1cc7c
movl -0x18(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x1cc86
movl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, -0x48(%rbp)
jmp 0x1cc86
movl -0x48(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)