// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/batman.c
// Function: update_gw_list
void update_gw_list(struct orig_node *orig_node, uint8_t new_gwflags, uint16_t gw_port)
{
	struct list_head *gw_pos, *gw_pos_tmp;
	struct gw_node *gw_node;
	char orig_str[ADDR_STR_LEN];
	int download_speed, upload_speed;
	prof_start( PROF_update_gw_list );

	list_for_each_safe( gw_pos, gw_pos_tmp, &gw_list ) {

		gw_node = list_entry(gw_pos, struct gw_node, list);

		if ( gw_node->orig_node == orig_node ) {

			addr_to_string( gw_node->orig_node->orig, orig_str, ADDR_STR_LEN );
			debug_output( 3, "Gateway class of originator %s changed from %i to %i\n", orig_str, gw_node->orig_node->gwflags, new_gwflags );

			if ( new_gwflags == 0 ) {

				gw_node->deleted = get_time_msec();
				gw_node->orig_node->gwflags = new_gwflags;
				debug_output( 3, "Gateway %s removed from gateway list\n", orig_str );

				if (gw_node == curr_gateway)
					choose_gw();

			} else {

				gw_node->deleted = 0;
				gw_node->orig_node->gwflags = new_gwflags;

			}

			prof_stop( PROF_update_gw_list );
			return;

		}

	}

	addr_to_string( orig_node->orig, orig_str, ADDR_STR_LEN );
	get_gw_speeds( new_gwflags, &download_speed, &upload_speed );

	debug_output( 3, "Found new gateway %s -> class: %i - %i%s/%i%s\n", orig_str, new_gwflags, ( download_speed > 2048 ? download_speed / 1024 : download_speed ), ( download_speed > 2048 ? "MBit" : "KBit" ), ( upload_speed > 2048 ? upload_speed / 1024 : upload_speed ), ( upload_speed > 2048 ? "MBit" : "KBit" ) );

	gw_node = debugMalloc(sizeof(struct gw_node), 103);
	memset(gw_node, 0, sizeof(struct gw_node));
	INIT_LIST_HEAD( &gw_node->list );

	gw_node->orig_node = orig_node;
	gw_node->gw_port = gw_port;
	gw_node->last_failure = get_time_msec();

	list_add_tail( &gw_node->list, &gw_list );

	prof_stop( PROF_update_gw_list );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movl $0x2, %edi
callq 0x6bbc
leaq 0x140a3(%rip), %rax     # 0x17320
movq %rax, %r15
movq (%r15), %r15
cmpq %rax, %r15
je 0x32e6
movq 0x8(%r15), %rcx
cmpq %r14, %rcx
jne 0x3280
movl (%rcx), %edi
movq %rsp, %rbx
movq %rbx, %rsi
movl $0x10, %edx
callq 0xbbac
movq 0x8(%r15), %rax
movzbl 0x34(%rax), %ecx
movzbl %bpl, %r14d
leaq 0xc83d(%rip), %rsi      # 0xfaf3
movl $0x3, %edi
movq %rbx, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xd88c
testb %r14b, %r14b
je 0x33d8
movl $0x0, 0x18(%r15)
movq 0x8(%r15), %rax
movb %bpl, 0x34(%rax)
jmp 0x33c3
movl (%r14), %edi
movq %rsp, %r15
movq %r15, %rsi
movl $0x10, %edx
callq 0xbbac
movl %ebp, %ecx
shrb $0x3, %cl
andb $0xf, %cl
movl %ebp, %edx
andb $0x7, %dl
movzbl %bpl, %eax
shrb $0x2, %bpl
andb $0x20, %bpl
orb $0x40, %bpl
movzbl %bpl, %esi
shll %cl, %esi
incb %dl
movzbl %dl, %r10d
imull %esi, %r10d
movl %esi, %r8d
shrl $0xa, %r8d
cmpl $0x801, %esi            # imm = 0x801
cmovbl %esi, %r8d
leaq 0xc840(%rip), %rdx      # 0xfb7e
leaq 0xc83e(%rip), %r11      # 0xfb83
movq %r11, %r9
cmovaeq %rdx, %r9
cmpl $0x4001, %r10d          # imm = 0x4001
movl $0xd, %ecx
movl $0x3, %esi
cmovbl %esi, %ecx
cmovaeq %rdx, %r11
shrl %cl, %r10d
leaq 0xc7e1(%rip), %rsi      # 0xfb4f
movl $0x3, %edi
movq %r15, %rdx
movl %eax, %ecx
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0xd88c
addq $0x10, %rsp
movl $0x20, %edi
movl $0x67, %esi
callq 0x5d52
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %rax, (%rax)
movq %r14, 0x8(%rax)
movw %bx, 0x10(%rax)
callq 0xb3f0
movl %eax, 0x14(%r15)
leaq 0x13f65(%rip), %rsi     # 0x17320
movq %r15, %rdi
callq 0x5bcd
movl $0x2, %edi
callq 0x6bd8
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0xb3f0
movl %eax, 0x18(%r15)
movq 0x8(%r15), %rax
movb $0x0, 0x34(%rax)
leaq 0xc739(%rip), %rsi      # 0xfb29
movq %rsp, %rdx
movl $0x3, %edi
xorl %eax, %eax
callq 0xd88c
cmpq 0x13eba(%rip), %r15     # 0x172c0
jne 0x33c3
callq 0x2d46
jmp 0x33c3