// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/dns.c
// Function: pkt_setflags
static int pkt_setflags(lua_State *L) {
	struct dns_packet *P = luaL_checkudata(L, 1, PACKET_CLASS);
	struct dns_header *hdr = dns_header(P);

	if (lua_isnumber(L, 2)) {
		int flags = luaL_checkint(L, 2);

		hdr->qr = 0x01 & (flags >> 15);
		hdr->opcode = 0x0f & (flags >> 11);
		hdr->aa = 0x01 & (flags >> 10);
		hdr->tc = 0x01 & (flags >> 9);
		hdr->rd = 0x01 & (flags >> 8);
		hdr->ra = 0x01 & (flags >> 7);
		hdr->unused = 0x07 & (flags >> 4);
		hdr->rcode = 0x0f & (flags >> 0);
	} else {
		luaL_checktype(L, 2, LUA_TTABLE);

		for (lua_pushnil(L); lua_next(L, 2); lua_pop(L, 1)) {
			const char *flag = luaL_checkstring(L, -2);

			if (pkt_isflag(flag, "qr")) {
				hdr->qr = pkt_tobool(L, -1);
			} else if (pkt_isflag(flag, "opcode")) {
				hdr->opcode = luaL_checkint(L, -1);
			} else if (pkt_isflag(flag, "aa")) {
				hdr->aa = pkt_tobool(L, -1);
			} else if (pkt_isflag(flag, "tc")) {
				hdr->tc = pkt_tobool(L, -1);
			} else if (pkt_isflag(flag, "rd")) {
				hdr->rd = pkt_tobool(L, -1);
			} else if (pkt_isflag(flag, "ra")) {
				hdr->ra = pkt_tobool(L, -1);
			} else if (pkt_isflag(flag, "z")) {
				hdr->unused = luaL_checkint(L, -1);
			} else if (pkt_isflag(flag, "rcode")) {
				hdr->rcode = luaL_checkint(L, -1);
			}
		}
	}

	lua_settop(L, 1);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
leaq 0x2178b(%rip), %rdx     # 0x49397
callq 0xfe00
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x5c, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0xfc70
cmpl $0x0, %eax
je 0x27d9c
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x10c70
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
sarl $0xf, %ecx
andl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x17, %rdx
andq $-0x800001, %rcx        # imm = 0xFF7FFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0xb, %ecx
andl $0xf, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0xf, %rdx
shlq $0x13, %rdx
andq $-0x780001, %rcx        # imm = 0xFF87FFFF
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0xa, %ecx
andl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x12, %rdx
andq $-0x40001, %rcx         # imm = 0xFFFBFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0x9, %ecx
andl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x11, %rdx
andq $-0x20001, %rcx         # imm = 0xFFFDFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0x8, %ecx
andl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x10, %rdx
andq $-0x10001, %rcx         # imm = 0xFFFEFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0x7, %ecx
andl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0x4, %ecx
andl $0x7, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x7, %rdx
shlq $0x1c, %rdx
andq $-0x70000001, %rcx      # imm = 0x8FFFFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %ecx
sarl $0x0, %ecx
andl $0xf, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0xf, %rdx
shlq $0x18, %rdx
andq $-0xf000001, %rcx       # imm = 0xF0FFFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x2807f
movq -0x8(%rbp), %rdi
movl $0x2, %esi
movl $0x5, %edx
callq 0xf740
movq -0x8(%rbp), %rdi
callq 0xfa10
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x10920
cmpl $0x0, %eax
je 0x2807d
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
xorl %eax, %eax
movl %eax, %edx
callq 0xf6a0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x217d9(%rip), %rsi     # 0x495c9
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x27e35
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x28470
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x17, %rdx
andq $-0x800001, %rcx        # imm = 0xFF7FFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x28068
movq -0x28(%rbp), %rdi
leaq 0x2156a(%rip), %rsi     # 0x493aa
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x27e82
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x10c70
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0xf, %rdx
shlq $0x13, %rdx
andq $-0x780001, %rcx        # imm = 0xFF87FFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x28066
movq -0x28(%rbp), %rdi
leaq 0x2173f(%rip), %rsi     # 0x495cc
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x27ed2
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x28470
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x12, %rdx
andq $-0x40001, %rcx         # imm = 0xFFFBFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x28064
movq -0x28(%rbp), %rdi
leaq 0x216f2(%rip), %rsi     # 0x495cf
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x27f22
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x28470
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x11, %rdx
andq $-0x20001, %rcx         # imm = 0xFFFDFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x28062
movq -0x28(%rbp), %rdi
leaq 0x2114c(%rip), %rsi     # 0x49079
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x27f72
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x28470
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x10, %rdx
andq $-0x10001, %rcx         # imm = 0xFFFEFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x28060
movq -0x28(%rbp), %rdi
leaq 0x21655(%rip), %rsi     # 0x495d2
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x27fc8
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x28470
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x2805e
movq -0x28(%rbp), %rdi
leaq 0x207fd(%rip), %rsi     # 0x487d0
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28012
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x10c70
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0x7, %rdx
shlq $0x1c, %rdx
andq $-0x70000001, %rcx      # imm = 0x8FFFFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x2805c
movq -0x28(%rbp), %rdi
leaq 0x21394(%rip), %rsi     # 0x493b1
callq 0x103a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x2805a
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x10c70
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
andq $0xf, %rdx
shlq $0x18, %rdx
andq $-0xf000001, %rcx       # imm = 0xF0FFFFFF
orq %rdx, %rcx
movq %rcx, (%rax)
jmp 0x2805c
jmp 0x2805e
jmp 0x28060
jmp 0x28062
jmp 0x28064
jmp 0x28066
jmp 0x28068
jmp 0x2806a
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
jmp 0x27db8
jmp 0x2807f
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x107f0
movl $0x1, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)