// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
pushq $0x2
popq %rdi
callq 0x63a8
leaq 0x141c7(%rip), %rax     # 0x17320
movq %rax, %r15
movq (%r15), %r15
cmpq %rax, %r15
je 0x31bd
movq 0x8(%r15), %rcx
cmpq %r14, %rcx
jne 0x315c
movl (%rcx), %edi
leaq 0x10(%rsp), %rbx
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0xb04f
movq 0x8(%r15), %rax
movzbl 0x34(%rax), %ecx
movzbl %bpl, %r14d
leaq 0xb961(%rip), %rsi      # 0xeaf3
pushq $0x3
popq %rdi
movq %rbx, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xcb1c
testb %r14b, %r14b
je 0x3296
andl $0x0, 0x18(%r15)
movq 0x8(%r15), %rax
movb %bpl, 0x34(%rax)
jmp 0x327f
movl (%r14), %edi
leaq 0x10(%rsp), %r15
pushq $0x10
popq %rdx
movq %r15, %rsi
callq 0xb04f
movzbl %bpl, %ebp
leaq 0xc(%rsp), %r12
leaq 0x8(%rsp), %r13
movl %ebp, %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2ef8
movl (%r12), %eax
movl %eax, %r8d
shrl $0xa, %r8d
movl $0x801, %ecx            # imm = 0x801
cmpl %ecx, %eax
cmovll %eax, %r8d
leaq 0xb976(%rip), %rax      # 0xeb7e
leaq 0xb974(%rip), %r10      # 0xeb83
movq %r10, %r9
cmovgeq %rax, %r9
movl (%r13), %edx
movl %edx, %r11d
shrl $0xa, %r11d
cmpl %ecx, %edx
cmovll %edx, %r11d
cmovgeq %rax, %r10
leaq 0xb91d(%rip), %rsi      # 0xeb4f
pushq $0x3
popq %rdi
movq %r15, %rdx
movl %ebp, %ecx
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0xcb1c
popq %rax
popq %rcx
pushq $0x20
popq %rdi
pushq $0x67
popq %rsi
callq 0x58c9
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %rax, (%rax)
movq %r14, 0x8(%rax)
movw %bx, 0x10(%rax)
callq 0xa9e4
movl %eax, 0x14(%r15)
leaq 0x140a9(%rip), %rsi     # 0x17320
movq %r15, %rdi
callq 0x574d
pushq $0x2
popq %rdi
callq 0x63c4
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xa9e4
movl %eax, 0x18(%r15)
movq 0x8(%r15), %rax
movb $0x0, 0x34(%rax)
leaq 0xb87b(%rip), %rsi      # 0xeb29
pushq $0x3
popq %rdi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xcb1c
cmpq 0x13ffc(%rip), %r15     # 0x172c0
jne 0x327f
callq 0x2bd6
jmp 0x327f