// File: /workspace/github_cpp_makefile_star2_O1/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 0x2f2d
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 0x3067
movl $0x1, %ecx
movq $0x0, -0x30(%rbp)
movq %rcx, -0x40(%rbp)
cmpl $0x0, 0x18(%rbx)
jle 0x3018
movl $0x1, %eax
movq -0x30(%rbp), %r15
movl %r15d, %ecx
shlq %cl, %rax
movq %rax, -0x68(%rbp)
shrq $0x6, %r15
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 0x3009
movq -0x38(%rbp), %rdi
callq 0x2200
addl %r13d, %r12d
incl %r14d
movl %r12d, %r13d
cmpl 0x18(%rbx), %r14d
jl 0x2fa8
movl -0x60(%rbp), %ecx
cmpq $0x29, %rcx
jae 0x3030
movq %rcx, %rax
addq -0x50(%rbp), %rax
addl $0x8, %ecx
movl %ecx, -0x60(%rbp)
jmp 0x303c
movq -0x58(%rbp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq -0x40(%rbp), %rdx
incq -0x30(%rbp)
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rbx), %rax
subq (%rbx), %rax
leaq 0x1(%rdx), %rcx
sarq $0x3, %rax
cmpq %rdx, %rax
ja 0x2f7d
movl -0x30(%rbp), %r12d
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jne 0x308d
movq 0x58(%rbx), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5f5c(%rip), %rdi      # 0x8ff0
leaq 0x3218(%rip), %rsi      # 0x62b3
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movl $0x1, %edi
callq 0x2210