// File: /workspace/github_cpp_makefile_star2_O1/gauravtewari[P]netlist/netlist.cpp
// Function: circuit::update_same_faninout()
int circuit::update_same_faninout(){
	u32 input_type = get_gate_type("INPUT");
	u32 output_type = get_gate_type("OUTPUT");
	u32 gtype;
	u32 *fin = new u32[num_gates];
	u32 *fout = new u32[num_gates];
	for(u32 i=0; i<num_gates; i++){ fin[i]=0; fout[i]=0;}
	for(vector<struct gate>::const_iterator i = gate_list.begin(); i != gate_list.end(); i++){
		/* For each gate (except input and output gates )find the edges that are driven by this gate */
		if((i->type != input_type) && (i->type != output_type)){
			gtype = i->type;	/* Note the gate type for comparison */
			for(list<u32>::const_iterator j = i->nets.begin(); j != i->nets.end(); j++){ /* For each edge driven by this gate */
				/* For each edge find the gate it drives */
				for(list<u32>::const_iterator k = net_list[*j].gates.begin(); k != net_list[*j].gates.end(); k++){ /* For each gate driven by this edge */
					if(gate_list[*k].type == gtype){
						fout[i->id]=1;
						fin[*k]=1;
					}
					
				}
			}
		}
	}
	for(u32 i = 0; i < num_gates; i++){
		if(fout[i] == 1){
			same_fanout[gate_list[i].type]++;
		}
		if(fin[i] == 1){
			same_fanin[gate_list[i].type]++;
		}
	}
	delete []fin;
	delete []fout;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x13b5(%rip), %rsi      # 0x508a
leaq 0x13b3(%rip), %rdx      # 0x508f
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x2f90
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3ba2
movl %eax, %ebp
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x3d0d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2210
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1373(%rip), %rsi      # 0x5090
leaq 0x1372(%rip), %rdx      # 0x5096
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x2f90
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3ba2
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3d57
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2210
movl (%rbx), %r13d
leaq (,%r13,4), %r12
movq %r12, %rdi
callq 0x2030
movq %rax, %r14
movq %r12, %rdi
callq 0x2030
movq %rax, %r15
testq %r13, %r13
je 0x3d97
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2150
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2150
movq 0x90(%rbx), %rax
movq 0x98(%rbx), %rcx
cmpq %rcx, %rax
je 0x3e34
movq 0xa8(%rbx), %rdx
movl $0x1, %esi
movq %rax, %rdi
movl 0x4(%rdi), %r8d
cmpl %ebp, %r8d
je 0x3e2b
cmpl 0x4(%rsp), %r8d
je 0x3e2b
leaq 0x10(%rdi), %r9
movq 0x10(%rdi), %r10
cmpq %r9, %r10
je 0x3e2b
movl 0x10(%r10), %r11d
leaq (%r11,%r11,4), %r11
leaq (%rdx,%r11,8), %r12
addq $0x10, %r12
movq (%r12), %r11
cmpq %r12, %r11
je 0x3e26
movl 0x10(%r11), %r12d
leaq (%r12,%r12,4), %r12
cmpl %r8d, 0x4(%rax,%r12,8)
jne 0x3e11
movl (%rdi), %r12d
movl %esi, (%r15,%r12,4)
movl 0x10(%r11), %r12d
movl %esi, (%r14,%r12,4)
movq (%r11), %r11
movl 0x10(%r10), %r12d
leaq (%r12,%r12,4), %r12
leaq (%rdx,%r12,8), %r12
addq $0x10, %r12
jmp 0x3dee
movq (%r10), %r10
jmp 0x3dd5
addq $0x28, %rdi
cmpq %rcx, %rdi
jne 0x3dbd
testq %r13, %r13
je 0x3e65
addq $0x4, %rax
xorl %ecx, %ecx
cmpl $0x1, (%r15,%rcx,4)
jne 0x3e4c
movl (%rax), %edx
incl 0x44(%rbx,%rdx,4)
cmpl $0x1, (%r14,%rcx,4)
jne 0x3e59
movl (%rax), %edx
incl 0x68(%rbx,%rdx,4)
incq %rcx
addq $0x28, %rax
cmpq %rcx, %r13
jne 0x3e3f
movq %r14, %rdi
callq 0x2270
movq %r15, %rdi
callq 0x2270
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
jmp 0x3e98
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x3ea8
movq (%r15), %rsi
incq %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2300