// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xada0(%rip), %r13      # 0x14580
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x10f0
movq %rax, %rbx
movups 0x5e88(%rip), %xmm0     # 0xf681
movups %xmm0, (%rax)
movups 0x5e8e(%rip), %xmm0     # 0xf691
movups %xmm0, 0x10(%rax)
movw $0xa, 0x20(%rax)
movq 0xad84(%rip), %rdi      # 0x14598
movq %rax, %rsi
callq 0x83ef
movq %rax, 0xad75(%rip)      # 0x14598
movups 0x5e79(%rip), %xmm0     # 0xf6a3
movups %xmm0, (%rbx)
movups 0x5e7f(%rip), %xmm0     # 0xf6b3
movups %xmm0, 0x10(%rbx)
movl $0xa3b31, 0x1f(%rbx)    # imm = 0xA3B31
movq %rax, %rdi
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xad47(%rip)      # 0x14598
movups 0x5e6e(%rip), %xmm0     # 0xf6c6
movups %xmm0, (%rbx)
movups 0x5e74(%rip), %xmm0     # 0xf6d6
movups %xmm0, 0x10(%rbx)
movl $0xa3b32, 0x20(%rbx)    # imm = 0xA3B32
movq %rax, %rdi
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xad19(%rip)      # 0x14598
movups 0x5e64(%rip), %xmm0     # 0xf6ea
movups %xmm0, (%rbx)
movups 0x5e6a(%rip), %xmm0     # 0xf6fa
movups %xmm0, 0x10(%rbx)
movl $0xa3b33, 0x20(%rbx)    # imm = 0xA3B33
movq %rax, %rdi
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xaceb(%rip)      # 0x14598
testq %r13, %r13
je 0x996c
movl $0x4, %ebp
leaq 0x5e8f(%rip), %r14      # 0xf751
leaq 0x5e66(%rip), %r15      # 0xf72f
leaq 0x5e3e(%rip), %r12      # 0xf70e
cmpl $0x0, 0x18(%r13)
je 0x9902
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11a0
movq 0xaca7(%rip), %rdi      # 0x14598
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xac98(%rip)      # 0x14598
incl %ebp
cmpl $0x0, 0x38(%r13)
je 0x9934
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11a0
movq 0xac75(%rip), %rdi      # 0x14598
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xac66(%rip)      # 0x14598
incl %ebp
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11a0
movq 0xac4a(%rip), %rdi      # 0x14598
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xac3b(%rip)      # 0x14598
incl %ebp
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x98d0
movups 0x5e00(%rip), %xmm0     # 0xf773
movups %xmm0, (%rbx)
movw $0xa, 0x10(%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x83ef
movq %rax, 0xac0a(%rip)      # 0x14598
movq %rbx, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq