// File: /workspace/github_cpp_makefile_star2_O3/hey-yahei[P]ConvNet/src/Concat.cpp
// Function: Concat::Run(float*, ...)
float* Concat::Run(float* in_data, ...) {
	va_list ap;
	
	int offset = 0;
	int *ishape;
	int input_size;
	int idx_input = 0;
	int cnt = 0;

	out_data = (float*)malloc(sizeof(float) * out_shape[0] * out_chw);

	va_start(ap, in_data);
	while (cnt++ < in_shape.size()) {
		for (int idx_bs = 0; idx_bs < out_shape[0]; idx_bs++) {
			ishape = in_shape[idx_input];
			input_size = ishape[1] * ishape[2] * ishape[3];
			memcpy(out_data + idx_bs * out_chw + offset, in_data, sizeof(float) * input_size);
			offset += input_size;

			if (!keep_in[idx_input])
				free(in_data);
		}
		idx_input++;

		// Next input
		in_data = va_arg(ap, float*);
	}
	va_end(ap);

	if (idx_input != in_shape.size()) {
		cerr << "Concat: run failed" << endl;
		exit(1);
	}

	return out_data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, %rbx
leaq -0x120(%rbp), %r14
movq %rdx, 0x10(%r14)
movq %rcx, 0x18(%r14)
movq %r8, 0x20(%r14)
movq %r9, 0x28(%r14)
testb %al, %al
je 0x2f25
movaps %xmm0, -0xf0(%rbp)
movaps %xmm1, -0xe0(%rbp)
movaps %xmm2, -0xd0(%rbp)
movaps %xmm3, -0xc0(%rbp)
movaps %xmm4, -0xb0(%rbp)
movaps %xmm5, -0xa0(%rbp)
movaps %xmm6, -0x90(%rbp)
movaps %xmm7, -0x80(%rbp)
movslq 0x18(%rdi), %rax
movslq 0x50(%rdi), %rdi
imulq %rax, %rdi
shlq $0x2, %rdi
callq 0x2240
movq %rax, 0x58(%rbx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, -0x60(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq %r14, -0x50(%rbp)
movq 0x8(%rbx), %rax
xorl %r12d, %r12d
cmpq (%rbx), %rax
je 0x3062
movl 0x18(%rbx), %eax
movl $0x1, %edx
movq $0x0, -0x30(%rbp)
movq %rdx, -0x40(%rbp)
testl %eax, %eax
jle 0x3013
movl $0x1, %eax
movq -0x30(%rbp), %rcx
shlq %cl, %rax
movq %rax, -0x68(%rbp)
movl %ecx, %r15d
shrl $0x6, %r15d
xorl %r14d, %r14d
movl %r12d, %r13d
movq (%rbx), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x4(%rax), %rcx
movslq 0x8(%rax), %rdx
imulq %rcx, %rdx
movslq 0x50(%rbx), %rcx
movslq %r14d, %rsi
imulq %rcx, %rsi
movslq 0xc(%rax), %r12
shlq $0x2, %rsi
addq 0x58(%rbx), %rsi
imulq %rdx, %r12
movslq %r13d, %rax
leaq (%rsi,%rax,4), %rdi
leaq (,%r12,4), %rdx
movq -0x38(%rbp), %rsi
callq 0x2130
movq 0x28(%rbx), %rax
movq -0x68(%rbp), %rcx
testq %rcx, (%rax,%r15,8)
jne 0x3002
movq -0x38(%rbp), %rdi
callq 0x2200
addl %r13d, %r12d
incl %r14d
movl 0x18(%rbx), %eax
movl %r12d, %r13d
cmpl %eax, %r14d
jl 0x2fa1
movl -0x60(%rbp), %edx
cmpq $0x29, %rdx
jae 0x302b
movq %rdx, %rcx
addq -0x50(%rbp), %rcx
addl $0x8, %edx
movl %edx, -0x60(%rbp)
jmp 0x3037
movq -0x58(%rbp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, -0x58(%rbp)
movq -0x40(%rbp), %rsi
incq -0x30(%rbp)
movq (%rcx), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
leaq 0x1(%rsi), %rdx
sarq $0x3, %rcx
cmpq %rsi, %rcx
ja 0x2f78
movl -0x30(%rbp), %r12d
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jne 0x3088
movq 0x58(%rbx), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5f61(%rip), %rdi      # 0x8ff0
leaq 0x321d(%rip), %rsi      # 0x62b3
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movl $0x1, %edi
callq 0x2210
nop