// File: /workspace/github_c_makefile_star2_O1/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 0xacd6(%rip), %r13      # 0x14590
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x1100
movq %rax, %rbx
movups 0x5dba(%rip), %xmm0     # 0xf68d
movups %xmm0, (%rax)
movups 0x5dc0(%rip), %xmm0     # 0xf69d
movups %xmm0, 0x10(%rax)
movw $0xa, 0x20(%rax)
movq 0xacba(%rip), %rdi      # 0x145a8
movq %rax, %rsi
callq 0x8512
movq %rax, 0xacab(%rip)      # 0x145a8
movups 0x5dab(%rip), %xmm0     # 0xf6af
movups %xmm0, (%rbx)
movups 0x5db1(%rip), %xmm0     # 0xf6bf
movups %xmm0, 0x10(%rbx)
movl $0xa3b31, 0x1f(%rbx)    # imm = 0xA3B31
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xac7d(%rip)      # 0x145a8
movups 0x5da0(%rip), %xmm0     # 0xf6d2
movups %xmm0, (%rbx)
movups 0x5da6(%rip), %xmm0     # 0xf6e2
movups %xmm0, 0x10(%rbx)
movl $0xa3b32, 0x20(%rbx)    # imm = 0xA3B32
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xac4f(%rip)      # 0x145a8
movups 0x5d96(%rip), %xmm0     # 0xf6f6
movups %xmm0, (%rbx)
movups 0x5d9c(%rip), %xmm0     # 0xf706
movups %xmm0, 0x10(%rbx)
movl $0xa3b33, 0x20(%rbx)    # imm = 0xA3B33
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xac21(%rip)      # 0x145a8
testq %r13, %r13
je 0x9a46
movl $0x4, %ebp
leaq 0x5dc1(%rip), %r14      # 0xf75d
leaq 0x5d98(%rip), %r15      # 0xf73b
leaq 0x5d70(%rip), %r12      # 0xf71a
cmpl $0x0, 0x18(%r13)
je 0x99dc
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11b0
movq 0xabdd(%rip), %rdi      # 0x145a8
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xabce(%rip)      # 0x145a8
incl %ebp
cmpl $0x0, 0x38(%r13)
je 0x9a0e
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11b0
movq 0xabab(%rip), %rdi      # 0x145a8
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xab9c(%rip)      # 0x145a8
incl %ebp
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11b0
movq 0xab80(%rip), %rdi      # 0x145a8
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xab71(%rip)      # 0x145a8
incl %ebp
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x99aa
movups 0x5d32(%rip), %xmm0     # 0xf77f
movups %xmm0, (%rbx)
movw $0xa, 0x10(%rbx)
movq 0xab4b(%rip), %rdi      # 0x145a8
movq %rbx, %rsi
callq 0x8512
movq %rax, 0xab3c(%rip)      # 0x145a8
movq %rbx, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq