// File: /workspace/github_c_makefile_star2_O0/qpfiffer[P]38-Moths/src/greshunkel.c
// Function: is_truthy
static inline int _is_truthy(const greshunkel_tuple *tuple) {
	const int is_string = tuple->type == GSHKL_STR ? 1 : 0;
	const int is_loop = tuple->type == GSHKL_ARR ? 1 : 0;
	const int is_subcontext = tuple->type == GSHKL_SUBCTEXT ? 1 : 0;
	int is_null = 0;
	if (is_string) {
		is_null = strnlen(tuple->value.str, MAX_GSHKL_STR_SIZE) == 0 ? 1 : 0;
	} else if (is_loop) {
		is_null = tuple->value.arr == NULL;
	} else if (is_subcontext) {
		is_null = 0;
	}

	if (!is_null) {
		if (is_string) {
			const int says_false = strncmp(tuple->value.str, "FALSE", strlen("FALSE")) == 0 ? 1 : 0;
			m38_log_msg(LOG_DEBUG, "_is_truthy: !is_null is_string SF: %i", !says_false);
			return !says_false;
		} else if (is_loop) {
			const int has_items = tuple->value.arr->count > 0;
			m38_log_msg(LOG_DEBUG, "_is_truthy: !is_null is_loop has_items: %i", has_items);
			return has_items;
		}
		m38_log_msg(LOG_DEBUG, "_is_truthy: !is_null  is_subcontext: %i", is_subcontext);
		return is_subcontext;
	}

	int rc = (is_string || is_subcontext) && !is_null;
	m38_log_msg(LOG_DEBUG, "_is_truthy: complex: %i %i %i %i", rc, is_string, is_subcontext, !is_null);
	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x1, %edx
cmovel %ecx, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x4936
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x1120
movq %rax, %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovel %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x4963
cmpl $0x0, -0x18(%rbp)
je 0x4952
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x20(%rbp)
jmp 0x4961
cmpl $0x0, -0x1c(%rbp)
je 0x495f
movl $0x0, -0x20(%rbp)
jmp 0x4961
jmp 0x4963
cmpl $0x0, -0x20(%rbp)
jne 0x4a31
cmpl $0x0, -0x14(%rbp)
je 0x49d5
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
leaq 0x269c(%rip), %rsi      # 0x701e
movl $0x5, %edx
callq 0x1060
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movl $0x1, %edi
leaq 0x3f57(%rip), %rsi      # 0x890f
movb $0x0, %al
callq 0x5a60
cmpl $0x0, -0x24(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x4a8b
cmpl $0x0, -0x18(%rbp)
je 0x4a11
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, 0x10(%rax)
seta %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %edx
movl $0x1, %edi
leaq 0x3f33(%rip), %rsi      # 0x8935
movb $0x0, %al
callq 0x5a60
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4a8b
jmp 0x4a13
movl -0x1c(%rbp), %edx
movl $0x1, %edi
leaq 0x3f3e(%rip), %rsi      # 0x8960
movb $0x0, %al
callq 0x5a60
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4a8b
cmpl $0x0, -0x14(%rbp)
jne 0x4a42
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x2d(%rbp)
je 0x4a4e
cmpl $0x0, -0x20(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %edx
movl -0x14(%rbp), %ecx
movl -0x1c(%rbp), %r8d
cmpl $0x0, -0x20(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %r9d
movl $0x1, %edi
leaq 0x3f0a(%rip), %rsi      # 0x8988
movb $0x0, %al
callq 0x5a60
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)