// File: /workspace/github_c_makefile_star2_O1/ls4154[P]hash-c/sha1.c
// Function: sha1_iterate
static void _sha1_iterate(struct sha1_ctx *ctx, byte_t *chunk)
{
	word_t w[80];

	for (int i = 0; i < 16; ++i) {
		w[i] = 0;
		for (int j = 0; j < 4; ++j)
			w[i] |= (word_t)*(chunk + 4 * i + j) << 8 * (3 - j);
	}

#ifdef SHA0
	for (int i = 16; i < 80; ++i)
		w[i] = w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16];
#else
	for (int i = 16; i < 80; ++i)
		w[i] = ROL(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
#endif

	word_t a = ctx->h[0];
	word_t b = ctx->h[1];
	word_t c = ctx->h[2];
	word_t d = ctx->h[3];
	word_t e = ctx->h[4];

	for (int i = 0; i < 80; ++i) {
		word_t tmp;
		word_t k;

		switch (i / 20) {
		case 0:
			tmp = (b & c) | ((~b) & d);
			k = 0x5a827999;
			break;
		case 1:
			tmp = b ^ c ^ d;
			k = 0x6ed9eba1;
			break;
		case 2:
			tmp = (b & c) | (b & d) | (c & d);
			k = 0x8f1bbcdc;
			break;
		default :
			tmp = b ^ c ^ d;
			k = 0xca62c1d6;
		}
		tmp += ROL(a, 5) + e + k + w[i];
		e = d;
		d = c;
		c = ROL(b, 30);
		b = a;
		a = tmp;
	}

	ctx->h[0] += a;
	ctx->h[1] += b;
	ctx->h[2] += c;
	ctx->h[3] += d;
	ctx->h[4] += e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
xorl %eax, %eax
movl $0x0, -0x70(%rsp,%rax,4)
movl $0x18, %ecx
xorl %r8d, %r8d
xorl %edx, %edx
movzbl (%rsi,%r8), %r9d
shll %cl, %r9d
orl %r9d, %edx
incq %r8
addl $-0x8, %ecx
cmpq $0x4, %r8
jne 0x1303
movl %edx, -0x70(%rsp,%rax,4)
incq %rax
addq $0x4, %rsi
cmpq $0x10, %rax
jne 0x12f1
movl $0x10, %eax
movl -0x90(%rsp,%rax,4), %ecx
xorl -0x7c(%rsp,%rax,4), %ecx
xorl -0xa8(%rsp,%rax,4), %ecx
xorl -0xb0(%rsp,%rax,4), %ecx
roll %ecx
movl %ecx, -0x70(%rsp,%rax,4)
incq %rax
cmpq $0x50, %rax
jne 0x1330
movl (%rdi), %r8d
movl 0x4(%rdi), %esi
movl 0x8(%rdi), %edx
movl 0xc(%rdi), %r13d
movl 0x10(%rdi), %r15d
xorl %r10d, %r10d
movl $0xcccccccd, %ebx       # imm = 0xCCCCCCCD
movl %r15d, -0x74(%rsp)
movl %r13d, -0x78(%rsp)
movl %edx, %ebp
movl %esi, %r14d
movl %r8d, %r12d
movl %r12d, %ecx
movl %r14d, %eax
movl %ebp, %r11d
movl %r13d, %r9d
movl %r10d, %r12d
imulq %rbx, %r12
shrq $0x24, %r12
cmpq $0x2, %r12
je 0x13d0
cmpl $0x1, %r12d
je 0x13bf
testl %r12d, %r12d
jne 0x13e9
movl %r11d, %r12d
xorl %r9d, %r12d
andl %eax, %r12d
xorl %r9d, %r12d
movl $0x5a827999, %r13d      # imm = 0x5A827999
jmp 0x13f8
movl %r11d, %r12d
xorl %eax, %r12d
xorl %r9d, %r12d
movl $0x6ed9eba1, %r13d      # imm = 0x6ED9EBA1
jmp 0x13f8
movl %r9d, %ebp
orl %r11d, %ebp
andl %eax, %ebp
movl %r9d, %r12d
andl %r11d, %r12d
orl %ebp, %r12d
movl $0x8f1bbcdc, %r13d      # imm = 0x8F1BBCDC
jmp 0x13f8
movl %r11d, %r12d
xorl %eax, %r12d
xorl %r9d, %r12d
movl $0xca62c1d6, %r13d      # imm = 0xCA62C1D6
movl %ecx, %ebp
roll $0x5, %ebp
addl %ebp, %r15d
addl %r12d, %r15d
addl %r13d, %r15d
movl %r15d, %r12d
addl -0x70(%rsp,%r10,4), %r12d
roll $0x1e, %eax
incq %r10
movl %r9d, %r15d
movl %r11d, %r13d
movl %eax, %ebp
movl %ecx, %r14d
cmpq $0x50, %r10
jne 0x1383
addl %r8d, %r12d
movl %r12d, (%rdi)
addl %esi, %ecx
movl %ecx, 0x4(%rdi)
addl %edx, %eax
movl %eax, 0x8(%rdi)
addl -0x78(%rsp), %r11d
movl %r11d, 0xc(%rdi)
addl -0x74(%rsp), %r9d
movl %r9d, 0x10(%rdi)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq