// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/towntalk.c
// Function: parse_switch_statement
static struct element* parse_switch_statement( struct element *elem,
	struct function *func, struct variables *vars, struct statement *prev, char *message ) {
	struct expression expr;
	struct element *next = elem->next;
	struct statement block = { 0 }, *cas, *def;
	struct block_statement *stmt = calloc( 1, sizeof( struct block_statement ) );
	if( stmt ) {
		stmt->stmt.dispose = dispose_block_statement;
		prev->next = &stmt->stmt;
		expr.next = NULL;
		next = parse_expression( next, func, vars, &expr, message );
		if( expr.next ) {
			stmt->stmt.source = expr.next;
			block.next = NULL;
			parse_keywords( switch_stmts, next->child, func, vars, &block, message );
			if( message[ 0 ] == 0 ) {
				cas = def = NULL;
				while( block.next ) {
					if( block.next->source ) {
						if( cas ) {
							cas->next = block.next;
							cas = cas->next;
						} else {
							stmt->if_block = cas = block.next;
						}
						block.next = block.next->next;
						cas->next = NULL;
					} else {
						if( def ) {
							def->next = block.next;
							def = def->next;
						} else {
							stmt->else_block = def = block.next;
						}
						block.next = block.next->next;
						def->next = NULL;
					}
				}
				if( stmt->else_block == NULL || stmt->else_block->next == NULL ) {
					next = next->next;
					stmt->stmt.execute = execute_switch_statement;
				} else {
					sprintf( message, "Duplicate default block in switch statement on line %d.", elem->line );
				}
			} else {
				dispose_statements( block.next );
			}
		}
	} else {
		strcpy( message, OUT_OF_MEMORY );
	}
	return next;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x30f0
movl $0x1, %edi
movl $0x48, %esi
callq 0x3120
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0xe69d
movq -0x90(%rbp), %rax
leaq -0x95fd(%rip), %rcx     # 0x4ed0
movq %rcx, 0x18(%rax)
movq -0x90(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0x38(%rbp)
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %r8
leaq -0x48(%rbp), %rcx
callq 0x60c0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xe69b
movq -0x38(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x8(%rax)
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %r9
leaq 0x1397e(%rip), %rdi     # 0x21ec0
leaq -0x78(%rbp), %r8
callq 0x9e50
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xe690
movq $0x0, -0x88(%rbp)
movq $0x0, -0x80(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xe635
movq -0x58(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xe5d2
cmpq $0x0, -0x80(%rbp)
je 0xe5a5
movq -0x58(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x80(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0xe5b8
movq -0x58(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq -0x90(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x80(%rbp), %rax
movq $0x0, 0x20(%rax)
jmp 0xe630
cmpq $0x0, -0x88(%rbp)
je 0xe5ff
movq -0x58(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x88(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0xe615
movq -0x58(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq -0x90(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x88(%rbp), %rax
movq $0x0, 0x20(%rax)
jmp 0xe56e
movq -0x90(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xe655
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0xe675
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x90(%rbp), %rax
leaq 0x24d1(%rip), %rcx      # 0x10b40
movq %rcx, 0x10(%rax)
jmp 0xe68e
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x28(%rax), %edx
leaq 0xdca3(%rip), %rsi      # 0x1c32a
movb $0x0, %al
callq 0x31f0
jmp 0xe699
movq -0x58(%rbp), %rdi
callq 0x3e00
jmp 0xe69b
jmp 0xe6ad
movq -0x28(%rbp), %rdi
movq 0x12ab8(%rip), %rsi     # 0x21160
callq 0x3070
movq -0x50(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)