// File: hey-yahei[P]ConvNet/src/Concat.cpp
// Function: Concat::Concat(int*, ...)
Concat::Concat(int ishape[], ...) {
	va_list ap;
	int cnt = 0;
	int *temp;

	// First arg
	va_start(ap, ishape);
	temp = (int*)malloc(sizeof(int) * 4);
	memcpy(temp, ishape, sizeof(int) * 4);
	in_shape.push_back(temp);
	memcpy(out_shape, ishape, sizeof(int) * 4);
	cnt++;

	// Other args
	while(nullptr != (ishape=va_arg(ap, int*))){
		// Push into vector
		temp = (int*)malloc(sizeof(int) * 4);
		memcpy(temp, ishape, sizeof(int) * 4);
		in_shape.push_back(temp);

		// Check if shapes match
		if ((temp[0] != out_shape[0]) || (temp[2] != out_shape[2]) || (temp[3] != out_shape[3])) {
			cerr << "Concat: shapes of input not match." << endl;
			exit(1);
		}

		// Update out_channels and counter
		out_shape[1] += temp[1];
		cnt++;
	}
	va_end(ap);

	out_chw = out_shape[1] * out_shape[2] * out_shape[3];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
testb %al, %al
je 0x38ee
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
movaps %xmm2, -0xb0(%rbp)
movaps %xmm3, -0xa0(%rbp)
movaps %xmm4, -0x90(%rbp)
movaps %xmm5, -0x80(%rbp)
movaps %xmm6, -0x70(%rbp)
movaps %xmm7, -0x60(%rbp)
movq %r9, -0xd8(%rbp)
movq %r8, -0xe0(%rbp)
movq %rcx, -0xe8(%rbp)
movq %rdx, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x108(%rbp)
movq %rdi, %rax
movq %rax, -0x118(%rbp)
callq 0x3f80
movq -0x108(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x110(%rbp)
callq 0x3fa0
movq -0x108(%rbp), %rax
movq $0x0, 0x58(%rax)
movl $0x0, -0x34(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x30, -0x2c(%rbp)
movl $0x10, -0x30(%rbp)
movl $0x10, %edi
callq 0x22e0
movq -0x108(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movups (%rcx), %xmm0
movups %xmm0, (%rax)
leaq -0x40(%rbp), %rsi
callq 0x3fc0
jmp 0x39a8
movq -0x118(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x20(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x11c(%rbp)
cmpl $0x28, %eax
ja 0x3a2f
movq -0x128(%rbp), %rcx
movl -0x11c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x130(%rbp)
jmp 0x3a4c
movq -0x110(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x3230
movq -0x108(%rbp), %rdi
callq 0x3250
jmp 0x3b4a
movq -0x128(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x10(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x3b28
movl $0x10, %edi
callq 0x22e0
movq -0x118(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movups (%rcx), %xmm0
movups %xmm0, (%rax)
leaq -0x40(%rbp), %rsi
callq 0x3fc0
jmp 0x3a93
movq -0x118(%rbp), %rcx
movq -0x40(%rbp), %rax
movl (%rax), %eax
cmpl 0x18(%rcx), %eax
jne 0x3acb
movq -0x118(%rbp), %rcx
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
cmpl 0x20(%rcx), %eax
jne 0x3acb
movq -0x118(%rbp), %rcx
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
cmpl 0x24(%rcx), %eax
je 0x3b06
movq 0xe51e(%rip), %rdi      # 0x11ff0
leaq 0x87b7(%rip), %rsi      # 0xc290
callq 0x21c0
movq %rax, -0x138(%rbp)
jmp 0x3ae7
movq -0x138(%rbp), %rdi
movq 0xe4cb(%rip), %rsi      # 0x11fc0
callq 0x2200
jmp 0x3afc
movl $0x1, %edi
callq 0x2290
movq -0x118(%rbp), %rax
movq -0x40(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl 0x1c(%rax), %ecx
movl %ecx, 0x1c(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39cb
movq -0x118(%rbp), %rax
movl 0x1c(%rax), %ecx
movl 0x20(%rax), %edx
imull %edx, %ecx
movl 0x24(%rax), %edx
imull %edx, %ecx
movl %ecx, 0x50(%rax)
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)