// File: /workspace/github_c_makefile_star2_O0/aquaxis[P]synverll/src/parser_ir_proc.c
// Function: create_verilog_state
int create_verilog_state()
{
	PROC_TREE *now_proc_tree = proc_tree_top;
    char *buf;
	int count = 4;

	buf = calloc(STR_MAX, 1);

	sprintf(buf, "localparam __state_fin_exec = 0;\n");
	verilog_state = register_verilog(verilog_state, buf);
	sprintf(buf, "localparam __state_start_req = 1;\n");
	verilog_state = register_verilog(verilog_state, buf);
	sprintf(buf, "localparam __state_start_wait = 2;\n");
	verilog_state = register_verilog(verilog_state, buf);
	sprintf(buf, "localparam __state_start_exec = 3;\n");
	verilog_state = register_verilog(verilog_state, buf);

    while(now_proc_tree != NULL){
		if(now_proc_tree->seq_req.ena){
			sprintf(buf, "localparam __state_%d_req = %d;\n", now_proc_tree->stage, count);
			verilog_state = register_verilog(verilog_state, buf);
			count++;
		}
		if(now_proc_tree->seq_wait.ena){
			sprintf(buf, "localparam __state_%d_wait = %d;\n", now_proc_tree->stage, count);
			verilog_state = register_verilog(verilog_state, buf);
			count++;
		}
		sprintf(buf, "localparam __state_%d_exec = %d;\n", now_proc_tree->stage, count);
		verilog_state = register_verilog(verilog_state, buf);
		count++;
        now_proc_tree = now_proc_tree->next_ptr;
	}

	sprintf(buf, "integer __state;\n");
	verilog_state = register_verilog(verilog_state, buf);

	free(buf);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq 0xb2e1(%rip), %rax      # 0x18560
movq %rax, -0x8(%rbp)
movl $0x4, -0x14(%rbp)
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x10c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x742e(%rip), %rsi      # 0x146d6
movb $0x0, %al
callq 0x1160
movq 0xb2c2(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb2b2(%rip)      # 0x18578
movq -0x10(%rbp), %rdi
leaq 0x7427(%rip), %rsi      # 0x146f8
movb $0x0, %al
callq 0x1160
movq 0xb299(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb289(%rip)      # 0x18578
movq -0x10(%rbp), %rdi
leaq 0x7421(%rip), %rsi      # 0x1471b
movb $0x0, %al
callq 0x1160
movq 0xb270(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb260(%rip)      # 0x18578
movq -0x10(%rbp), %rdi
leaq 0x741c(%rip), %rsi      # 0x1473f
movb $0x0, %al
callq 0x1160
movq 0xb247(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb237(%rip)      # 0x18578
cmpq $0x0, -0x8(%rbp)
je 0xd425
movq -0x8(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0xd392
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
movl -0x14(%rbp), %ecx
leaq 0x73f8(%rip), %rsi      # 0x14763
movb $0x0, %al
callq 0x1160
movq 0xb1ff(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb1ef(%rip)      # 0x18578
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0xd3d8
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
movl -0x14(%rbp), %ecx
leaq 0x73d3(%rip), %rsi      # 0x14784
movb $0x0, %al
callq 0x1160
movq 0xb1b9(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb1a9(%rip)      # 0x18578
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
movl -0x14(%rbp), %ecx
leaq 0x73b9(%rip), %rsi      # 0x147a6
movb $0x0, %al
callq 0x1160
movq 0xb17d(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb16d(%rip)      # 0x18578
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xd341
movq -0x10(%rbp), %rdi
leaq 0x7398(%rip), %rsi      # 0x147c8
movb $0x0, %al
callq 0x1160
movq 0xb13a(%rip), %rdi      # 0x18578
movq -0x10(%rbp), %rsi
callq 0xb6c0
movq %rax, 0xb12a(%rip)      # 0x18578
movq -0x10(%rbp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nop