// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/dns.c
// Function: sshfp_digest
static int sshfp_digest(lua_State *L) {
	struct rr *rr = luaL_checkudata(L, 1, RR_SSHFP_CLASS);
	int fmt = luaL_checkoption(L, 2, "x", (const char *[]){ "s", "x", 0 });
	unsigned char *hash;
	size_t hashlen;

	lua_pushinteger(L, rr->data.sshfp.type);

	switch (rr->data.sshfp.type) {
	case DNS_SSHFP_SHA1:
		hash = rr->data.sshfp.digest.sha1;
		hashlen = sizeof rr->data.sshfp.digest.sha1;

		break;
	default:
		lua_pushnil(L);

		return 2;
	}

	switch (fmt) {
	case 1: {
		luaL_Buffer B;
		size_t i;

		luaL_buffinit(L, &B);

		for (i = 0; i < hashlen; i++) {
			luaL_addchar(&B, "0123456789abcdef"[0x0f & (hash[i] >> 4)]);
			luaL_addchar(&B, "0123456789abcdef"[0x0f & (hash[i] >> 0)]);
		}

		luaL_pushresult(&B);

		break;
	}
	default:
		lua_pushlstring(L, (char *)hash, hashlen);
		break;
	} /* switch() */

	return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2080, %rsp           # imm = 0x2080
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x21df9(%rip), %rdx     # 0x494e3
movl $0x1, %esi
callq 0xfe00
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq 0x33afd(%rip), %rax     # 0x5b200
movq %rax, -0x30(%rbp)
movups 0x33ae2(%rip), %xmm0    # 0x5b1f0
movaps %xmm0, -0x40(%rbp)
leaq 0x20a88(%rip), %rdx     # 0x481a1
movl $0x2, %esi
leaq -0x40(%rbp), %rcx
callq 0xfcb0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, %esi
callq 0xf9a0
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
subl $0x1, %eax
jne 0x27764
jmp 0x2774a
movq -0x18(%rbp), %rax
addq $0x20, %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq $0x14, -0x50(%rbp)
jmp 0x27779
movq -0x10(%rbp), %rdi
callq 0xfa10
movl $0x2, -0x4(%rbp)
jmp 0x278ea
movl -0x1c(%rbp), %eax
subl $0x1, %eax
jne 0x278d2
jmp 0x27787
movq -0x10(%rbp), %rdi
leaq -0x2070(%rbp), %rsi
callq 0x107e0
movq $0x0, -0x2078(%rbp)
movq -0x2078(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x278c4
movq -0x2060(%rbp), %rcx
movb $0x1, %al
cmpq -0x2068(%rbp), %rcx
movb %al, -0x2079(%rbp)
jb 0x277e9
leaq -0x2070(%rbp), %rdi
movl $0x1, %esi
callq 0xf3f0
cmpq $0x0, %rax
setne %al
movb %al, -0x2079(%rbp)
movb -0x2079(%rbp), %al
movq -0x48(%rbp), %rax
movq -0x2078(%rbp), %rcx
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x21d79(%rip), %rax     # 0x49587
movb (%rax,%rcx), %dl
movq -0x2070(%rbp), %rax
movq -0x2060(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x2060(%rbp)
movb %dl, (%rax,%rcx)
movq -0x2060(%rbp), %rcx
movb $0x1, %al
cmpq -0x2068(%rbp), %rcx
movb %al, -0x207a(%rbp)
jb 0x27866
leaq -0x2070(%rbp), %rdi
movl $0x1, %esi
callq 0xf3f0
cmpq $0x0, %rax
setne %al
movb %al, -0x207a(%rbp)
movb -0x207a(%rbp), %al
movq -0x48(%rbp), %rax
movq -0x2078(%rbp), %rcx
movzbl (%rax,%rcx), %eax
sarl $0x0, %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x21cfc(%rip), %rax     # 0x49587
movb (%rax,%rcx), %dl
movq -0x2070(%rbp), %rax
movq -0x2060(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x2060(%rbp)
movb %dl, (%rax,%rcx)
movq -0x2078(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2078(%rbp)
jmp 0x277a2
leaq -0x2070(%rbp), %rdi
callq 0x108d0
jmp 0x278e3
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xf510
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2080, %rsp           # imm = 0x2080
popq %rbp
retq
nopw %cs:(%rax,%rax)