LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/weisfeilerLehman.c
// Function: weisfeilerLehmanRelabel
struct Graph* weisfeilerLehmanRelabel(struct Graph* g, struct Vertex* wlLabels, struct GraphPool* gp, struct ShallowGraphPool* sgp) {
	struct Graph* h = cloneGraph(g, gp);
	int v;

	for (v=0; v<g->n; ++v) {
		h->vertices[v]->label = getWLLabel(g->vertices[v], wlLabels, gp, sgp);
		h->vertices[v]->isStringMaster = 1;
	}
	// fprintf(stderr, "\n\n\n");
	// printStringsInSearchTree(wlLabels, stderr, sgp);
	return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq %rdx, %rsi
callq 0x5dac
movq %rax, %r13
xorl %ebp, %ebp
movslq (%r12), %rax
cmpq %rax, %rbp
jge 0x1bc8e
movq 0x10(%r12), %rax
movq (%rax,%rbp,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1badc
movq 0x10(%r13), %rcx
movq (%rcx,%rbp,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%rbp,8), %rax
movl $0x1, 0x24(%rax)
incq %rbp
jmp 0x1bc53
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/wilsonsAlgorithm.c
// Function: initIntegerArrayStack
struct IntegerArrayStack* initIntegerArrayStack(int capacity) {
	struct IntegerArrayStack* ias = malloc(sizeof(struct IntegerArrayStack));
	ias->stackData = malloc(capacity * sizeof(int));
	ias->top = -1;
	ias->capacity = capacity;
	return ias;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
pushq $0x10
popq %rdi
callq 0x1180
movq %rax, %r14
movslq %ebx, %rbx
leaq (,%rbx,4), %rdi
callq 0x1180
movq %rax, (%r14)
orl $-0x1, 0x8(%r14)
movl %ebx, 0xc(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/wilsonsAlgorithm.c
// Function: ias_shuffleArray
void ias_shuffleArray(struct IntegerArrayStack* ias) {
	int i;
	for (i = ias->capacity - 1; i > 0; i--)
	{
		int index = rand() % (i + 1);
		// Simple swap
		int a = ias->stackData[index];
		ias->stackData[index] = ias->stackData[i];
		ias->stackData[i] = a;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0xc(%rdi), %r14d
cmpl $0x2, %r14d
jl 0x1bd55
leaq -0x1(%r14), %r15
callq 0x1240
cltd
idivl %r14d
movq (%rbx), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %edx
movl -0x4(%rax,%r14,4), %esi
movl %esi, (%rax,%rcx,4)
movl %edx, -0x4(%rax,%r14,4)
movq %r15, %r14
jmp 0x1bd27
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/wilsonsAlgorithm.c
// Function: initArrayList
struct ArrayList* initArrayList(int capacity) {
	struct ArrayList* al = malloc(sizeof(struct ArrayList));
	al->stackData = malloc(capacity * sizeof(int*));
	al->top = -1;
	al->capacity = capacity;
	return al;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
pushq $0x10
popq %rdi
callq 0x1180
movq %rax, %r14
movslq %ebx, %rbx
leaq (,%rbx,8), %rdi
callq 0x1180
movq %rax, (%r14)
orl $-0x1, 0x8(%r14)
movl %ebx, 0xc(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/wilsonsAlgorithm.c
// Function: randomSpanningTreeAsShallowGraph
struct ShallowGraph* randomSpanningTreeAsShallowGraph(struct Graph* g, struct ShallowGraphPool* sgp) {
	if (g->m == 0) {
		return getShallowGraph(sgp);
	} else {
		return _randomSpanningTreeAsShallowGraph(g, sgp);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpl $0x0, 0x4(%rdi)
je 0x1be74
movq %rdi, %r14
movslq (%rdi), %r12
leaq (,%r12,8), %rdi
callq 0x1180
movq %rax, %r15
movq %r12, %rdi
callq 0x1180
movq %rax, %r12
movq %rbx, %rdi
callq 0x117e9
movq %rax, %r13
movl (%r14), %edi
callq 0x1bca0
movq %rax, %rbp
xorl %eax, %eax
movslq (%r14), %rcx
cmpq %rcx, %rax
jge 0x1be52
movq (%rbp), %rcx
movslq 0x8(%rbp), %rdx
leaq 0x1(%rdx), %rsi
movl %esi, 0x8(%rbp)
movl %eax, 0x4(%rcx,%rdx,4)
andq $0x0, (%r15,%rax,8)
movb $0x0, (%r12,%rax)
incq %rax
jmp 0x1be28
movq %rbp, %rdi
callq 0x1bd1b
movslq 0x8(%rbp), %rax
cmpq $-0x1, %rax
je 0x1be8a
movq (%rbp), %rcx
leal -0x1(%rax), %edx
movl %edx, 0x8(%rbp)
movslq (%rcx,%rax,4), %rax
jmp 0x1be8d
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x117e9
pushq $-0x1
popq %rax
movb $0x1, (%r12,%rax)
movq 0x10(%rbx), %r9
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x1bef0
testb %al, %al
je 0x1be92
movq %rbp, %rdi
callq 0x1bd06
movq %r15, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/executables/outerplanaritytest.c
// Function: printHelp
int printHelp() {
#include "../o/help/outerplanaritytestHelp.help"
	unsigned char* help = executables_outerplanaritytestHelp_txt;
	int len = executables_outerplanaritytestHelp_txt_len;
	if (help != NULL) {
		int i=0;
		for (i=0; i<len; ++i) {
			fputc(help[i], stdout);
		}
		return EXIT_SUCCESS;
	} else {
		fprintf(stderr, "Could not read help file\n");
		return EXIT_FAILURE;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %ebx, %ebx
leaq 0x201a(%rip), %r14      # 0x1e080
movq 0xdf5b(%rip), %r15      # 0x29fc8
cmpq $0x4a7, %rbx            # imm = 0x4A7
je 0x1c088
movzbl (%rbx,%r14), %edi
movq (%r15), %rsi
callq 0x1100
incq %rbx
jmp 0x1c06d
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/executables/outerplanaritytest.c
// Function: addSpiderWebEdges
void addSpiderWebEdges(struct BBTree* bbTree, struct ShallowGraphPool* sgp) {
    printf(", \"spiderweb\": {");
    if (bbTree->tree->n > 0) {
        computeDistanceToCenter(bbTree->tree, sgp);
        char first = 1;
        for (int v=0; v<bbTree->tree->n; ++v) {
            if (first) {
                first = 0;
            } else {
                printf(", ");
            }
            printf("\"%d\": %d", bbTree->originalIDs[v], bbTree->tree->vertices[v]->lowPoint);
        }
    }
    putc('}', stdout);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x21a0(%rip), %rdi      # 0x1e614
xorl %eax, %eax
callq 0x10b0
movq (%rbx), %rdi
cmpl $0x0, (%rdi)
jle 0x1c4de
movq %r14, %rsi
callq 0x1a8ad
xorl %eax, %eax
leaq 0xf59(%rip), %r14       # 0x1d3ed
leaq 0x218a(%rip), %r15      # 0x1e625
xorl %r12d, %r12d
movq (%rbx), %rcx
movslq (%rcx), %rdx
cmpq %rdx, %r12
jge 0x1c4de
testb $0x1, %al
je 0x1c4ba
movq %r14, %rdi
xorl %eax, %eax
callq 0x10b0
movq (%rbx), %rcx
movq 0x18(%rbx), %rax
movl (%rax,%r12,4), %esi
movq 0x10(%rcx), %rax
movq (%rax,%r12,8), %rax
movl 0x20(%rax), %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x10b0
incq %r12
movb $0x1, %al
jmp 0x1c49e
movq 0xdae3(%rip), %rax      # 0x29fc8
movq (%rax), %rsi
pushq $0x7d
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1120
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/executables/outerplanaritytest.c
// Function: printInterestingEdges
char printInterestingEdges(struct Vertex* lastInteresting, struct Vertex* v, char notFirst, int* originalIDs, char printAll) {
    v->visited = 1;
    if (v->lowPoint) {
        if (lastInteresting) {
            char isNeighbor = 0;
            for (struct VertexList* e=v->neighborhood; e!=NULL; e=e->next) {
                if (e->endPoint == lastInteresting) {
                    isNeighbor = 1;
                    break;
                }
            }
            if (printAll || !isNeighbor) {
                if (notFirst) {
                    printf(", ");
                }
                printf("[%d, %d]", originalIDs[lastInteresting->number], originalIDs[v->number]);
                notFirst = 1;
            }
        }
    }
    for (struct VertexList* e=v->neighborhood; e!=NULL; e=e->next) {
        if (e->endPoint->visited == 0) {
            if (v->lowPoint) {
                notFirst = printInterestingEdges(v, e->endPoint, notFirst, originalIDs, printAll);
            } else {
                notFirst = printInterestingEdges(lastInteresting, e->endPoint, notFirst, originalIDs, printAll);
            }
        }
    }
    return notFirst;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %ebp
movq %rcx, %rbx
movl %edx, %eax
movq %rsi, %r14
movq %rdi, %r15
movl $0x1, 0x1c(%rsi)
testq %rdi, %rdi
je 0x1c56b
cmpl $0x0, 0x20(%r14)
je 0x1c56b
movq %r14, %rcx
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
je 0x1c53b
cmpq %r15, 0x18(%rcx)
jne 0x1c527
testb %bpl, %bpl
je 0x1c56b
testb %al, %al
je 0x1c54d
leaq 0xea7(%rip), %rdi       # 0x1d3ed
xorl %eax, %eax
callq 0x10b0
movslq 0x18(%r15), %rax
movl (%rbx,%rax,4), %esi
movslq 0x18(%r14), %rax
movl (%rbx,%rax,4), %edx
leaq 0x20cc(%rip), %rdi      # 0x1e62e
xorl %eax, %eax
callq 0x10b0
movb $0x1, %al
movsbl %bpl, %ebp
movq %r14, %r12
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x1c5a6
movq 0x18(%r12), %rsi
cmpl $0x0, 0x1c(%rsi)
jne 0x1c572
cmpl $0x0, 0x20(%r14)
movsbl %al, %edx
je 0x1c596
movq %r14, %rdi
jmp 0x1c599
movq %r15, %rdi
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x1c4fb
jmp 0x1c572
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/executables/outerplanaritytest.c
// Function: addShortcutEdges
void addShortcutEdges(struct BBTree* bbTree, char printAll) {
    int root = 0;
    /* mark interesting vertices, keep the last leaf or join as root */
    for (int v=0; v<bbTree->tree->n; ++v) {
        bbTree->tree->vertices[v]->visited = 0;
        if (degree(bbTree->tree->vertices[v]) != 2) {
            bbTree->tree->vertices[v]->lowPoint = 1;
            root = v;
        } else {
            bbTree->tree->vertices[v]->lowPoint = 0;
        } 
    }
    if (bbTree->blocks) {
        for (int v=0; v<bbTree->blocks->n; ++v) {
            bbTree->blocks->vertices[v]->lowPoint = 2;
        }
    }

    printf(", \"shortcutEdges\": [");
    printInterestingEdges(NULL, bbTree->tree->vertices[root], 0, bbTree->originalIDs, printAll);
    printf("]");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rcx
xorl %r15d, %r15d
xorl %ebp, %ebp
movslq (%rcx), %rax
cmpq %rax, %r15
jge 0x1c601
movq 0x10(%rcx), %rax
movq (%rax,%r15,8), %rdi
andl $0x0, 0x1c(%rdi)
callq 0x5a8a
movq (%r14), %rcx
movq 0x10(%rcx), %rdx
movq (%rdx,%r15,8), %rdx
cmpl $0x2, %eax
jne 0x1c5f2
andl $0x0, 0x20(%rdx)
jmp 0x1c5fc
movl $0x1, 0x20(%rdx)
movl %r15d, %ebp
incq %r15
jmp 0x1c5c3
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x1c62c
movl (%rax), %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
cmpq %rdx, %rcx
je 0x1c62c
movq 0x10(%rax), %rsi
movq (%rsi,%rdx,8), %rsi
movl $0x2, 0x20(%rsi)
incq %rdx
jmp 0x1c613
leaq 0x2004(%rip), %rdi      # 0x1e637
xorl %eax, %eax
callq 0x10b0
movq (%r14), %rax
movq 0x18(%r14), %rcx
movq 0x10(%rax), %rax
movslq %ebp, %rdx
movq (%rax,%rdx,8), %rsi
movsbl %bl, %r8d
xorl %edi, %edi
xorl %edx, %edx
callq 0x1c4fb
pushq $0x5d
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1040
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/executables/outerplanaritytest.c
// Function: printBBTreeEdges
void printBBTreeEdges(struct BBTree* bbTree) {
    int root = 0;
    /* mark all vertices as interesting */
    for (int v=0; v<bbTree->tree->n; ++v) {
        bbTree->tree->vertices[v]->visited = 0;
        bbTree->tree->vertices[v]->lowPoint = 1;
    }

    printf(", \"CATree\": [");
    printInterestingEdges(NULL, bbTree->tree->vertices[root], 0, bbTree->originalIDs, 1);
    printf("]");
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rax
movslq (%rax), %rcx
xorl %edx, %edx
movabsq $0x100000000, %rsi      # imm = 0x100000000
cmpq %rcx, %rdx
jge 0x1c697
movq 0x10(%rax), %rdi
movq (%rdi,%rdx,8), %rdi
movq %rsi, 0x1c(%rdi)
incq %rdx
jmp 0x1c681
leaq 0x1fae(%rip), %rdi      # 0x1e64c
xorl %eax, %eax
callq 0x10b0
movq (%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x10(%rax), %rax
movq (%rax), %rsi
pushq $0x1
popq %r8
xorl %edi, %edi
xorl %edx, %edx
callq 0x1c4fb
pushq $0x5d
popq %rdi
popq %rbx
jmp 0x1040
// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/executables/outerplanaritytest.c
// Function: printBlockVertices
void printBlockVertices(struct BBTree* bbTree, int* originalIDs) {

    printf(", \"blocks\": {");
    if (bbTree->blocks) {
        for (int i=0; i<bbTree->blocks->n; ++i) {
            if (i>0) { printf(", "); }
            printf("\"%d\": [", -1 - i);
            char start = 1;
            // init vertices in g (!)
            for (struct VertexList* e=bbTree->blockComponents[i]->edges; e!=NULL; e=e->next) {
                e->startPoint->visited = 0;
                e->endPoint->visited = 0;
            }
            for (struct VertexList* e=bbTree->blockComponents[i]->edges; e!=NULL; e=e->next) {
                if (e->startPoint->visited == 0) {
                    if (start) { 
                        start = 0; 
                    } else { 
                        printf(", ");
                    }
                    printf("%d", originalIDs[e->startPoint->number]);
                    e->startPoint->visited = 1;
                }
                if (e->endPoint->visited == 0) {
                    printf(", ");
                    printf("%d", originalIDs[e->endPoint->number]);
                    e->endPoint->visited = 1;
                }
            }
            putc(']', stdout);
        }
    }
    putc('}', stdout);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1f79(%rip), %rdi      # 0x1e65a
xorl %eax, %eax
callq 0x10b0
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x1c805
leaq 0xcf1(%rip), %r12       # 0x1d3ed
leaq 0x1f28(%rip), %r13      # 0x1e62b
xorl %r15d, %r15d
movq %r14, (%rsp)
movslq (%rax), %rax
cmpq %rax, %r15
jge 0x1c805
testq %r15, %r15
je 0x1c725
movq %r12, %rdi
xorl %eax, %eax
callq 0x10b0
movl %r15d, %esi
notl %esi
leaq 0x1f37(%rip), %rdi      # 0x1e668
xorl %eax, %eax
callq 0x10b0
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rbp
movq %rbp, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x1c761
movq 0x10(%rax), %rcx
andl $0x0, 0x1c(%rcx)
movq 0x18(%rax), %rcx
andl $0x0, 0x1c(%rcx)
addq $0x8, %rax
jmp 0x1c743
movb $0x1, %r14b
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x1c7e3
movq 0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x1c7a9
testb %r14b, %r14b
jne 0x1c78a
movq %r12, %rdi
xorl %eax, %eax
callq 0x10b0
movq 0x10(%rbp), %rax
movslq 0x18(%rax), %rax
movl (%rbx,%rax,4), %esi
xorl %r14d, %r14d
movq %r13, %rdi
xorl %eax, %eax
callq 0x10b0
movq 0x10(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq 0x18(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x1c7dd
movq %r12, %rdi
xorl %eax, %eax
callq 0x10b0
movq 0x18(%rbp), %rax
movslq 0x18(%rax), %rax
movl (%rbx,%rax,4), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x10b0
movq 0x18(%rbp), %rax
movl $0x1, 0x1c(%rax)
addq $0x8, %rbp
jmp 0x1c764
movq 0xd7de(%rip), %rax      # 0x29fc8
movq (%rax), %rsi
pushq $0x5d
popq %rdi
callq 0x1120
incq %r15
movq (%rsp), %r14
movq 0x8(%r14), %rax
jmp 0x1c70a
movq 0xd7bc(%rip), %rax      # 0x29fc8
movq (%rax), %rsi
pushq $0x7d
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1120
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_led
void dap_led(int index, int state)
{
  uint8_t buf[3];

  buf[0] = ID_DAP_LED;
  buf[1] = index;
  buf[2] = state;
  dbg_dap_cmd(buf, sizeof(buf), 3);

  check(DAP_OK == buf[0], "DAP_LED failed");
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0xd(%rsp), %rbx
movb $0x1, (%rbx)
movb %dil, 0x1(%rbx)
movb %sil, 0x2(%rbx)
pushq $0x3
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0xed2e
xorl %edi, %edi
cmpb $0x0, (%rbx)
sete %dil
leaq 0x9c04(%rip), %rsi      # 0x10020
xorl %eax, %eax
callq 0x793d
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_connect
void dap_connect(int interf)
{
  uint8_t buf[2];
  int cap = (DAP_INTERFACE_SWD == interf) ? DAP_CAP_SWD : DAP_CAP_JTAG;

  buf[0] = ID_DAP_CONNECT;
  buf[1] = cap;
  dbg_dap_cmd(buf, sizeof(buf), 2);

  check(buf[0] == cap, "DAP_CONNECT failed");

  dap_interface = interf;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
xorl %ebp, %ebp
cmpl $0x1, %edi
setne %bpl
incl %ebp
leaq 0xe(%rsp), %r14
movb $0x2, (%r14)
movb %bpl, 0x1(%r14)
pushq $0x2
popq %rdx
movq %r14, %rdi
movl %edx, %esi
callq 0xed2e
movzbl (%r14), %eax
xorl %edi, %edi
cmpl %eax, %ebp
sete %dil
leaq 0x9bc4(%rip), %rsi      # 0x1002f
xorl %eax, %eax
callq 0x793d
movl %ebx, 0x16cd8(%rip)     # 0x1d150
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_swj_clock
void dap_swj_clock(uint32_t clock)
{
  uint8_t buf[5];

  buf[0] = ID_DAP_SWJ_CLOCK;
  buf[1] = clock & 0xff;
  buf[2] = (clock >> 8) & 0xff;
  buf[3] = (clock >> 16) & 0xff;
  buf[4] = (clock >> 24) & 0xff;
  dbg_dap_cmd(buf, sizeof(buf), 5);

  check(DAP_OK == buf[0], "SWJ_CLOCK failed");
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %edi, %eax
leaq 0xb(%rsp), %rbx
movb $0x11, (%rbx)
movb %al, 0x1(%rbx)
movb %ah, 0xd(%rsp)
movl %edi, %ecx
shrl $0x10, %ecx
movb %cl, 0x3(%rbx)
shrl $0x18, %eax
movb %al, 0x4(%rbx)
pushq $0x5
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0xed2e
xorl %edi, %edi
cmpb $0x0, (%rbx)
sete %dil
leaq 0x9b64(%rip), %rsi      # 0x10042
xorl %eax, %eax
callq 0x793d
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_transfer_configure
void dap_transfer_configure(uint8_t idle, uint16_t retry, uint16_t match_retry)
{
  uint8_t buf[6];

  buf[0] = ID_DAP_TRANSFER_CONFIGURE;
  buf[1] = idle;
  buf[2] = retry & 0xff;
  buf[3] = (retry >> 8) & 0xff;
  buf[4] = match_retry & 0xff;
  buf[5] = (match_retry >> 8) & 0xff;
  dbg_dap_cmd(buf, sizeof(buf), 6);

  check(DAP_OK == buf[0], "TRANSFER_CONFIGURE failed");
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
leaq 0xa(%rsp), %rbx
movb $0x4, (%rbx)
movb %dil, 0x1(%rbx)
movb %al, 0x2(%rbx)
movb %ah, 0xd(%rsp)
movb %dl, 0x4(%rbx)
movb %dh, 0xf(%rsp)
pushq $0x6
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0xed2e
xorl %edi, %edi
cmpb $0x0, (%rbx)
sete %dil
leaq 0x9b2a(%rip), %rsi      # 0x10053
xorl %eax, %eax
callq 0x793d
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_swd_configure
void dap_swd_configure(int cfg)
{
  uint8_t buf[2];

  buf[0] = ID_DAP_SWD_CONFIGURE;
  buf[1] = cfg;
  dbg_dap_cmd(buf, sizeof(buf), 2);

  check(DAP_OK == buf[0], "SWD_CONFIGURE failed");
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0xe(%rsp), %rbx
movb $0x13, (%rbx)
movb %dil, 0x1(%rbx)
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0xed2e
xorl %edi, %edi
cmpb $0x0, (%rbx)
sete %dil
leaq 0x9b09(%rip), %rsi      # 0x1006d
xorl %eax, %eax
callq 0x793d
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_configure
void dap_jtag_configure(int count, int *ir_len)
{
  uint8_t buf[32];

  buf[0] = ID_DAP_JTAG_CONFIGURE;
  buf[1] = count;
  for (int i = 0; i < count; i++)
    buf[2+i] = ir_len[i];
  dbg_dap_cmd(buf, sizeof(buf), 2 + count);

  check(DAP_OK == buf[0], "JTAG_CONFIGURE failed");
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movl %edi, %edx
movb $0x15, (%rsp)
movb %dl, 0x1(%rsp)
xorl %eax, %eax
testl %edi, %edi
movl $0x0, %ecx
cmovgl %edi, %ecx
cmpq %rax, %rcx
je 0x659f
movb (%rsi,%rax,4), %dil
movb %dil, 0x2(%rsp,%rax)
incq %rax
jmp 0x658c
addl $0x2, %edx
movq %rsp, %rbx
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0xed2e
xorl %edi, %edi
cmpb $0x0, (%rbx)
sete %dil
leaq 0x9ac2(%rip), %rsi      # 0x10082
xorl %eax, %eax
callq 0x793d
addq $0x20, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_info
int dap_info(int info, uint8_t *data, int size)
{
  uint8_t buf[256];
  int rsize;

  buf[0] = ID_DAP_INFO;
  buf[1] = info;
  dbg_dap_cmd(buf, sizeof(buf), 2);

  rsize = (size < buf[0]) ? size : buf[0];
  memcpy(data, &buf[1], rsize);

  if (rsize < size)
    data[rsize] = 0;

  return rsize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edx, %r15d
movq %rsi, %rbx
leaq 0x1(%rsp), %r12
movb $0x0, -0x1(%r12)
movb %dil, (%r12)
movq %rsp, %r14
pushq $0x2
popq %rdx
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0xed2e
movzbl (%r14), %r13d
cmpl %r15d, %r13d
movl %r15d, %ebp
cmovll %r13d, %ebp
movslq %ebp, %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6190
cmpl %r15d, %r13d
jge 0x6636
movb $0x0, (%rbx,%r14)
movl %ebp, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_read_idcode
uint32_t dap_read_idcode(void)
{
  if (DAP_INTERFACE_SWD == dap_interface)
  {
    dap_read_idcode_req();
    dap_transfer();
    return dap_response[0];
  }
  else if (DAP_INTERFACE_JTAG == dap_interface)
  {
    uint8_t buf[16];

    buf[0] = ID_DAP_JTAG_IDCODE;
    buf[1] = dap_jtag_index;

    dbg_dap_cmd(buf, sizeof(buf), 2);
    check(DAP_OK == buf[0], "JTAG_IDCODE failed");

    return *((uint32_t *)&buf[1]);
  }

  return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl 0x16910(%rip), %ecx     # 0x1d150
cmpl $0x2, %ecx
je 0x685e
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0x6895
callq 0x6f11
callq 0x68f4
movl 0x471a4(%rip), %eax     # 0x4da00
jmp 0x6895
movq %rsp, %rbx
movb $0x16, (%rbx)
movb 0x168ea(%rip), %al      # 0x1d154
movb %al, 0x1(%rbx)
pushq $0x10
popq %rsi
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0xed2e
xorl %edi, %edi
cmpb $0x0, (%rbx)
sete %dil
leaq 0x998c(%rip), %rsi      # 0x10217
xorl %eax, %eax
callq 0x793d
movl 0x1(%rbx), %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_reset_target_hw
void dap_reset_target_hw(int state)
{
  uint8_t buf[7];
  int value = state ? (DAP_SWJ_SWCLK_TCK | DAP_SWJ_SWDIO_TMS) : 0;

  //-------------
  buf[0] = ID_DAP_SWJ_PINS;
  buf[1] = value; // Value
  buf[2] = DAP_SWJ_nRESET | DAP_SWJ_SWCLK_TCK | DAP_SWJ_SWDIO_TMS; // Select
  buf[3] = 0; // Wait
  buf[4] = 0;
  buf[5] = 0;
  buf[6] = 0;
  dbg_dap_cmd(buf, sizeof(buf), 7);

  sleep_ms(10);

  //-------------
  buf[0] = ID_DAP_SWJ_PINS;
  buf[1] = DAP_SWJ_nRESET | value; // Value
  buf[2] = DAP_SWJ_nRESET | DAP_SWJ_SWCLK_TCK | DAP_SWJ_SWDIO_TMS; // Select
  buf[3] = 0; // Wait
  buf[4] = 0;
  buf[5] = 0;
  buf[6] = 0;
  dbg_dap_cmd(buf, sizeof(buf), 7);

  sleep_ms(10);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %eax, %eax
testl %edi, %edi
movb $0x10, %r15b
leaq 0x1(%rsp), %rbx
movb %r15b, (%rbx)
setne %al
leal (%rax,%rax,2), %r12d
movb %r12b, 0x1(%rbx)
movb $-0x7d, %r13b
movb %r13b, 0x2(%rbx)
andl $0x0, 0x3(%rbx)
pushq $0x7
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0xed2e
pushq $0xa
popq %r14
movl %r14d, %edi
callq 0x7aeb
movb %r15b, (%rbx)
orb $-0x80, %r12b
movb %r12b, 0x1(%rbx)
movb %r13b, 0x2(%rbx)
andl $0x0, 0x3(%rbx)
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0xed2e
movl %r14d, %edi
callq 0x7aeb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_reset_pin
void dap_reset_pin(int state)
{
  uint8_t buf[7];

  buf[0] = ID_DAP_SWJ_PINS;
  buf[1] = state ? DAP_SWJ_nRESET : 0; // Value
  buf[2] = DAP_SWJ_nRESET; // Select
  buf[3] = 0; // Wait
  buf[4] = 0;
  buf[5] = 0;
  buf[6] = 0;
  dbg_dap_cmd(buf, sizeof(buf), 7);
}

// Assembly:
pushq %rax
testl %edi, %edi
setne %al
leaq 0x1(%rsp), %rdi
movb $0x10, (%rdi)
shlb $0x7, %al
movb %al, 0x1(%rdi)
movb $-0x80, 0x2(%rdi)
andl $0x0, 0x3(%rdi)
pushq $0x7
popq %rdx
movl %edx, %esi
callq 0xed2e
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_read_block
void dap_read_block(uint32_t addr, uint8_t *data, int size)
{
  uint32_t ptr = addr;
  uint32_t rem = size;
  int cnt = 0;

  if (size == 0)
    return;

  while (rem && (ptr % sizeof(uint32_t)))
  {
    dap_read_byte_req(ptr);
    ptr += sizeof(uint8_t);
    rem -= sizeof(uint8_t);
  }

  while (rem >= sizeof(uint32_t))
  {
    dap_read_word_req(ptr);
    ptr += sizeof(uint32_t);
    rem -= sizeof(uint32_t);
  }

  while (rem)
  {
    dap_read_byte_req(ptr);
    ptr += sizeof(uint8_t);
    rem -= sizeof(uint8_t);
  }

  dap_transfer();

  while (size && (addr % sizeof(uint32_t)))
  {
    *data = dap_response[cnt++];
    data += sizeof(uint8_t);
    addr += sizeof(uint8_t);
    size -= sizeof(uint8_t);
  }

  while (size >= (int)sizeof(uint32_t))
  {
    *(uint32_t *)data = dap_response[cnt++];
    data += sizeof(uint32_t);
    size -= sizeof(uint32_t);
  }

  while (size)
  {
    *data = dap_response[cnt++];
    data += sizeof(uint8_t);
    size -= sizeof(uint8_t);
  }
}

// Assembly:
testl %edx, %edx
je 0x70ee
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movl %edi, %r14d
movl %edi, %r15d
movl %edx, %r12d
movl %ebp, %r13d
addl $-0x1, %r13d
jae 0x706a
movl %r15d, %eax
andl $0x3, %eax
je 0x706a
movl %r15d, %edi
callq 0x6ebd
incl %r15d
movl %r13d, %r12d
jmp 0x703c
movl %r15d, %edi
callq 0x6ed8
addl $0x4, %r15d
addl $-0x4, %r12d
cmpl $0x3, %r12d
ja 0x705a
xorl %r13d, %r13d
cmpl %r13d, %r12d
je 0x7086
leal (%r15,%r13), %edi
callq 0x6ebd
incl %r13d
jmp 0x7073
callq 0x68f4
movl %r14d, %esi
movl %ebp, %eax
leaq 0x46969(%rip), %rcx     # 0x4da00
xorl %edx, %edx
cmpl %edx, %eax
je 0x70b5
leal (%rsi,%rdx), %edi
andl $0x3, %edi
je 0x70b5
movb (%rcx), %dil
movb %dil, (%rbx,%rdx)
incq %rdx
addq $0x4, %rcx
jmp 0x7099
subl %edx, %ebp
cmpl $0x3, %ebp
jle 0x70dc
movl (%rcx), %esi
movl %esi, (%rbx,%rdx)
addl $-0x4, %ebp
addq $0x4, %rcx
addq $0x4, %rdx
jmp 0x70b7
movb (%rcx), %sil
movb %sil, (%rbx,%rdx)
addq $0x4, %rcx
incq %rdx
cmpl %edx, %eax
jne 0x70ce
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_write_block
void dap_write_block(uint32_t addr, uint8_t *data, int size)
{
  if (size == 0)
    return;

  while (size && (addr % sizeof(uint32_t)))
  {
    dap_write_byte_req(addr, *data);
    data += sizeof(uint8_t);
    addr += sizeof(uint8_t);
    size -= sizeof(uint8_t);
  }

  while (size >= (int)sizeof(uint32_t))
  {
    dap_write_word_req(addr, *(uint32_t *)data);
    data += sizeof(uint32_t);
    addr += sizeof(uint32_t);
    size -= sizeof(uint32_t);
  }

  while (size)
  {
    dap_write_byte_req(addr, *data);
    data += sizeof(uint8_t);
    addr += sizeof(uint8_t);
    size -= sizeof(uint8_t);
  }

  dap_transfer();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testl %edx, %edx
je 0x7169
movl %edx, %ebp
movq %rsi, %rbx
movl %edi, %r14d
movl %edx, %r15d
xorl %r12d, %r12d
cmpl %r12d, %r15d
je 0x7128
leaq (%r14,%r12), %rdi
movl %edi, %eax
andl $0x3, %eax
je 0x7128
movzbl (%rbx,%r12), %esi
callq 0x6ee6
incq %r12
jmp 0x7109
subl %r12d, %ebp
cmpl $0x3, %ebp
jle 0x7157
leaq (%r14,%r12), %rdi
movl (%rbx,%r12), %esi
callq 0x6f02
addl $-0x4, %ebp
addq $0x4, %r12
jmp 0x712b
leaq (%r14,%r12), %rdi
movzbl (%rbx,%r12), %esi
callq 0x6ee6
incq %r12
cmpl %r12d, %r15d
jne 0x7146
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x68f4
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_add_req
static void dap_jtag_add_req(int tdi, int tms, int tdo)
{
  dap_jtag_request_t req;
  req.tdi = tdi ? 1 : 0;
  req.opt = (tms ? JTAG_SEQUENCE_TMS : 0) | (tdo ? JTAG_SEQUENCE_TDO : 0);
  assert(dap_request_count < TRANSFER_SIZE);
  dap_jtag_request[dap_jtag_request_count++] = req;
}

// Assembly:
cmpl $0x4000, 0x15fd8(%rip)  # imm = 0x4000
jge 0x71b6
testl %edx, %edx
setne %al
testl %esi, %esi
setne %cl
shlb $0x6, %cl
shlb $0x7, %al
orb %cl, %al
movslq 0x56865(%rip), %rcx     # 0x5da00
leal 0x1(%rcx), %edx
testl %edi, %edi
movl %edx, 0x5685a(%rip)     # 0x5da00
leaq 0x58873(%rip), %rdx     # 0x5fa20
movb %al, (%rdx,%rcx,2)
setne 0x1(%rdx,%rcx,2)
retq
pushq %rax
leaq 0x90c9(%rip), %rdi      # 0x10287
leaq 0x8f7b(%rip), %rsi      # 0x10140
leaq 0x910c(%rip), %rcx      # 0x102d8
movl $0x3f6, %edx            # imm = 0x3F6
callq 0x60d0
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_read
void dap_jtag_read(int offset, uint8_t *data, int size)
{
  dap_jtag_flush();

  for (int i = 0; i < size; i++)
  {
    int index = offset + i;
    int bit;

    assert(index < dap_jtag_response_count);

    bit = (dap_jtag_response_buf[index / 8] & (1 << (index % 8))) ? 1 : 0;

    if ((i % 8) == 0)
      data[i / 8] = 0;

    data[i / 8] |= (bit << (i % 8));
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
callq 0x71db
movl 0x585c4(%rip), %esi     # 0x5fa10
xorl %edi, %edi
testl %ebx, %ebx
cmovlel %edi, %ebx
pushq $0x8
popq %r8
leaq 0x565b2(%rip), %r9      # 0x5da10
cmpl %edi, %ebx
je 0x74a1
leal (%r15,%rdi), %ecx
cmpl %esi, %ecx
jge 0x74a7
movl %ecx, %eax
cltd
idivl %r8d
cltq
movzbl (%rax,%r9), %edx
andl $0x7, %ecx
xorl %eax, %eax
btl %ecx, %edx
setb %r10b
movl %edi, %edx
shrl $0x3, %edx
movl %edi, %ecx
andl $0x7, %ecx
jne 0x7494
movb $0x0, (%r14,%rdx)
movb %r10b, %al
shll %cl, %eax
orb %al, (%r14,%rdx)
incl %edi
jmp 0x745e
popq %rbx
popq %r14
popq %r15
retq
leaq 0x8d91(%rip), %rdi      # 0x1023f
leaq 0x8c8b(%rip), %rsi      # 0x10140
leaq 0x8da3(%rip), %rcx      # 0x1025f
movl $0x467, %edx            # imm = 0x467
callq 0x60d0
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_write_ir
void dap_jtag_write_ir(int ir, int size)
{
  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 0);
  dap_jtag_clk(0, 0);

  for (int i = 0; i < size; i++)
    dap_jtag_clk((ir >> i) & 1, i == (size-1));

  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
xorl %r15d, %r15d
pushq $0x1
popq %r14
xorl %edi, %edi
movl %r14d, %esi
callq 0x7172
xorl %edi, %edi
movl %r14d, %esi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
leal -0x1(%rbx), %r14d
testl %ebx, %ebx
cmovlel %r15d, %ebx
cmpl %r15d, %ebx
je 0x756c
xorl %edi, %edi
btl %r15d, %ebp
setb %dil
xorl %esi, %esi
cmpl %r15d, %r14d
sete %sil
callq 0x7172
incl %r15d
jmp 0x754a
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x7172
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_write_dr
void dap_jtag_write_dr(uint8_t *data, int size)
{
  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 0);
  dap_jtag_clk(0, 0);

  for (int i = 0; i < size; i++)
    dap_jtag_clk((data[i / 8] >> (i % 8)) & 1, i == (size-1));

  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
xorl %ebp, %ebp
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
leal -0x1(%rbx), %r15d
testl %ebx, %ebx
cmovlel %ebp, %ebx
cmpl %ebp, %ebx
je 0x75ea
movl %ebp, %eax
shrl $0x3, %eax
movzbl (%r14,%rax), %eax
movl %ebp, %ecx
andl $0x7, %ecx
xorl %edi, %edi
btl %ecx, %eax
setb %dil
xorl %esi, %esi
cmpl %ebp, %r15d
sete %sil
callq 0x7172
incl %ebp
jmp 0x75bc
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x7172
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_read_dr
void dap_jtag_read_dr(uint8_t *data, int size)
{
  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 0);
  dap_jtag_clk(0, 0);

  for (int i = 0; i < size; i++)
    dap_jtag_clk_read(0, i == (size-1));

  dap_jtag_clk(0, 1);
  dap_jtag_clk(0, 0);

  dap_jtag_read(0, data, size);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
xorl %ebp, %ebp
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
testl %ebx, %ebx
movl $0x0, %r15d
cmovgl %ebx, %r15d
leal -0x1(%rbx), %r12d
cmpl %ebp, %r15d
je 0x765b
xorl %esi, %esi
cmpl %ebp, %r12d
sete %sil
xorl %edi, %edi
callq 0x71d6
incl %ebp
jmp 0x7642
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x7172
xorl %edi, %edi
xorl %esi, %esi
callq 0x7172
xorl %edi, %edi
movq %r14, %rsi
movl %ebx, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x7434
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/dap.c
// Function: dap_jtag_scan_chain
int dap_jtag_scan_chain(uint32_t *idcode, int size)
{
  int count = 0;

  dap_jtag_reset();

  dap_jtag_clk(1, 1);
  dap_jtag_clk(1, 0);
  dap_jtag_clk(1, 0);

  for (int i = 0; i < size; i++)
  {
    for (int j = 0; j < 32; j++)
      dap_jtag_clk_read(0, 0);

    dap_jtag_read(0, (uint8_t *)&idcode[count], 32);

    if (idcode[count])
      count++;
    else
      break;
  }

  dap_jtag_clk(1, 1);
  dap_jtag_clk(1, 1);
  dap_jtag_clk(1, 0);

  return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
callq 0x74e2
pushq $0x1
popq %rbp
movl %ebp, %edi
movl %ebp, %esi
callq 0x7172
xorl %r12d, %r12d
movl %ebp, %edi
xorl %esi, %esi
callq 0x7172
movl %ebp, %edi
xorl %esi, %esi
callq 0x7172
testl %ebx, %ebx
cmovlel %r12d, %ebx
pushq $0x20
popq %rbp
cmpq %rbx, %r12
je 0x76f5
movl %ebp, %r15d
subl $0x1, %r15d
jb 0x76d7
xorl %edi, %edi
xorl %esi, %esi
callq 0x71d6
jmp 0x76c6
leaq (%r14,%r12,4), %r15
xorl %edi, %edi
movq %r15, %rsi
movl %ebp, %edx
callq 0x7434
cmpl $0x0, (%r15)
je 0x76f2
incq %r12
jmp 0x76be
movl %r12d, %ebx
pushq $0x1
popq %rbp
movl %ebp, %edi
movl %ebp, %esi
callq 0x7172
movl %ebp, %edi
movl %ebp, %esi
callq 0x7172
movl %ebp, %edi
xorl %esi, %esi
callq 0x7172
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: verbose
void verbose(char *fmt, ...)
{
  va_list args;

  if (g_verbose)
  {
    va_start(args, fmt);
    vprintf(fmt, args);
    va_end(args);

    fflush(stdout);
  }
}

// Assembly:
subq $0xd8, %rsp
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x7797
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
cmpb $0x1, 0x78292(%rip)     # 0x7fa30
jne 0x77d9
leaq 0x20(%rsp), %rax
movq %rsp, %rsi
movq %rax, 0x10(%rsi)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsi)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsi)
callq 0x61c0
movq 0x147ef(%rip), %rax     # 0x1bfc0
movq (%rax), %rdi
callq 0x61b0
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: warning
void warning(char *fmt, ...)
{
  va_list args;

  va_start(args, fmt);
  fprintf(stderr, "Warning: ");
  vfprintf(stderr, fmt, args);
  fprintf(stderr, "\n");
  va_end(args);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x78db
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r14
movq %rdi, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
movq 0x146ee(%rip), %r15     # 0x1bff0
movq (%r15), %rcx
leaq 0x8c74(%rip), %rdi      # 0x10580
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
callq 0x6280
movq (%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6230
movq (%r15), %rsi
pushq $0xa
popq %rdi
callq 0x6130
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: check
void check(bool cond, char *fmt, ...)
{
  if (cond)
    return;

  va_list args;

  va_start(args, fmt);
  fprintf(stderr, "Error: ");
  vfprintf(stderr, fmt, args);
  fprintf(stderr, "\n");
  va_end(args);

  exit(1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x7998
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
testl %edi, %edi
je 0x79a9
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rsi, %rbx
leaq 0x20(%rsp), %rax
movq %rsp, %r14
movq %rax, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%r14)
movq 0x14618(%rip), %r15     # 0x1bff0
movq (%r15), %rcx
leaq 0x8ba8(%rip), %rdi      # 0x1058a
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x6280
movq (%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6230
movq (%r15), %rsi
pushq $0xa
popq %rdi
callq 0x6130
pushq $0x1
popq %rdi
callq 0x6270
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: error_exit
void error_exit(char *fmt, ...)
{
  va_list args;

  va_start(args, fmt);
  fprintf(stderr, "Error: ");
  vfprintf(stderr, fmt, args);
  fprintf(stderr, "\n");
  va_end(args);

  exit(1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x7a71
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r14
movq %rdi, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
movq 0x14558(%rip), %r15     # 0x1bff0
movq (%r15), %rcx
leaq 0x8ae8(%rip), %rdi      # 0x1058a
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x6280
movq (%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6230
movq (%r15), %rsi
pushq $0xa
popq %rdi
callq 0x6130
pushq $0x1
popq %rdi
callq 0x6270
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: sleep_ms
void sleep_ms(int ms)
{
#ifdef _WIN32
  Sleep(ms);
#else
  struct timespec ts;

  ts.tv_sec = ms / 1000;
  ts.tv_nsec = (ms % 1000) * 1000000;

  nanosleep(&ts, NULL);
#endif
}

// Assembly:
subq $0x18, %rsp
movl %edi, %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cltq
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
imull $0xf4240, %edx, %eax    # imm = 0xF4240
cltq
movq %rax, 0x8(%rdi)
xorl %esi, %esi
callq 0x60c0
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: load_file
int load_file(char *name, uint8_t *data, int size)
{
  struct stat stat;
  int fd, rsize;

  check(NULL != name, "input file name is not specified");

  fd = open(name, O_RDONLY | O_BINARY);

  if (fd < 0)
    perror_exit("open()");

  fstat(fd, &stat);

  if (stat.st_size < size)
    size = stat.st_size;

  rsize = read(fd, data, size);

  if (rsize < 0)
    perror_exit("read()");

  check(rsize == size, "cannot fully read file");

  close(fd);

  return rsize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %edi, %edi
testq %rbx, %rbx
setne %dil
leaq 0x8a3a(%rip), %rsi      # 0x105a0
xorl %eax, %eax
callq 0x793d
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x6200
testl %eax, %eax
js 0x7be0
movl %eax, %ebx
leaq 0x8(%rsp), %r15
movl %eax, %edi
movq %r15, %rsi
callq 0x62b0
movq 0x30(%r15), %rax
movslq %ebp, %r15
cmpq %r15, %rax
cmovll %eax, %r15d
movslq %r15d, %rdx
movl %ebx, %edi
movq %r14, %rsi
callq 0x6140
movq %rax, %r14
testl %r14d, %r14d
js 0x7bec
xorl %edi, %edi
cmpl %r14d, %r15d
sete %dil
leaq 0x8a0e(%rip), %rsi      # 0x105cf
xorl %eax, %eax
callq 0x793d
movl %ebx, %edi
callq 0x6120
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x89da(%rip), %rdi      # 0x105c1
callq 0x7ace
leaq 0x89d5(%rip), %rdi      # 0x105c8
callq 0x7ace
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/edbg.c
// Function: save_file
void save_file(char *name, uint8_t *data, int size)
{
  int fd, rsize;

  check(NULL != name, "output file name is not specified");

  fd = open(name, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0644);

  if (fd < 0)
    perror_exit("open()");

  rsize = write(fd, data, size);

  if (rsize < 0)
    perror_exit("write()");

  check(rsize == size, "error writing the file");

  close(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
xorl %edi, %edi
testq %r15, %r15
setne %dil
leaq 0x89cf(%rip), %rsi      # 0x105e6
xorl %eax, %eax
callq 0x793d
movq %r15, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x6200
testl %eax, %eax
js 0x7c70
movl %eax, %ebp
movslq %ebx, %rdx
movl %eax, %edi
movq %r14, %rsi
callq 0x6060
testl %eax, %eax
js 0x7c7c
xorl %edi, %edi
cmpl %ebx, %eax
sete %dil
leaq 0x89b0(%rip), %rsi      # 0x10608
xorl %eax, %eax
callq 0x793d
movl %ebp, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6120
leaq 0x894a(%rip), %rdi      # 0x105c1
callq 0x7ace
leaq 0xabda(%rip), %rdi      # 0x1285d
callq 0x7ace
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/utils.c
// Function: sha256
void sha256(uint8_t *data, int size, uint8_t *hash)
{
  uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
  uint64_t bit_size = size * 8;
  uint8_t buf[64];

  while (size >= 64)
  {
    sha256_process(H, data);
    data += 64;
    size -= 64;
  }

  memset(buf, 0, sizeof(buf));
  memcpy(buf, data, size);

  buf[size] = 0x80;

  if (size >= 56)
  {
    sha256_process(H, buf);
    memset(buf, 0, sizeof(buf));
  }

  buf[56] = bit_size >> 56;
  buf[57] = bit_size >> 48;
  buf[58] = bit_size >> 40;
  buf[59] = bit_size >> 32;
  buf[60] = bit_size >> 24;
  buf[61] = bit_size >> 16;
  buf[62] = bit_size >> 8;
  buf[63] = bit_size;

  sha256_process(H, buf);

  for (int i = 0; i < 8; i++)
  {
    hash[i*4+0] = H[i] >> 24;
    hash[i*4+1] = H[i] >> 16;
    hash[i*4+2] = H[i] >> 8;
    hash[i*4+3] = H[i];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movaps 0x8c8a(%rip), %xmm0     # 0x11380
movq %rsp, %r13
movaps %xmm0, 0x10(%r13)
movaps 0x8c6b(%rip), %xmm0     # 0x11370
movaps %xmm0, (%r13)
leal (,%r14,8), %ebp
movslq %esi, %r12
cmpl $0x40, %r12d
jl 0x8730
movq %r13, %rdi
movq %r15, %rsi
callq 0x87fd
addq $0x40, %r15
addq $-0x40, %r12
jmp 0x8715
movslq %ebp, %r13
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movq %r15, %rsi
movq %r12, %rdx
callq 0x6190
movb $-0x80, 0x20(%rsp,%r12)
cmpl $0x38, %r12d
jl 0x8787
movq %rsp, %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x87fd
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movq %r13, %rax
shrq $0x38, %rax
leaq 0x20(%rsp), %rsi
movb %al, 0x38(%rsi)
movq %r13, %rax
shrq $0x30, %rax
movb %al, 0x39(%rsi)
movq %r13, %rax
shrq $0x28, %rax
movb %al, 0x3a(%rsi)
movl %r14d, %eax
sarl $0x1c, %eax
movb %al, 0x3b(%rsi)
movl %r14d, %eax
shrl $0x15, %eax
movb %al, 0x3c(%rsi)
movl %r14d, %eax
shrl $0xd, %eax
movb %al, 0x3d(%rsi)
shrl $0x5, %r14d
movb %r14b, 0x3e(%rsi)
movb %r13b, 0x3f(%rsi)
movq %rsp, %rdi
callq 0x87fd
xorl %eax, %eax
cmpq $0x8, %rax
je 0x87ee
movl (%rsp,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
jmp 0x87db
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/utils.c
// Function: sha256_process
static void sha256_process(uint32_t *H, uint8_t *data)
{
  uint32_t W[64];
  uint32_t ah[8]; // Working variables 'a' to 'h'

  for (int t = 0; t < 16; t++)
    W[t] = (data[t*4] << 24) | (data[t*4+1] << 16) | (data[t*4+2] << 8) | (data[t*4+3]);

  for (int t = 16; t < 64; t++)
    W[t] = SL1(W[t-2]) + W[t-7] + SL0(W[t-15]) + W[t-16];

  for(int t = 0; t < 8; t++)
    ah[t] = H[t];

  for (int t = 0; t < 64; t++)
  {
    uint32_t T1 = ah[7] + SU1(ah[4]) + CH(ah[4], ah[5], ah[6]) + K[t] + W[t];
    uint32_t T2 = SU0(ah[0]) + MAJ(ah[0], ah[1], ah[2]);

    ah[7] = ah[6];
    ah[6] = ah[5];
    ah[5] = ah[4];
    ah[4] = ah[3] + T1;
    ah[3] = ah[2];
    ah[2] = ah[1];
    ah[1] = ah[0];
    ah[0] = T1 + T2;
  }

  for (int t = 0; t < 8; t++)
    H[t] += ah[t];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
xorl %eax, %eax
cmpq $0x10, %rax
je 0x8824
movl (%rsi,%rax,4), %ecx
bswapl %ecx
movl %ecx, -0x60(%rsp,%rax,4)
incq %rax
jmp 0x8810
movabsq $0x10, %rax
cmpq $0x40, %rax
je 0x887b
movl -0x68(%rsp,%rax,4), %ecx
movl %ecx, %edx
roll $0xf, %edx
movl %ecx, %esi
roll $0xd, %esi
xorl %edx, %esi
shrl $0xa, %ecx
xorl %esi, %ecx
addl -0x7c(%rsp,%rax,4), %ecx
movl -0x9c(%rsp,%rax,4), %edx
movl %edx, %esi
roll $0x19, %esi
movl %edx, %r8d
roll $0xe, %r8d
xorl %esi, %r8d
shrl $0x3, %edx
addl -0xa0(%rsp,%rax,4), %ecx
xorl %r8d, %edx
addl %edx, %ecx
movl %ecx, -0x60(%rsp,%rax,4)
incq %rax
jmp 0x882e
xorl %eax, %eax
cmpq $0x8, %rax
je 0x888f
movl (%rdi,%rax,4), %ecx
movl %ecx, -0x80(%rsp,%rax,4)
incq %rax
jmp 0x887d
movl -0x64(%rsp), %ebp
movl -0x70(%rsp), %ebx
movl -0x6c(%rsp), %r10d
movl -0x68(%rsp), %r12d
movl -0x80(%rsp), %r9d
movl -0x7c(%rsp), %ecx
movl -0x78(%rsp), %esi
movl -0x74(%rsp), %eax
xorl %r8d, %r8d
movl %r12d, %r11d
cmpq $0x100, %r8             # imm = 0x100
je 0x894b
movl %ebx, %r15d
movl %ebx, %r14d
movl %ebx, %r13d
roll $0x1a, %r13d
movl %r10d, %edx
xorl %r11d, %edx
andl %ebx, %edx
roll $0x15, %r15d
movl %r10d, %r12d
movl %ebx, %r10d
xorl %r13d, %r15d
roll $0x7, %r14d
xorl %r15d, %r14d
addl %ebp, %r14d
leaq 0x8e98(%rip), %rbx      # 0x11790
addl (%r8,%rbx), %r14d
xorl %r11d, %edx
addl %edx, %r14d
addl -0x60(%rsp,%r8), %r14d
movl %r9d, %edx
movl %r9d, %ebp
movl %esi, %r15d
movl %eax, %ebx
movl %esi, %eax
xorl %ecx, %esi
andl %r9d, %esi
andl %ecx, %r15d
xorl %esi, %r15d
movl %ecx, %esi
movl %r9d, %ecx
roll $0x1e, %r9d
addl %r14d, %ebx
roll $0x13, %edx
xorl %r9d, %edx
roll $0xa, %ebp
xorl %edx, %ebp
addl %ebp, %r15d
addl %r14d, %r15d
addq $0x4, %r8
movl %r15d, %r9d
movl %r11d, %ebp
jmp 0x88b5
movl %ebp, -0x64(%rsp)
movl %ebx, -0x70(%rsp)
movl %r10d, -0x6c(%rsp)
movl %r11d, -0x68(%rsp)
movl %r9d, -0x80(%rsp)
movl %ecx, -0x7c(%rsp)
movl %esi, -0x78(%rsp)
movl %eax, -0x74(%rsp)
xorl %eax, %eax
cmpq $0x8, %rax
je 0x8982
movl -0x80(%rsp,%rax,4), %ecx
addl %ecx, (%rdi,%rax,4)
incq %rax
jmp 0x8970
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ataradov[P]edbg/utils.c
// Function: crc32
uint32_t crc32(uint8_t *data, int size)
{
  uint32_t crc = 0xffffffff;

  for (int i = 0; i < size; i++)
    crc = crc32_tab[(crc ^ data[i]) & 0xff] ^ (crc >> 8);

  return crc;
}

// Assembly:
xorl %ecx, %ecx
testl %esi, %esi
cmovlel %ecx, %esi
pushq $-0x1
popq %rax
leaq 0x89eb(%rip), %rdx      # 0x11390
cmpq %rcx, %rsi
je 0x89c1
movb (%rdi,%rcx), %r8b
xorb %al, %r8b
movzbl %r8b, %r8d
shrl $0x8, %eax
xorl (%rdx,%r8,4), %eax
incq %rcx
jmp 0x89a5
retq
nop