// File: /workspace/github_c_makefile_star2_O0/aligrudi[P]neatmkfn/otf.c
// Function: otf_gpostype5
static void otf_gpostype5(struct otf *otf, void *sub, char *feat)
{
	int fmt = U16(sub, 0);
	int *mcov;		/* mark coverage */
	int *lcov;		/* ligature coverage */
	int cgrp[1024];		/* glyph groups assigned to classes */
	int lgrp;		/* the group assigned to base glyphs */
	int mcnt;		/* mark coverage size */
	int lcnt;		/* ligature coverage size */
	int ccnt;		/* class count */
	void *marks;		/* mark array table */
	void *ligas;		/* ligature array table */
	int i, j, k;
	/* only marks at the end of ligatures are supported */
	if (fmt != 1)
		return;
	mcov = coverage(sub + U16(sub, 2), &mcnt);
	lcov = coverage(sub + U16(sub, 4), &lcnt);
	ccnt = U16(sub, 6);
	marks = sub + U16(sub, 8);
	ligas = sub + U16(sub, 10);
	/* define a group for ligatures */
	lgrp = ggrp_coverage(lcov, lcnt);
	/* define a group for each mark class */
	for (i = 0; i < ccnt; i++) {
		int *grp = malloc(mcnt * sizeof(grp[0]));
		int cnt = 0;
		for (j = 0; j < mcnt; j++)
			if (U16(marks, 2 + 4 * j) == i)
				grp[cnt++] = mcov[j];
		cgrp[i] = ggrp_coverage(grp, cnt);
		free(grp);
	}
	/* GPOS rules for each mark after a ligature */
	printf("gsec %d\n", sec);
	for (i = 0; i < mcnt; i++) {
		void *mark = marks + U16(marks, 2 + 4 * i + 2);	/* mark anchor */
		int dx = -uwid(S16(mark, 2));
		int dy = -uwid(S16(mark, 4));
		if (otf_r2l(feat)) {
			dx += uwid(glyph_wid[mcov[i]]);
			dy = -dy;
		}
		printf("gpos %s 2 @%d %s:%+d%+d%+d%+d\n",
			feat, lgrp, glyph_name[mcov[i]], dx, dy, 0, 0);
	}
	printf("gsec %d\n", sec + 1);
	/* GPOS rules for each ligature before a mark */
	for (i = 0; i < lcnt; i++) {
		void *ligattach = ligas + U16(ligas, 2 + 2 * i);
		int comcnt = U16(ligattach, 0);		/* component count */
		/* considering only the last component */
		k = comcnt - 1;
		if (comcnt == 0)
			continue;
		if (!U16(ligattach, 2 + 2 * ccnt * k))
			continue;
		for (j = 0; j < ccnt; j++) {
			char *base = ligattach + U16(ligattach, 2 + 2 * ccnt * k + 2 * j);
			int dx = uwid(S16(base, 2)) - uwid(glyph_wid[lcov[i]]);
			int dy = uwid(S16(base, 4));
			if (otf_r2l(feat)) {
				dx += uwid(glyph_wid[lcov[i]]);
				dy = -dy;
			}
			printf("gpos %s 2 %s @%d:%+d%+d%+d%+d\n",
				feat, glyph_name[lcov[i]], cgrp[j], dx, dy, 0, 0);
		}
	}
	free(mcov);
	free(lcov);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10f0, %rsp           # imm = 0x10F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movzwl (%rax), %edi
callq 0x3d090
movzwl %ax, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
je 0x44724
jmp 0x44d2a
movq -0x10(%rbp), %rax
movq %rax, -0x10c0(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x3d090
movq -0x10c0(%rbp), %rdi
movzwl %ax, %eax
cltq
addq %rax, %rdi
leaq -0x1038(%rbp), %rsi
callq 0x431f0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x10b8(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x4(%rax), %edi
callq 0x3d090
movq -0x10b8(%rbp), %rdi
movzwl %ax, %eax
cltq
addq %rax, %rdi
leaq -0x103c(%rbp), %rsi
callq 0x431f0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x6(%rax), %edi
callq 0x3d090
movzwl %ax, %eax
movl %eax, -0x1040(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x10b0(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x8(%rax), %edi
callq 0x3d090
movw %ax, %cx
movq -0x10b0(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1048(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x10a8(%rbp)
movq -0x10(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x3d090
movw %ax, %cx
movq -0x10a8(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1050(%rbp)
movq -0x30(%rbp), %rdi
movl -0x103c(%rbp), %esi
callq 0x434e0
movl %eax, -0x1034(%rbp)
movl $0x0, -0x1054(%rbp)
movl -0x1054(%rbp), %eax
cmpl -0x1040(%rbp), %eax
jge 0x44921
movslq -0x1038(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3d150
movq %rax, -0x1068(%rbp)
movl $0x0, -0x106c(%rbp)
movl $0x0, -0x1058(%rbp)
movl -0x1058(%rbp), %eax
cmpl -0x1038(%rbp), %eax
jge 0x448df
movq -0x1048(%rbp), %rax
movl -0x1058(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx), %edi
callq 0x3d090
movzwl %ax, %eax
cmpl -0x1054(%rbp), %eax
jne 0x448cc
movq -0x28(%rbp), %rax
movslq -0x1058(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x1068(%rbp), %rax
movl -0x106c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x106c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x448ce
movl -0x1058(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1058(%rbp)
jmp 0x44868
movq -0x1068(%rbp), %rdi
movl -0x106c(%rbp), %esi
callq 0x434e0
movl %eax, %ecx
movslq -0x1054(%rbp), %rax
movl %ecx, -0x1030(%rbp,%rax,4)
movq -0x1068(%rbp), %rdi
callq 0x3d030
movl -0x1054(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1054(%rbp)
jmp 0x4482b
movl 0x5b1f09(%rip), %esi    # 0x5f6830
leaq 0x13365(%rip), %rdi     # 0x57c93
movb $0x0, %al
callq 0x3d0b0
movl $0x0, -0x1054(%rbp)
movl -0x1054(%rbp), %eax
cmpl -0x1038(%rbp), %eax
jge 0x44a91
movq -0x1048(%rbp), %rax
movq %rax, -0x10c8(%rbp)
movq -0x1048(%rbp), %rax
movl -0x1054(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx), %edi
callq 0x3d090
movw %ax, %cx
movq -0x10c8(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1078(%rbp)
movq -0x1078(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x3d090
movswl %ax, %edi
callq 0x40ca0
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x107c(%rbp)
movq -0x1078(%rbp), %rax
movzwl 0x4(%rax), %edi
callq 0x3d090
movswl %ax, %edi
callq 0x40ca0
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x1080(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45160
cmpl $0x0, %eax
je 0x44a29
movq -0x28(%rbp), %rax
movslq -0x1054(%rbp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x471e29(%rip), %rax    # 0x4b6830
movl (%rax,%rcx,4), %edi
callq 0x40ca0
addl -0x107c(%rbp), %eax
movl %eax, -0x107c(%rbp)
xorl %eax, %eax
subl -0x1080(%rbp), %eax
movl %eax, -0x1080(%rbp)
movq -0x18(%rbp), %rsi
movl -0x1034(%rbp), %edx
movq -0x28(%rbp), %rax
movslq -0x1054(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
leaq 0x31de7(%rip), %rcx     # 0x76830
shlq $0x6, %rax
addq %rax, %rcx
movl -0x107c(%rbp), %r8d
movl -0x1080(%rbp), %r9d
leaq 0x131f0(%rip), %rdi     # 0x57c55
xorl %eax, %eax
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movb $0x0, %al
callq 0x3d0b0
movl -0x1054(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1054(%rbp)
jmp 0x4493f
movl 0x5b1d99(%rip), %esi    # 0x5f6830
addl $0x1, %esi
leaq 0x131f2(%rip), %rdi     # 0x57c93
movb $0x0, %al
callq 0x3d0b0
movl $0x0, -0x1054(%rbp)
movl -0x1054(%rbp), %eax
cmpl -0x103c(%rbp), %eax
jge 0x44d18
movq -0x1050(%rbp), %rax
movq %rax, -0x10d0(%rbp)
movq -0x1050(%rbp), %rax
movl -0x1054(%rbp), %ecx
shll %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx), %edi
callq 0x3d090
movw %ax, %cx
movq -0x10d0(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1088(%rbp)
movq -0x1088(%rbp), %rax
movzwl (%rax), %edi
callq 0x3d090
movzwl %ax, %eax
movl %eax, -0x108c(%rbp)
movl -0x108c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x105c(%rbp)
cmpl $0x0, -0x108c(%rbp)
jne 0x44b3f
jmp 0x44d04
movq -0x1088(%rbp), %rax
movl -0x1040(%rbp), %ecx
shll %ecx
imull -0x105c(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx), %edi
callq 0x3d090
cmpw $0x0, %ax
jne 0x44b6f
jmp 0x44d04
movl $0x0, -0x1058(%rbp)
movl -0x1058(%rbp), %eax
cmpl -0x1040(%rbp), %eax
jge 0x44d02
movq -0x1088(%rbp), %rax
movq %rax, -0x10e0(%rbp)
movq -0x1088(%rbp), %rax
movl -0x1040(%rbp), %ecx
shll %ecx
imull -0x105c(%rbp), %ecx
addl $0x2, %ecx
movl -0x1058(%rbp), %edx
shll %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx), %edi
callq 0x3d090
movw %ax, %cx
movq -0x10e0(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1098(%rbp)
movq -0x1098(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x3d090
movswl %ax, %edi
callq 0x40ca0
movl %eax, -0x10d4(%rbp)
movq -0x30(%rbp), %rax
movslq -0x1054(%rbp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x471c1a(%rip), %rax    # 0x4b6830
movl (%rax,%rcx,4), %edi
callq 0x40ca0
movl %eax, %ecx
movl -0x10d4(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x109c(%rbp)
movq -0x1098(%rbp), %rax
movzwl 0x4(%rax), %edi
callq 0x3d090
movswl %ax, %edi
callq 0x40ca0
movl %eax, -0x10a0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45160
cmpl $0x0, %eax
je 0x44c92
movq -0x30(%rbp), %rax
movslq -0x1054(%rbp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x471bc0(%rip), %rax    # 0x4b6830
movl (%rax,%rcx,4), %edi
callq 0x40ca0
addl -0x109c(%rbp), %eax
movl %eax, -0x109c(%rbp)
xorl %eax, %eax
subl -0x10a0(%rbp), %eax
movl %eax, -0x10a0(%rbp)
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rax
movslq -0x1054(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
leaq 0x31b84(%rip), %rdx     # 0x76830
shlq $0x6, %rax
addq %rax, %rdx
movslq -0x1058(%rbp), %rax
movl -0x1030(%rbp,%rax,4), %ecx
movl -0x109c(%rbp), %r8d
movl -0x10a0(%rbp), %r9d
leaq 0x12f9e(%rip), %rdi     # 0x57c74
xorl %eax, %eax
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movb $0x0, %al
callq 0x3d0b0
movl -0x1058(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1058(%rbp)
jmp 0x44b79
jmp 0x44d04
movl -0x1054(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1054(%rbp)
jmp 0x44ab2
movq -0x28(%rbp), %rdi
callq 0x3d030
movq -0x30(%rbp), %rdi
callq 0x3d030
addq $0x10f0, %rsp           # imm = 0x10F0
popq %rbp
retq
nopw %cs:(%rax,%rax)