// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movw %dx, %ax
movb %sil, %cl
movq %rdi, -0x8(%rbp)
movb %cl, -0x9(%rbp)
movw %ax, -0xc(%rbp)
movl $0x2, %edi
callq 0x8760
movq 0x17fd3(%rip), %rax     # 0x1b3c0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
leaq 0x17fbd(%rip), %rax     # 0x1b3c0
cmpq %rax, -0x18(%rbp)
je 0x34f9
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x34df
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %edi
leaq -0x40(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movzbl 0x34(%rax), %ecx
movzbl -0x9(%rbp), %r8d
movl $0x3, %edi
leaq 0x11693(%rip), %rsi     # 0x14af3
movb $0x0, %al
callq 0x123f0
movzbl -0x9(%rbp), %eax
cmpl $0x0, %eax
jne 0x34b7
callq 0xf260
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movb -0x9(%rbp), %cl
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movb %cl, 0x34(%rax)
leaq -0x40(%rbp), %rdx
movl $0x3, %edi
leaq 0x1168d(%rip), %rsi     # 0x14b29
movb $0x0, %al
callq 0x123f0
movq -0x28(%rbp), %rax
cmpq 0x17eb2(%rip), %rax     # 0x1b360
jne 0x34b5
callq 0x2c70
jmp 0x34d0
movq -0x28(%rbp), %rax
movl $0x0, 0x18(%rax)
movb -0x9(%rbp), %cl
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movb %cl, 0x34(%rax)
movl $0x2, %edi
callq 0x8790
jmp 0x3648
jmp 0x34e1
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x33fc
movq -0x8(%rbp), %rax
movl (%rax), %edi
leaq -0x40(%rbp), %rsi
movl $0x10, %edx
callq 0xfa90
leaq -0x44(%rbp), %rsi
leaq -0x48(%rbp), %rdx
movzbl -0x9(%rbp), %edi
callq 0x3030
leaq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movzbl -0x9(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x800, -0x44(%rbp)     # imm = 0x800
jle 0x3546
movl -0x44(%rbp), %eax
movl $0x400, %ecx            # imm = 0x400
cltd
idivl %ecx
movl %eax, -0x5c(%rbp)
jmp 0x354c
movl -0x44(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x44(%rbp), %edx
leaq 0x11627(%rip), %rax     # 0x14b83
leaq 0x1161b(%rip), %rcx     # 0x14b7e
cmpl $0x800, %edx            # imm = 0x800
cmovgq %rcx, %rax
movq %rax, -0x68(%rbp)
cmpl $0x800, -0x48(%rbp)     # imm = 0x800
jle 0x358a
movl -0x48(%rbp), %eax
movl $0x400, %ecx            # imm = 0x400
cltd
idivl %ecx
movl %eax, -0x70(%rbp)
jmp 0x3590
movl -0x48(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x68(%rbp), %r9
movl -0x6c(%rbp), %r8d
movl -0x4c(%rbp), %ecx
movq -0x58(%rbp), %rdx
movl -0x70(%rbp), %r10d
movl -0x48(%rbp), %edi
leaq 0x115d6(%rip), %rax     # 0x14b83
leaq 0x115ca(%rip), %rsi     # 0x14b7e
cmpl $0x800, %edi            # imm = 0x800
cmovgq %rsi, %rax
movl $0x3, %edi
leaq 0x11585(%rip), %rsi     # 0x14b4f
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x123f0
movl $0x20, %edi
movl $0x67, %esi
callq 0x7220
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x21e0
movq -0x28(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movw -0xc(%rbp), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x10(%rax)
callq 0xf260
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x28(%rbp), %rdi
leaq 0x17d87(%rip), %rsi     # 0x1b3c0
callq 0x6e60
movl $0x2, %edi
callq 0x8790
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)