// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %rdi, %rbx
leaq 0x19ba(%rip), %rsi      # 0x508a
leaq 0x38(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x2aaa
leaq 0x38(%rsp), %rsi
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x35d4
movl %eax, 0x14(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x2110
leaq 0x198a(%rip), %rsi      # 0x5090
leaq 0x18(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x2aaa
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x35d4
movl %eax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2110
movl (%rbx), %r13d
leaq (,%r13,4), %r15
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %r15, %rdi
callq 0x2030
movq %rax, %r15
xorl %eax, %eax
cmpq %rax, %r13
je 0x376c
andl $0x0, (%r14,%rax,4)
andl $0x0, (%r15,%rax,4)
incq %rax
jmp 0x3758
movq 0x8(%rsp), %rdx
movq 0x90(%rdx), %rax
movq 0x98(%rdx), %rcx
movq 0xa8(%rdx), %rdx
pushq $0x1
popq %rsi
movq %rax, %rdi
cmpq %rcx, %rdi
je 0x37ee
movl 0x4(%rdi), %r8d
cmpl 0x14(%rsp), %r8d
je 0x37e8
cmpl 0x10(%rsp), %r8d
je 0x37e8
leaq 0x10(%rdi), %r9
movq %r9, %r10
movq (%r10), %r10
cmpq %r9, %r10
je 0x37e8
movl 0x10(%r10), %r11d
imulq $0x28, %r11, %r11
leaq (%rdx,%r11), %rbx
addq $0x10, %rbx
movq %rbx, %r11
movq (%r11), %r11
cmpq %rbx, %r11
je 0x37aa
movl 0x10(%r11), %r12d
imulq $0x28, %r12, %rbp
cmpl %r8d, 0x4(%rax,%rbp)
jne 0x37c5
movl (%rdi), %ebp
movl %esi, (%r15,%rbp,4)
movl %esi, (%r14,%r12,4)
jmp 0x37c5
addq $0x28, %rdi
jmp 0x378c
addq $0x4, %rax
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
cmpq %rcx, %r13
je 0x3821
cmpl $0x1, (%r15,%rcx,4)
jne 0x380b
movl (%rax), %edx
incl 0x44(%rsi,%rdx,4)
cmpl $0x1, (%r14,%rcx,4)
jne 0x3818
movl (%rax), %edx
incl 0x68(%rsi,%rdx,4)
incq %rcx
addq $0x28, %rax
jmp 0x37f9
movq %r14, %rdi
callq 0x2240
movq %r15, %rdi
callq 0x2240
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x3856
jmp 0x385d
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x2110
jmp 0x3860
movq %rax, %rbx
movq %rbx, %rdi
callq 0x22d0