LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: proc_reg_compute_T
void
proc_reg_compute_T(void)
{
	int i, j, k, l, m;
	double t;
	l = 0;
	for (i = 0; i < ncol; i++) {
		if (Z[i])
			continue;
		m = 0;
		for (j = 0; j < ncol; j++) {
			if (Z[j])
				continue;
			t = 0;
			for (k = 0; k < nrow; k++)
				t += X(k, i) * X(k, j);
			T(l, m) = t;
			m++;
		}
		l++;
	}
}

// Assembly:
movslq 0xae39(%rip), %rax      # 0x14af0
testq %rax, %rax
jle 0x9d79
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0xbecc(%rip), %rcx      # 0x15ba0
movl 0xbaf6(%rip), %edx      # 0x157d0
leaq (,%rax,8), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpl $0x0, (%rcx,%r8,4)
jne 0x9d5f
movl %eax, %r10d
imull %r9d, %r10d
movslq %r10d, %r10
shlq $0x3, %r10
addq 0xadca(%rip), %r10      # 0x14ad0
movq 0xadcb(%rip), %r11      # 0x14ad8
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpl $0x0, (%rcx,%r14,4)
jne 0x9d50
xorpd %xmm0, %xmm0
testl %edx, %edx
jle 0x9d44
movq %rdx, %r12
movq %r11, %r13
movsd (%r13,%rdi), %xmm1
mulsd (%r13,%rbx), %xmm1
addsd %xmm1, %xmm0
addq %rsi, %r13
decq %r12
jne 0x9d2a
movslq %r15d, %r15
movsd %xmm0, (%r10,%r15,8)
incl %r15d
incq %r14
addq $0x8, %rbx
cmpq %rax, %r14
jne 0x9d15
incl %r9d
incq %r8
addq $0x8, %rdi
cmpq %rax, %r8
jne 0x9cea
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: proc_reg_compute_B
void
proc_reg_compute_B(void)
{
	int i, j, l;
	double t;

	l = 0;

	for (i = 0; i < ncol; i++) {
		if (Z[i])
			continue;
		t = 0;
		for (j = 0; j < nrow; j++)
			t += X(j, i) * Y[j];
		T(0, l++) = t;
	}

	for (i = 0; i < npar; i++) {
		t = 0;
		for (j = 0; j < npar; j++)
			t += G(i, j) * T(0, j);
		B[i] = t;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movslq 0xa9c8(%rip), %rax      # 0x14af0
testq %rax, %rax
jle 0xa1a3
movq 0xba6c(%rip), %rcx      # 0x15ba0
movl 0xb696(%rip), %edx      # 0x157d0
movq 0xa997(%rip), %rsi      # 0x14ad8
movq 0xa998(%rip), %rdi      # 0x14ae0
movq 0xa981(%rip), %r8       # 0x14ad0
leaq (,%rax,8), %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpl $0x0, (%rcx,%r10,4)
jne 0xa197
xorpd %xmm0, %xmm0
testl %edx, %edx
jle 0xa18b
movq %rsi, %rbx
xorl %r14d, %r14d
movsd (%rbx), %xmm1
mulsd (%rdi,%r14,8), %xmm1
addsd %xmm1, %xmm0
incq %r14
addq %r9, %rbx
cmpq %r14, %rdx
jne 0xa172
movslq %r11d, %rbx
incl %r11d
movsd %xmm0, (%r8,%rbx,8)
incq %r10
addq $0x8, %rsi
cmpq %rax, %r10
jne 0xa15d
movslq 0xa89e(%rip), %rcx      # 0x14a48
testq %rcx, %rcx
jle 0xa1fb
movq 0xa912(%rip), %rdx      # 0x14ac8
movq 0xa913(%rip), %rsi      # 0x14ad0
movq 0xa8fc(%rip), %rdi      # 0x14ac0
shlq $0x3, %rax
xorl %r8d, %r8d
xorpd %xmm0, %xmm0
xorl %r9d, %r9d
movsd (%rdx,%r9,8), %xmm1
mulsd (%rsi,%r9,8), %xmm1
addsd %xmm1, %xmm0
incq %r9
cmpq %r9, %rcx
jne 0xa1d2
movsd %xmm0, (%rdi,%r8,8)
incq %r8
addq %rax, %rdx
cmpq %rcx, %r8
jne 0xa1cb
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: proc_reg_compute_Yhat
void
proc_reg_compute_Yhat(void)
{
	int i, j, k;
	double yhat;
	for (i = 0; i < nrow; i++) {
		yhat = 0;
		k = 0;
		for (j = 0; j < ncol; j++)
			if (Z[j] == 0) // if not zapped
				yhat += X(i, j) * B[k++];
		Yhat[i] = yhat;
	}
}

// Assembly:
movslq 0xb5c9(%rip), %rax      # 0x157d0
testq %rax, %rax
jle 0xa29a
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
movl 0xa8d1(%rip), %ecx      # 0x14af0
movq 0xb97a(%rip), %rdx      # 0x15ba0
movq 0xa8bb(%rip), %rsi      # 0x14ae8
leaq (,%rcx,8), %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
testl %ecx, %ecx
jle 0xa27f
movq 0xa87a(%rip), %r10      # 0x14ac0
movq 0xa88b(%rip), %r11      # 0x14ad8
addq %r8, %r11
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
xorl %r14d, %r14d
cmpl $0x0, (%rdx,%rbx,4)
jne 0xa275
movsd (%r11,%rbx,8), %xmm1
movslq %r14d, %r15
incl %r14d
mulsd (%r10,%r15,8), %xmm1
addsd %xmm1, %xmm0
incq %rbx
cmpq %rbx, %rcx
jne 0xa259
jmp 0xa283
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsi,%r9,8)
incq %r9
addq %rdi, %r8
cmpq %rax, %r9
jne 0xa23b
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: proc_reg_compute_PVAL
void
proc_reg_compute_PVAL(void)
{
	int i, n;
	n = nrow - npar;
	for (i = 0; i < npar; i++)
		PVAL[i] = 2 * (1 - tdist(fabs(TVAL[i]), n));
}

// Assembly:
cmpl $0x0, 0xa4ea(%rip)      # 0x14a48
jle 0xa5cc
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl 0xb264(%rip), %eax      # 0x157d0
subl 0xa4d6(%rip), %eax      # 0x14a48
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x10(%rbp)
xorl %ebx, %ebx
movq 0xb62c(%rip), %rax      # 0x15bb0
movsd (%rax,%rbx,8), %xmm0
andpd 0xd3f(%rip), %xmm0      # 0xb2d0
movsd -0x10(%rbp), %xmm1
callq 0x7bf4
movsd 0xd55(%rip), %xmm1      # 0xb2f8
subsd %xmm0, %xmm1
addsd %xmm1, %xmm1
movq 0xb606(%rip), %rax      # 0x15bb8
movsd %xmm1, (%rax,%rbx,8)
incq %rbx
movslq 0xa487(%rip), %rax      # 0x14a48
cmpq %rax, %rbx
jl 0xa57d
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: proc_step
void
proc_step(void)
{
	nby = 0;
	nvar = 0;
	nstats = 0;
	nclass = 0;

	maxdec = 3;
	alpha = 0.05;

	select_dataset(NULL);

	scan(); // get token after PROC

	keyword();

	switch (token) {
	case KANOVA:
		proc_anova();
		break;
	case KMEANS:
		proc_means();
		break;
	case KPRINT:
		proc_print();
		break;
	case KREG:
		proc_reg();
		break;
	default:
		expected("procedure name");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movl %eax, 0x9aa7(%rip)      # 0x14080
movl %eax, 0x9de1(%rip)      # 0x143c0
movl %eax, 0xb1ab(%rip)      # 0x15790
movl %eax, 0x9c35(%rip)      # 0x14220
movl $0x3, 0x98eb(%rip)      # 0x13ee0
movabsq $0x3fa999999999999a, %rax # imm = 0x3FA999999999999A
movq %rax, 0x98d2(%rip)      # 0x13ed8
movq 0x5a73(%rip), %rax      # 0x10080
movq %rax, 0x98b4(%rip)      # 0x13ec8
callq 0x2b84
callq 0x2593
movl 0x5270(%rip), %eax      # 0xf894
cmpl $0x145, %eax            # imm = 0x145
jg 0xa63f
cmpl $0x12e, %eax            # imm = 0x12E
je 0xa653
cmpl $0x141, %eax            # imm = 0x141
jne 0xa65f
popq %rbp
jmp 0x7d40
cmpl $0x146, %eax            # imm = 0x146
je 0xa659
cmpl $0x149, %eax            # imm = 0x149
jne 0xa65f
popq %rbp
jmp 0x8c7b
popq %rbp
jmp 0x4af1
popq %rbp
jmp 0x88ad
leaq 0x1454(%rip), %rdi      # 0xbaba
callq 0x25f2
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: run_nib
void
run_nib(char *s)
{
	if (setjmp(jmpbuf))
		return;

	pgm = s;

	inp = s;

	scan();

	for (;;) {
		keyword();
		switch (token) {
		case 0:
			return;
		case KDATA:
			data_step();
			break;
		case KPROC:
			proc_step();
			break;
		case KRUN:
			scan();
			if (token != ';')
				stop("';' expected");
			scan();
			break;
		default:
			parse_default();
			break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xb565(%rip), %rdi      # 0x15be0
callq 0x2150
testl %eax, %eax
je 0xa68b
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, 0xb616(%rip)      # 0x15ca8
movq %rbx, 0x51ff(%rip)      # 0xf898
callq 0x2b84
xorl %ebx, %ebx
callq 0x2593
movl 0x51e9(%rip), %eax      # 0xf894
cmpl $0x146, %eax            # imm = 0x146
jle 0xa6d5
cmpl $0x147, %eax            # imm = 0x147
je 0xa70f
cmpl $0x14a, %eax            # imm = 0x14A
jne 0xa71e
callq 0x2b84
cmpl $0x3b, 0x51c8(%rip)     # 0xf894
jne 0xa728
callq 0x2b84
jmp 0xa6a0
cmpl $0x135, %eax            # imm = 0x135
jne 0xa716
movl %ebx, 0x4d4e(%rip)      # 0xf430
movl $0x1, 0x4d48(%rip)      # 0xf434
movl %ebx, 0x4d46(%rip)      # 0xf438
movb $0x0, 0x4d47(%rip)      # 0xf440
movl $0x2c2009, 0x512d(%rip) # imm = 0x2C2009
callq 0x2374
callq 0x2403
jmp 0xa6a0
callq 0xa5cd
jmp 0xa6a0
testl %eax, %eax
je 0xa684
callq 0x2ac5
jmp 0xa6a0
callq 0xa74a
leaq 0xdd0(%rip), %rdi       # 0xb504
callq 0x4081
leaq 0xb4a0(%rip), %rdi      # 0x15be0
movl $0x1, %esi
callq 0x21b0
// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]sassafras/sassafras.c
// Function: print_pgm
void
print_pgm(void)
{
	char c, *s, *t;

	s = pgm;

	for (;;) {

		while (*s && s != inp && (*s == '\n' || *s == '\r'))
			s++;

		if (*s == 0 || s == inp)
			break;

		t = s;

		while (*s && s != inp && *s != '\n' && *s != '\r')
			s++;

		c = *s;
		*s = 0;
		emit_line(t);
		*s = c;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0xb54d(%rip), %r15      # 0x15ca8
movq 0x5136(%rip), %rax      # 0xf898
movb (%r15), %r14b
testb %r14b, %r14b
sete %dl
cmpq %rax, %r15
sete %cl
orb %dl, %cl
je 0xa780
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x2401, %ebx           # imm = 0x2401
incq %r15
movq %r15, %rdi
cmpb $0xd, %r14b
je 0xa79a
movzbl %r14b, %edx
cmpl $0xa, %edx
jne 0xa7b4
movb (%rdi), %r14b
testb %r14b, %r14b
sete %dl
cmpq %rax, %rdi
sete %cl
orb %dl, %cl
incq %rdi
testb %cl, %cl
je 0xa78b
jmp 0xa775
testb $0x1, %cl
jne 0xa775
decq %rdi
movb (%rdi), %r14b
movq %rdi, %r15
cmpq %rax, %rdi
je 0xa7e5
cmpb $0xd, %r14b
ja 0xa7d6
movzbl %r14b, %ecx
btl %ecx, %ebx
jb 0xa7e5
movb 0x1(%r15), %r14b
incq %r15
cmpq %rax, %r15
jne 0xa7c7
movq %rax, %r15
movb $0x0, (%r15)
callq 0x2070
movb %r14b, (%r15)
movq 0x50a0(%rip), %rax      # 0xf898
testb %r14b, %r14b
sete %dl
cmpq %rax, %r15
sete %cl
orb %dl, %cl
cmpb $0x1, %cl
jne 0xa785
jmp 0xa775
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/./permutation.h
// Function: rng_init
static inline void rng_init(unsigned thread_num) {
  rng_buf = (char *)calloc(1, RNG_BUF_SIZE);
  rand_state = (struct random_data *)calloc(1, sizeof(struct random_data));
  assert(rand_state);
  if (initstate_r(thread_num, rng_buf, RNG_BUF_SIZE, rand_state) != 0) {
    perror("initstate_r");
    exit(1);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x1, %edi
movl $0x20, %esi
callq 0x436970
movq %rax, %r14
movq $-0x60, %rax
movq %r14, %fs:(%rax)
movl $0x1, %edi
movl $0x30, %esi
callq 0x436970
movq $-0x58, %rcx
movq %rax, %fs:(%rcx)
testq %rax, %rax
je 0x402ecd
movl $0x20, %edx
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rcx
callq 0x412700
testl %eax, %eax
jne 0x402eec
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd009d(%rip), %rdi     # 0x4d2f71
leaq 0xd00a1(%rip), %rsi     # 0x4d2f7c
leaq 0xd00aa(%rip), %rcx     # 0x4d2f8c
movl $0x5d, %edx
callq 0x40bc10
callq 0x401140
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/multichase.c
// Function: chase_incr
static void chase_incr(per_thread_t *t) {
  struct incr_struct *p = t->x.cycle[0];

  do {
    x50(++p->incme; p = *(void **)p;)
  } while (__sync_add_and_fetch(&t->x.count, 50));

  // we never actually reach here, but the compiler doesn't know that
  t->x.cycle[0] = p;
}

// Assembly:
movq 0x8(%rdi), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
incl 0x8(%rax)
movq (%rax), %rax
lock
subl $-0x32, 0x4(%rdi)
jne 0x40374c
movq %rax, 0x8(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/multichase.c
// Function: chase_branch
static void chase_branch(per_thread_t *t) {
  void *p = t->x.cycle[0];
  typedef void* (*fptr)(void);
  fptr fp = p;

  do {
    fp = (fptr)(fp)();
  } while (__sync_add_and_fetch(&t->x.count, t->x.branch_chunk_size));

  // we never actually reach here, but the compiler doesn't know that
  t->x.dummy = (uintptr_t)p;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r14
leaq 0x4(%rdi), %r15
movq %r14, %rax
callq *%rax
movl 0x94(%rbx), %ecx
lock
addl %ecx, (%r15)
jne 0x40389b
movl %r14d, 0x60(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/permutation.c
// Function: gen_random_permutation
void gen_random_permutation(perm_t *perm, size_t nr, size_t base) {
  size_t i;

  for (i = 0; i < nr; ++i) {
    size_t t = rng_int(i);
    perm[i] = perm[t];
    perm[t] = base + i;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x407b94
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
negq %r14
movl $0x1, %r13d
leaq 0xc(%rsp), %rbp
leaq 0x8(%rsp), %r12
movq %fs:-0x58, %rdi
leaq 0x14(%rsp), %rsi
callq 0x4129a0
testl %eax, %eax
jne 0x407ba3
movq %fs:-0x58, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4129a0
testl %eax, %eax
jne 0x407ba3
movq %fs:-0x58, %rdi
movq %rbp, %rsi
callq 0x4129a0
testl %eax, %eax
jne 0x407ba3
movq %fs:-0x58, %rdi
movq %r12, %rsi
callq 0x4129a0
testl %eax, %eax
jne 0x407ba3
movzwl 0x14(%rsp), %eax
movl 0x10(%rsp), %ecx
shll $0x10, %ecx
orq %rax, %rcx
movl 0xc(%rsp), %eax
movzwl %ax, %edx
shlq $0x20, %rdx
orq %rcx, %rdx
movl 0x8(%rsp), %eax
shlq $0x30, %rax
orq %rdx, %rax
xorl %edx, %edx
divq %r13
movq (%r15,%rdx,8), %rax
movq %rax, -0x8(%r15,%r13,8)
movq %rbx, (%r15,%rdx,8)
incq %rbx
leaq (%r14,%r13), %rax
incq %rax
incq %r13
cmpq $0x1, %rax
jne 0x407ae3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4011b9
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/permutation.c
// Function: is_a_permutation
int is_a_permutation(const perm_t *perm, size_t nr_elts) {
  uint8_t *vec;
  size_t vec_len = (nr_elts + 7) / 8;
  size_t i;

  vec = malloc(vec_len);
  memset(vec, 0, vec_len);

  for (i = 0; i < nr_elts; ++i) {
    size_t vec_elt = perm[i] / 8;
    size_t test_bit = 1u << (perm[i] % 8);
    if (vec[vec_elt] & test_bit) {
      free(vec);
      return 0;
    }
    vec[vec_elt] |= test_bit;
  }
  for (i = 0; i < nr_elts / 8; ++i) {
    if (vec[i] != 0xff) {
      free(vec);
      return 0;
    }
  }
  if (nr_elts % 8) {
    if (vec[vec_len - 1] != ((1u << (nr_elts % 8)) - 1)) {
      free(vec);
      return 0;
    }
  }
  free(vec);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r12
leaq 0x7(%rsi), %r14
shrq $0x3, %r14
movq %r14, %rdi
callq 0x435520
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq %r14, (%rsp)
movq %r14, %rdx
callq 0x4010a8
testq %r15, %r15
je 0x407c41
xorl %r13d, %r13d
movq (%r12,%r13,8), %rdx
movq %rdx, %rax
movl %edx, %ecx
andb $0x7, %cl
movl $0x1, %ebp
shll %cl, %ebp
shrq $0x3, %rax
movzbl (%rbx,%rax), %r14d
andl $0x7, %edx
btl %edx, %r14d
jae 0x407c2c
movq %rbx, %rdi
callq 0x435860
jmp 0x407c34
movl %r14d, %ecx
orl %ebp, %ecx
movb %cl, (%rbx,%rax)
testl %r14d, %ebp
jne 0x407c94
incq %r13
cmpq %r13, %r15
jne 0x407bfd
cmpq $0x8, %r15
jb 0x407c61
movq %r15, %rax
shrq $0x3, %rax
xorl %r12d, %r12d
xorl %ecx, %ecx
cmpb $-0x1, (%rbx,%rcx)
jne 0x407c8a
incq %rcx
cmpq %rcx, %rax
jne 0x407c53
andq $0x7, %r15
je 0x407c84
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r15d, %ecx
shll %cl, %eax
movq (%rsp), %rcx
movzbl -0x1(%rbx,%rcx), %ecx
xorl %ecx, %eax
xorl %r12d, %r12d
cmpl $-0x1, %eax
jne 0x407c8a
movl $0x1, %r12d
movq %rbx, %rdi
callq 0x435860
jmp 0x407c97
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/permutation.c
// Function: generate_chase_mixer
void generate_chase_mixer(struct generate_chase_common_args *args,
                          size_t nr_mixers) {
  size_t nr_mixer_indices = args->nr_mixer_indices;
  void (*gen_permutation)(perm_t *, size_t, size_t) = args->gen_permutation;

  /* Set number of mixers rounded up to the power of two */
  if (nr_mixers > 1) {
    args->nr_mixers = 1 << (CHAR_BIT * sizeof(long) -
                            __builtin_clzl(nr_mixers - 1));
  } else {
    args->nr_mixers = 1;
  }

  if (args->nr_mixers < 64) {
    args->nr_mixers = 64;
  }

  if (verbosity > 1)
    printf("nr_mixers = %zu\n", args->nr_mixers);
  perm_t *t = malloc(nr_mixer_indices * sizeof(*t));
  if (t == NULL) {
    fprintf(stderr, "Could not allocate %lu bytes, check stride/memory size?\n",
            nr_mixer_indices * sizeof(*t));
    exit(1);
  }
  perm_t *r = malloc(nr_mixer_indices * args->nr_mixers * sizeof(*r));
  if (r == NULL) {
    fprintf(stderr, "Could not allocate %lu bytes, check stride/memory size?\n",
            nr_mixer_indices * args->nr_mixers * sizeof(*r));
    exit(1);
  }
  size_t i;
  size_t j;

  // we arrange r in a transposed manner so that all of the
  // data for a particular mixer_idx is packed together.
  for (i = 0; i < args->nr_mixers; ++i) {
    gen_permutation(t, nr_mixer_indices, 0);
    for (j = 0; j < nr_mixer_indices; ++j) {
      r[j * args->nr_mixers + i] = t[j];
    }
  }
  free(t);

  args->mixer = r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x1, %eax
cmpq $0x2, %rsi
jb 0x407cd7
decq %rsi
bsrq %rsi, %rcx
xorl $0x3f, %ecx
negb %cl
movl $0x1, %eax
shll %cl, %eax
cltq
movq 0x28(%rbx), %rbp
movq 0x30(%rbx), %r14
movq %rax, 0x20(%rbx)
cmpq $0x3f, %rax
ja 0x407cf1
movq $0x40, 0x20(%rbx)
movq $0x50b310, %rax         # imm = 0x50B310
cmpl $0x2, (%rax)
jl 0x407d0f
movq 0x20(%rbx), %rsi
leaq 0xcb346(%rip), %rdi     # 0x4d304e
xorl %eax, %eax
callq 0x413340
leaq (,%r14,8), %r12
movq %r12, %rdi
callq 0x435520
testq %rax, %rax
je 0x407db0
movq %rax, %r15
movq 0x20(%rbx), %r13
imulq %r14, %r13
shlq $0x3, %r13
movq %r13, %rdi
callq 0x435520
movq %rax, (%rsp)
testq %rax, %rax
je 0x407db8
cmpq $0x0, 0x20(%rbx)
je 0x407d91
xorl %r13d, %r13d
movq (%rsp), %r12
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq *%rbp
testq %r14, %r14
je 0x407d84
movq 0x20(%rbx), %rax
shlq $0x3, %rax
movq %r12, %rcx
xorl %edx, %edx
movq (%r15,%rdx,8), %rsi
movq %rsi, (%rcx)
incq %rdx
addq %rax, %rcx
cmpq %rdx, %r14
jne 0x407d72
incq %r13
addq $0x8, %r12
cmpq 0x20(%rbx), %r13
jb 0x407d56
movq %r15, %rdi
callq 0x435860
movq (%rsp), %rax
movq %rax, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x4011f2
movq %r13, %rdi
callq 0x4011ce
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/arena.c
// Function: print_page_size
void print_page_size(size_t page_size, bool use_thp) {
  FILE *f;
  size_t read;
  /* Big enough to fit UINT64_MAX + '\n' + '\0'. */
  char buf[22];

  if (!use_thp) {
    printf("page_size = %zu bytes\n", page_size);
    return;
  }

  f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r");
  if (!f) goto err;

  read = fread(buf, 1, sizeof(buf) - 1, f);
  if (!feof(f) || (ferror(f) && !feof(f))) goto err;

  if (fclose(f)) goto err;

  if (buf[read - 1] == '\n') --read;
  buf[read] = '\0';

  printf("page_size = %s bytes (THP)\n", buf);
  return;

err:
  perror(
      "page_size = <failed to read "
      "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size>");
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
testl %esi, %esi
je 0x408469
leaq 0xcae65(%rip), %rdi     # 0x4d3243
leaq 0xcabcd(%rip), %rsi     # 0x4d2fb2
callq 0x4220f0
testq %rax, %rax
je 0x408484
movq %rax, %rbx
movq %rsp, %rdi
movl $0x1, %esi
movl $0x15, %edx
movq %rax, %rcx
callq 0x4221f0
movq %rax, %r14
movq %rbx, %rdi
callq 0x4248b0
testl %eax, %eax
je 0x408484
movq %rbx, %rdi
callq 0x424980
testl %eax, %eax
je 0x408432
movq %rbx, %rdi
callq 0x4248b0
testl %eax, %eax
je 0x408484
movq %rbx, %rdi
callq 0x4219c0
testl %eax, %eax
jne 0x408484
cmpb $0xa, -0x1(%rsp,%r14)
leaq -0x1(%r14), %rax
cmovneq %r14, %rax
movb $0x0, (%rsp,%rax)
leaq 0xcae1f(%rip), %rdi     # 0x4d3276
movq %rsp, %rsi
xorl %eax, %eax
callq 0x413340
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq %rdi, %rax
leaq 0xcadb9(%rip), %rdi     # 0x4d322c
movq %rax, %rsi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x413340
leaq 0xcae07(%rip), %rdi     # 0x4d3292
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x413570
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/arena.c
// Function: read_sysfs_state_file
static char *read_sysfs_state_file(char const *path) {
  FILE *f = fopen(path, "r");
  char *token = NULL;
  int ret;

  if (f == NULL) {
    perror("open sysfs state file");
    exit(1);
  }

  while ((ret = fscanf(f, "%ms", &token)) == 1) {
    if (token[0] == '[') break;

    free(token);
    token = NULL;
  }

  if (ferror(f) && !feof(f)) {
    perror("read sysfs state file");
    exit(1);
  }

  if (fclose(f)) {
    perror("close sysfs state file");
    exit(1);
  }

  return token;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0xca733(%rip), %rsi     # 0x4d2fb2
callq 0x4220f0
movq $0x0, 0x8(%rsp)
testq %rax, %rax
je 0x408920
movq %rax, %rbx
leaq 0xcab56(%rip), %rsi     # 0x4d33f6
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x413630
cmpl $0x1, %eax
jne 0x4088ed
leaq 0xcab3b(%rip), %r14     # 0x4d33f6
leaq 0x8(%rsp), %r15
movq 0x8(%rsp), %rdi
cmpb $0x5b, (%rdi)
je 0x4088ed
callq 0x435860
movq $0x0, 0x8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x413630
cmpl $0x1, %eax
je 0x4088c0
movq %rbx, %rdi
callq 0x424980
testl %eax, %eax
je 0x408905
movq %rbx, %rdi
callq 0x4248b0
testl %eax, %eax
je 0x40892a
movq %rbx, %rdi
callq 0x4219c0
testl %eax, %eax
jne 0x408925
movq 0x8(%rsp), %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x401398
callq 0x401383
callq 0x40136e
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/arena.c
// Function: write_sysfs_file
static void write_sysfs_file(char const *path, char const *value) {
  FILE *f = fopen(path, "w");

  if (f == NULL) {
    perror("open sysfs file for write");
    exit(1);
  }

  if (fprintf(f, "%s\n", value) < 0) {
    perror("write value to sysfs file");
    exit(1);
  }

  if (fclose(f)) {
    perror("close sysfs file");
    exit(1);
  }
}

// Assembly:
pushq %rbx
leaq 0xcaaf0(%rip), %rsi     # 0x4d3427
callq 0x4220f0
testq %rax, %rax
je 0x40896e
movq %rax, %rbx
leaq 0xc984f(%rip), %rsi     # 0x4d219a
leaq 0xca995(%rip), %rdx     # 0x4d32e7
movq %rax, %rdi
xorl %eax, %eax
callq 0x413280
testl %eax, %eax
js 0x408973
movq %rbx, %rdi
callq 0x4219c0
testl %eax, %eax
jne 0x408978
popq %rbx
retq
callq 0x4013d7
callq 0x4013c2
callq 0x4013ad
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/br_asm.c
// Function: convert_pointers_to_branches
int convert_pointers_to_branches(void *head, int chunk_size) {
  int remain = cycle_len(head);
  chunk_size = (remain < chunk_size)
                   ? remain
                   : remain / (1 << lround(log2(1.0 * remain / chunk_size)));
  int base_chunk_size = chunk_size;
  int chunks_remaining = remain / chunk_size;
  int chunk_count = 0;
  const int br_code_len = 12;  // len(mov_imm64) + max(len(jmp), len(ret))
  char *p = (char *)head;
  do {
    if (!chunk_count) chunk_count = remain / chunks_remaining;
    char *next = *((char **)p);
    for (int i = 8; i < br_code_len; i++) {
      if (p[i]) {
        fprintf(stderr, "not enough space to convert a pointer to branches\n");
        exit(1);
      }
    }
    p = x64_emit_mov_imm64_rax(p, (intptr_t)next);
    // At end of branch chunk, return with a pointer to the next chunk.
    --remain;
    if (--chunk_count == 0) {
      p = x64_emit_ret(p);
      --chunks_remaining;
    } else {
      p = x64_emit_jmp_to_rax(p);
    }
    p = next;
  } while (p != head);
  return base_chunk_size;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %ebp, %ebp
movq %rdi, %rax
incl %ebp
movq (%rax), %rax
cmpq %rbx, %rax
jne 0x40898b
movl %ebp, %r8d
cmpl %esi, %ebp
jl 0x4089ba
cvtsi2sd %ebp, %xmm0
cvtsi2sd %esi, %xmm1
divsd %xmm1, %xmm0
callq 0x408ac0
callq 0x408dc0
movl %ebp, %r8d
movl %eax, %ecx
shrl %cl, %r8d
movl %ebp, %eax
cltd
idivl %r8d
movl %eax, %edi
xorl %eax, %eax
movq %rbx, %rsi
testl %eax, %eax
jne 0x4089d0
movl %ebp, %eax
cltd
idivl %edi
movq (%rsi), %rdx
movl $0x8, %ecx
cmpb $0x0, (%rsi,%rcx)
jne 0x408a2c
incq %rcx
cmpq $0xc, %rcx
jne 0x4089d8
movw $0xb848, (%rsi)         # imm = 0xB848
addq $0x2, %rsi
xorl %ecx, %ecx
movq %rdx, %r9
shrq %cl, %r9
movb %r9b, (%rsi)
incq %rsi
addq $0x8, %rcx
cmpq $0x40, %rcx
jne 0x4089f2
decl %eax
je 0x408a13
movw $0xe0ff, (%rsi)         # imm = 0xE0FF
jmp 0x408a18
movb $-0x3d, (%rsi)
decl %edi
decl %ebp
movq %rdx, %rsi
cmpq %rbx, %rdx
jne 0x4089c7
movl %r8d, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x4013ec
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/util.c
// Function: parse_mem_arg
int parse_mem_arg(const char *str, size_t *result) {
  size_t r;
  char *p;

  r = strtoull(str, &p, 0);
  switch (*p) {
    case 'k':
    case 'K':
      r *= 1024;
      ++p;
      break;
    case 'm':
    case 'M':
      r *= 1024 * 1024;
      ++p;
      break;
    case 'g':
    case 'G':
      r *= 1024 * 1024 * 1024;
      ++p;
      break;
  }
  if (*p) {
    return -1;
  }
  *result = r;
  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rsp, %r14
movq %r14, %rsi
xorl %edx, %edx
callq 0x412a60
movq (%r14), %rcx
movzbl (%rcx), %edx
addl $-0x47, %edx
cmpl $0x26, %edx
ja 0x408a9d
movabsq $0x100000001, %rsi      # imm = 0x100000001
btq %rdx, %rsi
jb 0x408a92
movabsq $0x1000000010, %rsi     # imm = 0x1000000010
btq %rdx, %rsi
jb 0x408a8c
movabsq $0x4000000040, %rsi     # imm = 0x4000000040
btq %rdx, %rsi
jae 0x408a9d
shlq $0x14, %rax
jmp 0x408a96
shlq $0xa, %rax
jmp 0x408a96
shlq $0x1e, %rax
incq %rcx
movq %rcx, (%rsp)
movq (%rsp), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpb $0x0, (%rdx)
jne 0x408ab0
movq %rax, (%rbx)
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: chacha_keysetup
void chacha_keysetup(chacha_ctx_t *x, const unsigned char *k, unsigned kbits)
{
  const char *constants;

  x->input[4] = read32le((uint32_t *)(k + 0));
  x->input[5] = read32le((uint32_t *)(k + 4));
  x->input[6] = read32le((uint32_t *)(k + 8));
  x->input[7] = read32le((uint32_t *)(k + 12));
  if (kbits == 256) { /* recommended */
    k += 16;
    constants = sigma;
  } else { /* kbits == 128 */
    constants = tau;
  }
  x->input[8] = read32le((uint32_t *)(k + 0));
  x->input[9] = read32le((uint32_t *)(k + 4));
  x->input[10] = read32le((uint32_t *)(k + 8));
  x->input[11] = read32le((uint32_t *)(k + 12));
  x->input[0] = read32le((uint32_t *)(constants + 0));
  x->input[1] = read32le((uint32_t *)(constants + 4));
  x->input[2] = read32le((uint32_t *)(constants + 8));
  x->input[3] = read32le((uint32_t *)(constants + 12));
}

// Assembly:
movl (%rsi), %eax
movl %eax, 0x10(%rdi)
movl 0x4(%rsi), %eax
movl %eax, 0x14(%rdi)
movl 0x8(%rsi), %eax
movl %eax, 0x18(%rdi)
movl 0xc(%rsi), %eax
movl %eax, 0x1c(%rdi)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x100, %edx            # imm = 0x100
setne %al
sete %cl
movl %ecx, %edx
shll $0x4, %edx
movl (%rsi,%rdx), %r8d
movl %r8d, 0x20(%rdi)
movl 0x4(%rsi,%rdx), %r8d
movl %r8d, 0x24(%rdi)
movl 0x8(%rsi,%rdx), %r8d
movl %r8d, 0x28(%rdi)
movl 0xc(%rsi,%rdx), %edx
movl %edx, 0x2c(%rdi)
movl $0x61707865, (%rdi)     # imm = 0x61707865
shll $0x19, %ecx
orl $0x3120646e, %ecx       # imm = 0x3120646E
movl %ecx, 0x4(%rdi)
leal 0x79622d32(,%rax,4), %eax
movl %eax, 0x8(%rdi)
movl $0x6b206574, 0xc(%rdi)  # imm = 0x6B206574
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: chacha_ivsetup
void chacha_ivsetup(chacha_ctx_t *x,const unsigned char *iv)
{
  x->input[12] = 0;
  x->input[13] = read32le((uint32_t *)(iv + 0)); /* Modified for 12-byte iv */
  x->input[14] = read32le((uint32_t *)(iv + 4));
  x->input[15] = read32le((uint32_t *)(iv + 8));
}

// Assembly:
movl $0x0, 0x30(%rdi)
movl (%rsi), %eax
movl %eax, 0x34(%rdi)
movl 0x4(%rsi), %eax
movl %eax, 0x38(%rdi)
movl 0x8(%rsi), %eax
movl %eax, 0x3c(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: chacha
void chacha(chacha_ctx_t *x,unsigned char *out,unsigned bytes)
{
  unsigned char output[64];
  unsigned i;

  if (!bytes) return;
  for (;;) {
    salsa20_wordtobyte(output,x->input);
    x->input[12] += 1;
    if (bytes <= 64) {
      for (i = 0;i < bytes;++i) out[i] = output[i];
      return;
    }
    for (i = 0;i < 64;++i) out[i] = output[i];
    bytes -= 64;
    out += 64;
  }
}

// Assembly:
testl %edx, %edx
je 0x13fe
subq $0x88, %rsp
movl %edx, %eax
vmovups (%rdi), %ymm0
vmovups 0x20(%rdi), %ymm1
vmovups %ymm0, (%rsp)
vmovups %ymm1, 0x20(%rsp)
vmovdqa (%rsp), %xmm2
vmovdqa 0x10(%rsp), %xmm1
vmovdqa 0x20(%rsp), %xmm3
vmovdqa 0x30(%rsp), %xmm0
movl $0xfffffff4, %ecx       # imm = 0xFFFFFFF4
vpaddd %xmm1, %xmm2, %xmm2
vpxor %xmm2, %xmm0, %xmm0
vprold $0x10, %xmm0, %xmm0
vpaddd %xmm3, %xmm0, %xmm3
vpxor %xmm1, %xmm3, %xmm1
vprold $0xc, %xmm1, %xmm1
vpaddd %xmm2, %xmm1, %xmm2
vpxor %xmm0, %xmm2, %xmm0
vprold $0x8, %xmm0, %xmm0
vpaddd %xmm3, %xmm0, %xmm3
vpxor %xmm1, %xmm3, %xmm1
vpshufd $0x4e, %xmm1, %xmm1     # xmm1 = xmm1[2,3,0,1]
vprold $0x7, %xmm1, %xmm1
vpshufd $0x39, %xmm2, %xmm2     # xmm2 = xmm2[1,2,3,0]
vpaddd %xmm1, %xmm2, %xmm2
vpxor %xmm2, %xmm0, %xmm0
vprold $0x10, %xmm0, %xmm0
vpshufd $0x93, %xmm3, %xmm3     # xmm3 = xmm3[3,0,1,2]
vpaddd %xmm3, %xmm0, %xmm3
vpxor %xmm1, %xmm3, %xmm1
vprold $0xc, %xmm1, %xmm1
vpaddd %xmm2, %xmm1, %xmm2
vpxor %xmm0, %xmm2, %xmm0
vprold $0x8, %xmm0, %xmm0
vpaddd %xmm3, %xmm0, %xmm3
vpxor %xmm1, %xmm3, %xmm1
vpshufd $0x93, %xmm2, %xmm2     # xmm2 = xmm2[3,0,1,2]
vpshufd $0x4e, %xmm1, %xmm1     # xmm1 = xmm1[2,3,0,1]
vprold $0x7, %xmm1, %xmm1
vpshufd $0x39, %xmm3, %xmm3     # xmm3 = xmm3[1,2,3,0]
addl $0x2, %ecx
jne 0x12b7
vmovdqa %xmm1, 0x10(%rsp)
vmovdqa %xmm2, (%rsp)
vmovdqa %xmm0, 0x30(%rsp)
vmovdqa %xmm3, 0x20(%rsp)
xorl %ecx, %ecx
vmovdqu (%rsp,%rcx,4), %ymm0
vpaddd (%rdi,%rcx,4), %ymm0, %ymm0
vmovdqu %ymm0, (%rsp,%rcx,4)
addq $0x8, %rcx
cmpq $0x10, %rcx
jne 0x136f
vmovups (%rsp), %ymm0
vmovups 0x20(%rsp), %ymm1
vmovups %ymm1, 0x60(%rsp)
vmovups %ymm0, 0x40(%rsp)
incl 0x30(%rdi)
cmpl $0x41, %eax
jb 0x13c8
vmovdqu 0x40(%rsp), %ymm0
vmovdqu 0x60(%rsp), %ymm1
vmovdqu %ymm1, 0x20(%rsi)
vmovdqu %ymm0, (%rsi)
addl $-0x40, %eax
addq $0x40, %rsi
jmp 0x1287
testl %eax, %eax
je 0x13f7
xorl %eax, %eax
movl %edx, %ecx
subl $0x40, %ecx
cmovbl %eax, %ecx
addl $0x3f, %ecx
andl $-0x40, %ecx
subl %ecx, %edx
cmpl $0x1, %edx
adcl $0x0, %edx
leaq 0x40(%rsp), %rax
movq %rsi, %rdi
movq %rax, %rsi
vzeroupper
callq 0x1100
addq $0x88, %rsp
vzeroupper
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: hs1siv_chacha256
void hs1siv_chacha256(void *out, unsigned outbytes,
                      unsigned char *iv, void *user_key)
{
    chacha_ctx_t ctx;

    chacha_keysetup(&ctx, user_key, 256);
    chacha_ivsetup(&ctx,iv);
    chacha(&ctx,out,outbytes);
}

// Assembly:
subq $0x48, %rsp
vmovups (%rcx), %ymm0
movq %rsp, %rax
vmovups %ymm0, 0x10(%rax)
vmovaps 0xbe6(%rip), %xmm0      # 0x2000
vmovaps %xmm0, (%rax)
movl %esi, %ecx
movq %rdi, %rsi
movl $0x0, 0x30(%rax)
movq (%rdx), %rdi
movq %rdi, 0x34(%rax)
movl 0x8(%rdx), %edx
movl %edx, 0x3c(%rax)
movq %rax, %rdi
movl %ecx, %edx
vzeroupper
callq 0x10d0
addq $0x48, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: hs1_hash
void hs1_hash(hs1siv_ctx_t *ctx, void *in, unsigned inbytes, void *out) {
    uint64_t *h = (uint64_t *)out;
    unsigned k = (HS1_SIV_HASH_RNDS > 4 ? 1 : 2);

    prf_hash2(h, (uint32_t *)in, inbytes, (uint32_t *)ctx->nh_key,
              (uint64_t *)ctx->poly_key, (uint64_t *)ctx->asu_key);
    #if HS1_SIV_HASH_RNDS > 2
    prf_hash2(h+k, (uint32_t *)in, inbytes, (uint32_t *)ctx->nh_key+8,
              (uint64_t *)ctx->poly_key+2, (uint64_t *)ctx->asu_key+3);
    #if HS1_SIV_HASH_RNDS > 4
    prf_hash2(h+2*k, (uint32_t *)in, inbytes, (uint32_t *)ctx->nh_key+16,
              (uint64_t *)ctx->poly_key+4, (uint64_t *)ctx->asu_key+6);
    #if HS1_SIV_HASH_RNDS > 6
    prf_hash2(h+3*k, (uint32_t *)in, inbytes, (uint32_t *)ctx->nh_key+24,
              (uint64_t *)ctx->poly_key+6, (uint64_t *)ctx->asu_key+9);
    #endif
    #endif
    #endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x20(%rdi), %rcx
leaq 0x90(%rdi), %r8
movq %rbx, %rdi
callq 0x1030
addq $0x10, %rbx
leaq 0x40(%r15), %rcx
addq $0xa0, %r15
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r15, %r8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: hs1siv_subkeygen
void hs1siv_subkeygen(hs1siv_ctx_t *ctx, void *user_key, unsigned key_bytes)
{
    unsigned char chacha_key[32];
    unsigned char iv[12];
    unsigned i=0;

    /* Copy user_key as many times as needed to fill 32 byte chacha key */
    while (i < 32) {
        unsigned nbytes = 32-i;
        if (nbytes > key_bytes) nbytes = key_bytes;
        memcpy(chacha_key+i,user_key,nbytes);
        i += nbytes;
    }

    /* Build key-derivation nonce and fill context */
    memset(iv,0,12);
    iv[0] = key_bytes;
    iv[2] = HS1_SIV_SIV_LEN;
    iv[4] = HS1_SIV_CHACHA_RNDS;
    iv[5] = HS1_SIV_HASH_RNDS;
    iv[6] = HS1_SIV_NH_LEN;
    hs1siv_chacha256(ctx, sizeof(hs1siv_ctx_t), iv, chacha_key);

    /* Pre-process internal keys: make future reads little-endian, mod poly */
    for (i=0; i<sizeof(ctx->nh_key)/4; i++)
        ((uint32_t *)ctx->nh_key)[i] = read32le(((uint32_t *)ctx->nh_key)+i);
    for (i=0; i<sizeof(ctx->poly_key)/8; i++)
        ((uint64_t *)ctx->poly_key)[i] = read64le(((uint64_t *)ctx->poly_key)+i)
                                       & m60;
    #if (HS1_SIV_HASH_RNDS > 4)
    for (i=0; i<sizeof(ctx->asu_key)/8; i++)
        ((uint64_t *)ctx->asu_key)[i] = read64le(((uint64_t *)ctx->asu_key)+i);
    #endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %r12d, %r12d
movl $0x20, %r15d
subl %r12d, %r15d
cmpl %ebp, %r15d
cmovael %ebp, %r15d
movl %r12d, %eax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1100
addl %r12d, %r15d
movl %r15d, %r12d
cmpl $0x20, %r15d
jb 0x1908
movq %rsp, %rdx
movq $0x0, (%rdx)
movl $0x0, 0x8(%rdx)
movb %bpl, (%rdx)
movb $0x10, 0x2(%rdx)
movw $0x40c, 0x4(%rdx)       # imm = 0x40C
movb $0x40, 0x6(%rdx)
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movl $0xb0, %esi
callq 0x10a0
vmovupd 0x90(%rbx), %ymm0
vandpd 0x698(%rip){1to4}, %ymm0, %ymm0 # 0x2018
vmovupd %ymm0, 0x90(%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: hs1
void hs1(
    hs1siv_ctx_t *hs1_ctx,
    void *in, unsigned inbytes,
    void *iv,
    void *out, unsigned outbytes
)
{
    #if (HS1_SIV_HASH_RNDS > 4)
    uint64_t h[HS1_SIV_HASH_RNDS/2];
    #else
    uint64_t h[HS1_SIV_HASH_RNDS];
    #endif

    unsigned i;
    unsigned char key[32];
    chacha_ctx_t chacha_ctx;

    hs1_hash(hs1_ctx, in, inbytes, h);
    memcpy(key, hs1_ctx->chacha_key, 32);
    for (i=0; i<sizeof(h)/8;i++) ((uint64_t *)key)[i] ^= h[i];
    chacha_keysetup(&chacha_ctx, key, 256);
    chacha_ivsetup(&chacha_ctx,(unsigned char *)iv);
    chacha(&chacha_ctx, (unsigned char *)out, outbytes);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0xc(%rsp)
movq %r8, %r14
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r13
leaq 0x20(%rdi), %rcx
leaq 0x90(%rdi), %r8
leaq 0x10(%rsp), %rdi
callq 0x1030
leaq 0x20(%rsp), %rbx
leaq 0x40(%r13), %rcx
leaq 0xa0(%r13), %r8
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x1030
vmovups (%r13), %ymm0
vxorps -0x10(%rbx), %ymm0, %ymm0
leaq 0x30(%rsp), %rdi
vmovups %ymm0, 0x10(%rdi)
vmovaps 0x5f8(%rip), %xmm0      # 0x2000
vmovaps %xmm0, (%rdi)
movl $0x0, 0x30(%rdi)
movq (%r15), %rax
movq %rax, 0x34(%rdi)
movl 0x8(%r15), %eax
movl %eax, 0x3c(%rdi)
movq %r14, %rsi
movl 0xc(%rsp), %edx
vzeroupper
callq 0x10d0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: hs1siv_encrypt
void hs1siv_encrypt(hs1siv_ctx_t *ctx, void *m, unsigned mbytes,
                    void *a, unsigned abytes, void *n, void *t, void *c)
{
    unsigned i;
    unsigned abuflen = (abytes+HS1_SIV_NH_LEN-1)/HS1_SIV_NH_LEN*HS1_SIV_NH_LEN;
    unsigned buflen = abuflen + (mbytes+15)/16*16 + 16;
    unsigned char tmp_t[HS1_SIV_SIV_LEN];
    unsigned char *buf = (unsigned char *)malloc(buflen);
    memset(buf, 0, buflen);
    memcpy(buf, a, abytes);
    memcpy(buf+abuflen, m, mbytes);
    write32le((uint32_t *)(buf+buflen-16), abytes);
    write32le((uint32_t *)(buf+buflen-8), mbytes);
    hs1(ctx, buf, buflen, n, tmp_t, HS1_SIV_SIV_LEN);
    free(buf);
    buf = (unsigned char *)malloc(mbytes+64);
    hs1(ctx, tmp_t, HS1_SIV_SIV_LEN, n, buf, mbytes+64);
    for (i=0; i<mbytes; i++)
        buf[64+i] ^= ((unsigned char *)m)[i];
    memcpy(c,buf+64,mbytes);
    memcpy(t,tmp_t,HS1_SIV_SIV_LEN);
    free(buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x18(%rsp)
movl %r8d, %ebx
movq %rcx, 0x8(%rsp)
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x28(%rsp)
leal 0x3f(%rbx), %ebp
andl $-0x40, %ebp
leal 0xf(%r15), %eax
andl $-0x10, %eax
leal (%rax,%rbp), %r13d
addl $0x10, %r13d
movq %r13, %rdi
callq 0x1060
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x1040
movl %ebx, %edx
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x1100
addq %r12, %rbp
movl %r15d, %edx
movq %rdx, 0x8(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x1100
movl %ebx, -0x10(%r12,%r13)
movl %r15d, -0x8(%r12,%r13)
leaq 0x30(%rsp), %r8
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movl %r13d, %edx
movq 0x18(%rsp), %r13
movq %r13, %rcx
movl $0x10, %r9d
callq 0x10f0
movq %r12, %rdi
callq 0x1080
leal 0x40(%r15), %r12d
movq %r12, %rdi
callq 0x1060
movq %rax, %rbx
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
movl $0x10, %edx
movq %r13, %rcx
movq %rax, %r8
movl %r12d, %r9d
callq 0x10f0
movq 0x8(%rsp), %rdx
testl %r15d, %r15d
je 0x1b63
movq %rdx, %rax
negq %rax
movl $0x40, %ecx
movb -0x40(%r14,%rcx), %dil
movl %ecx, %esi
xorb %dil, (%rbx,%rsi)
leaq (%rax,%rcx), %rsi
incq %rsi
incq %rcx
cmpq $0x40, %rsi
jne 0x1b48
movq %rbx, %rsi
addq $0x40, %rsi
movq 0x20(%rsp), %rdi
callq 0x1100
vmovaps 0x30(%rsp), %xmm0
movq 0x28(%rsp), %rax
vmovups %xmm0, (%rax)
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1080
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: hs1siv_decrypt
int hs1siv_decrypt(hs1siv_ctx_t *ctx, void *c, unsigned cbytes,
                   void *a, unsigned abytes, void *n, void *t, void *m)
{
    unsigned i;
    unsigned abuflen = (abytes+HS1_SIV_NH_LEN-1)/HS1_SIV_NH_LEN*HS1_SIV_NH_LEN;
    unsigned buflen = abuflen + (cbytes+15)/16*16 + 16;
    unsigned char *maybe_m = (unsigned char *)malloc(cbytes);
    unsigned char maybe_t[HS1_SIV_SIV_LEN];
    unsigned char *buf = (unsigned char *)malloc(cbytes+64);
    hs1(ctx, t, HS1_SIV_SIV_LEN, n, buf, cbytes+64);
    for (i=0; i<cbytes; i++)
        ((unsigned char *)maybe_m)[i] = ((unsigned char *)c)[i] ^ buf[64+i];
    free(buf);
    buf = (unsigned char *)malloc(buflen);
    memset(buf, 0, buflen);
    memcpy(buf, a, abytes);
    memcpy(buf+abuflen, maybe_m, cbytes);
    write32le((uint32_t *)(buf+buflen-16), abytes);
    write32le((uint32_t *)(buf+buflen-8), cbytes);
    hs1(ctx, buf, buflen, n, maybe_t, HS1_SIV_SIV_LEN);
    free(buf);
    if (memcmp(t,maybe_t,HS1_SIV_SIV_LEN) == 0) {
        memcpy(m,maybe_m,cbytes);
        free(maybe_m);
        return 0;
    } else {
        free(maybe_m);
        return -1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rbp
movq %rcx, 0x28(%rsp)
movl %edx, %r14d
movq %rsi, %r13
movq %rdi, 0x18(%rsp)
movq %r8, 0x30(%rsp)
leal 0x3f(%r8), %ecx
andl $-0x40, %ecx
leal 0xf(%r14), %eax
andl $-0x10, %eax
movq %rcx, 0x20(%rsp)
addl %ecx, %eax
addl $0x10, %eax
movl %eax, 0x14(%rsp)
movl %edx, %edi
movq %rdi, 0x8(%rsp)
callq 0x1060
movq %rax, %rbx
leal 0x40(%r14), %r15d
movq %r15, %rdi
callq 0x1060
movq %rax, %r12
movq 0x18(%rsp), %rdi
movq 0x90(%rsp), %rsi
movl $0x10, %edx
movq %rbp, 0x38(%rsp)
movq %rbp, %rcx
movq %rax, %r8
movl %r15d, %r9d
movq %r14, %rbp
callq 0x10f0
testl %ebp, %ebp
je 0x1c51
movq 0x8(%rsp), %rax
negq %rax
movl $0x40, %ecx
movl %ecx, %edx
movb (%r12,%rdx), %dl
xorb -0x40(%r13,%rcx), %dl
movb %dl, -0x40(%rbx,%rcx)
leaq (%rax,%rcx), %rdx
incq %rdx
incq %rcx
cmpq $0x40, %rdx
jne 0x1c32
movq %r12, %rdi
callq 0x1080
movl 0x14(%rsp), %r15d
movl %r15d, %r12d
movq %r12, %rdi
callq 0x1060
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x1040
movq 0x30(%rsp), %r14
movl %r14d, %edx
movq %r13, %rdi
movq 0x28(%rsp), %rsi
callq 0x1100
movl 0x20(%rsp), %edi
addq %r13, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq 0x1100
movl %r14d, -0x10(%r13,%r12)
movl %ebp, -0x8(%r13,%r12)
leaq 0x40(%rsp), %r14
movq 0x18(%rsp), %rdi
movq %r13, %rsi
movl %r15d, %edx
movq 0x38(%rsp), %rcx
movq %r14, %r8
movl $0x10, %r9d
callq 0x10f0
movq %r13, %rdi
callq 0x1080
movq 0x90(%rsp), %rax
vmovdqu (%rax), %xmm0
vpxor (%r14), %xmm0, %xmm0
vptest %xmm0, %xmm0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jne 0x1d0b
movq 0x98(%rsp), %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
callq 0x1100
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x1080
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: crypto_aead_encrypt
int crypto_aead_encrypt(
    unsigned char *c,unsigned long long *clen,
    const unsigned char *m,unsigned long long mlen,
    const unsigned char *ad,unsigned long long adlen,
    const unsigned char *nsec,
    const unsigned char *npub,
    const unsigned char *k
)
{
    hs1siv_ctx_t ctx;
    (void)nsec;
    hs1siv_subkeygen(&ctx, (void *)k, CRYPTO_KEYBYTES);
    if (clen) *clen = mlen+CRYPTO_ABYTES;
    hs1siv_encrypt(&ctx, (void *)m, mlen, (void *)ad, adlen, (void *)npub,
                   c+mlen, c);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %r15
movq 0x100(%rsp), %rsi
movq %rsp, %rdi
movl $0x10, %edx
callq 0x10c0
testq %r13, %r13
je 0x1d6a
leaq 0x10(%r12), %rax
movq %rax, (%r13)
movq %r12, %rax
addq %r15, %rax
movq %rsp, %rdi
movq %rbp, %rsi
movl %r12d, %edx
movq %r14, %rcx
movl %ebx, %r8d
movq 0xf8(%rsp), %r9
pushq %r15
pushq %rax
callq 0x10e0
addq $0x10, %rsp
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/hs1sivv2/ref/encrypt.c
// Function: crypto_aead_decrypt
int crypto_aead_decrypt(
    unsigned char *m,unsigned long long *mlen,
    unsigned char *nsec,
    const unsigned char *c,unsigned long long clen,
    const unsigned char *ad,unsigned long long adlen,
    const unsigned char *npub,
    const unsigned char *k
)
{
    hs1siv_ctx_t ctx;
    (void)nsec;
    if (mlen) *mlen = clen-CRYPTO_ABYTES;
    hs1siv_subkeygen(&ctx, (void *)k, CRYPTO_KEYBYTES);
    return hs1siv_decrypt(&ctx, (void *)c, clen-CRYPTO_ABYTES,
    	(void *)ad, adlen, (void *)npub, (void *)(c+clen-CRYPTO_ABYTES), m);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, %rbx
movq %r8, %rbp
movq %rcx, %r15
movq %rsi, %rax
movq %rdi, %r14
movq 0x100(%rsp), %rsi
movq 0xf0(%rsp), %r13
testq %rax, %rax
je 0x1de3
leaq -0x10(%rbp), %rcx
movq %rcx, (%rax)
movq %rsp, %r12
movq %r12, %rdi
movl $0x10, %edx
callq 0x10c0
leal -0x10(%rbp), %edx
leaq (%r15,%rbp), %rax
addq $-0x10, %rax
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rcx
movl %r13d, %r8d
movq 0xf8(%rsp), %r9
pushq %r14
pushq %rax
callq 0x1050
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq