// File: /workspace/github_c_makefile_star2_O2/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 0xa1e1(%rip), %r13      # 0x13580
pushq $0x1
popq %rsi
movl $0x400, %edi            # imm = 0x400
callq 0x10f0
movq %rax, %rbx
movups 0x52ab(%rip), %xmm0     # 0xe661
movups %xmm0, (%rax)
movups 0x52b1(%rip), %xmm0     # 0xe671
movups %xmm0, 0x10(%rax)
movw $0xa, 0x20(%rax)
movq 0xa1c7(%rip), %rdi      # 0x13598
movq %rax, %rsi
callq 0x7f6b
movq %rax, 0xa1b8(%rip)      # 0x13598
movups 0x529c(%rip), %xmm0     # 0xe683
movups %xmm0, (%rbx)
movups 0x52a2(%rip), %xmm0     # 0xe693
movups %xmm0, 0x10(%rbx)
movl $0xa3b31, 0x1f(%rbx)    # imm = 0xA3B31
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa18a(%rip)      # 0x13598
movups 0x5291(%rip), %xmm0     # 0xe6a6
movups %xmm0, (%rbx)
movups 0x5297(%rip), %xmm0     # 0xe6b6
movups %xmm0, 0x10(%rbx)
movl $0xa3b32, 0x20(%rbx)    # imm = 0xA3B32
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa15c(%rip)      # 0x13598
movups 0x5287(%rip), %xmm0     # 0xe6ca
movups %xmm0, (%rbx)
movups 0x528d(%rip), %xmm0     # 0xe6da
movups %xmm0, 0x10(%rbx)
movl $0xa3b33, 0x20(%rbx)    # imm = 0xA3B33
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa12e(%rip)      # 0x13598
pushq $0x4
popq %rbp
leaq 0x52bd(%rip), %r14      # 0xe731
leaq 0x5294(%rip), %r15      # 0xe70f
leaq 0x526c(%rip), %r12      # 0xe6ee
testq %r13, %r13
je 0x9523
cmpl $0x0, 0x18(%r13)
je 0x94bd
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11a0
movq 0xa0ec(%rip), %rdi      # 0x13598
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa0dd(%rip)      # 0x13598
incl %ebp
cmpl $0x0, 0x38(%r13)
je 0x94ef
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11a0
movq 0xa0ba(%rip), %rdi      # 0x13598
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa0ab(%rip)      # 0x13598
incl %ebp
movl 0x10(%r13), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11a0
movq 0xa08f(%rip), %rdi      # 0x13598
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa080(%rip)      # 0x13598
incl %ebp
movq 0x8(%r13), %r13
jmp 0x9482
movups 0x5229(%rip), %xmm0     # 0xe753
movups %xmm0, (%rbx)
movw $0xa, 0x10(%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7f6b
movq %rax, 0xa053(%rip)      # 0x13598
movq %rbx, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq