#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char *get_ip_from_hostname(char *);
unsigned int get_servers_amount(char **);
char **get_servers_hosts(char **, unsigned int);
int *get_servers_ports(char **, unsigned int);
scalar_t__ is_ip(char *);
int /*<<< orphan*/ listen_udp_packet(char *, unsigned int *, int);
int /*<<< orphan*/ send_udp_packet(char *, int, char *, unsigned int, int);
void run_dispatcher(char **servers_list, int socket_) {
  char message[65507];
  unsigned int message_length;
  unsigned int servers_amount = get_servers_amount(servers_list);
  char **servers_hosts = get_servers_hosts(servers_list, servers_amount);
  int *servers_ports = get_servers_ports(servers_list, servers_amount);
  unsigned int i;
  for (i = 0; i < servers_amount; i++) {
    if (is_ip(servers_hosts[i]) == 0) {
      servers_hosts[i] = get_ip_from_hostname(servers_hosts[i]);
    }
  }
  while (1) {
    for (i = 0; i < servers_amount; i++) {
      listen_udp_packet(message, &message_length, socket_);
      send_udp_packet(servers_hosts[i], servers_ports[i], message,
                      message_length, socket_);
    }
  }
}


x86 assembly (clang, -O0):
<run_dispatcher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10010,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <get_servers_amount@plt>
mov    %eax,-0xfff8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xfff8(%rbp),%esi
call   1050 <get_servers_hosts@plt>
mov    %rax,-0x10000(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xfff8(%rbp),%esi
call   1060 <get_servers_ports@plt>
mov    %rax,-0x10008(%rbp)
movl   $0x0,-0x1000c(%rbp)
mov    -0x1000c(%rbp),%eax
cmp    -0xfff8(%rbp),%eax
jae    123c <run_dispatcher+0xcc>
mov    -0x10000(%rbp),%rax
mov    -0x1000c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1040 <is_ip@plt>
cmp    $0x0,%rax
jne    1223 <run_dispatcher+0xb3>
mov    -0x10000(%rbp),%rax
mov    -0x1000c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1070 <get_ip_from_hostname@plt>
mov    %rax,%rdx
mov    -0x10000(%rbp),%rax
mov    -0x1000c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
jmp    1228 <run_dispatcher+0xb8>
mov    -0x1000c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1000c(%rbp)
jmp    11c7 <run_dispatcher+0x57>
jmp    1241 <run_dispatcher+0xd1>
movl   $0x0,-0x1000c(%rbp)
mov    -0x1000c(%rbp),%eax
cmp    -0xfff8(%rbp),%eax
jae    12be <run_dispatcher+0x14e>
lea    -0xfff0(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0xfff4(%rbp),%rsi
call   1090 <listen_udp_packet@plt>
mov    -0x10000(%rbp),%rax
mov    -0x1000c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x10008(%rbp),%rax
mov    -0x1000c(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    -0xfff0(%rbp),%rdx
mov    -0xfff4(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1030 <send_udp_packet@plt>
mov    -0x1000c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1000c(%rbp)
jmp    124b <run_dispatcher+0xdb>
jmp    1241 <run_dispatcher+0xd1>

x86 assembly (clang, -O2):
<run_dispatcher>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfff8,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
call   1080 <get_servers_amount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <get_servers_hosts@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %ebp,%esi
call   1060 <get_servers_ports@plt>
mov    %rax,%r12
mov    %ebp,%r14d
mov    %ebp,(%rsp)
test   %ebp,%ebp
je     11e6 <run_dispatcher+0x76>
xor    %ebp,%ebp
jmp    11c9 <run_dispatcher+0x59>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
cmp    %rbp,%r14
je     11e6 <run_dispatcher+0x76>
mov    (%r15,%rbp,8),%rdi
call   1040 <is_ip@plt>
test   %rax,%rax
jne    11c0 <run_dispatcher+0x50>
mov    (%r15,%rbp,8),%rdi
call   1070 <get_ip_from_hostname@plt>
mov    %rax,(%r15,%rbp,8)
jmp    11c0 <run_dispatcher+0x50>
lea    0x10(%rsp),%rbp
mov    %r12,0x8(%rsp)
mov    %r15,%r12
lea    0x4(%rsp),%r15
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,(%rsp)
je     1200 <run_dispatcher+0x90>
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1090 <listen_udp_packet@plt>
mov    (%r12,%r13,8),%rdi
mov    0x8(%rsp),%rax
mov    (%rax,%r13,4),%esi
mov    0x4(%rsp),%ecx
mov    %rbp,%rdx
mov    %ebx,%r8d
call   1030 <send_udp_packet@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1210 <run_dispatcher+0xa0>
jmp    1200 <run_dispatcher+0x90>

LLVM IR (-O0):
define void @run_dispatcher(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca [65507 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%11 = load i8**, i8*** %3
%12 = call i32 @get_servers_amount(i8** %11)
store i32 %12, i32* %7
%13 = load i8**, i8*** %3
%14 = load i32, i32* %7
%15 = call i8** @get_servers_hosts(i8** %13, i32 %14)
store i8** %15, i8*** %8
%16 = load i8**, i8*** %3
%17 = load i32, i32* %7
%18 = call i32* @get_servers_ports(i8** %16, i32 %17)
store i32* %18, i32** %9
store i32 0, i32* %10
br label %19
19: ; preds = %43, %2
%20 = load i32, i32* %10
%21 = load i32, i32* %7
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %46
23: ; preds = %19
%24 = load i8**, i8*** %8
%25 = load i32, i32* %10
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @is_ip(i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %42
31: ; preds = %23
%32 = load i8**, i8*** %8
%33 = load i32, i32* %10
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i8* @get_ip_from_hostname(i8* %36)
%38 = load i8**, i8*** %8
%39 = load i32, i32* %10
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
store i8* %37, i8** %41
br label %42
42: ; preds = %31, %23
br label %43
43: ; preds = %42
%44 = load i32, i32* %10
%45 = add i32 %44, 1
store i32 %45, i32* %10
br label %19
46: ; preds = %19
br label %47
47: ; preds = %46, %73
store i32 0, i32* %10
br label %48
48: ; preds = %70, %47
%49 = load i32, i32* %10
%50 = load i32, i32* %7
%51 = icmp ult i32 %49, %50
br i1 %51, label %52, label %73
52: ; preds = %48
%53 = getelementptr inbounds [65507 x i8], [65507 x i8]* %5, i64 0, i64 0
%54 = load i32, i32* %4
%55 = call i32 @listen_udp_packet(i8* %53, i32* %6, i32 %54)
%56 = load i8**, i8*** %8
%57 = load i32, i32* %10
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = load i32*, i32** %9
%62 = load i32, i32* %10
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = load i32, i32* %64
%66 = getelementptr inbounds [65507 x i8], [65507 x i8]* %5, i64 0, i64 0
%67 = load i32, i32* %6
%68 = load i32, i32* %4
%69 = call i32 @send_udp_packet(i8* %60, i32 %65, i8* %66, i32 %67, i32 %68)
br label %70
70: ; preds = %52
%71 = load i32, i32* %10
%72 = add i32 %71, 1
store i32 %72, i32* %10
br label %48
73: ; preds = %48
br label %47
}

LLVM IR (-O2):
define void @run_dispatcher(i8** %0, i32 %1) {
%3 = alloca [65507 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [65507 x i8], [65507 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @get_servers_amount(i8** %0)
%8 = tail call i8** @get_servers_hosts(i8** %0, i32 %7)
%9 = tail call i32* @get_servers_ports(i8** %0, i32 %7)
%10 = icmp eq i32 %7, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = zext i32 %7 to i64
br label %15
13: ; preds = %24, %2
%14 = zext i32 %7 to i64
br label %27
15: ; preds = %11, %24
%16 = phi i64 [ 0, %11 ], [ %25, %24 ]
%17 = getelementptr inbounds i8*, i8** %8, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @is_ip(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %17
%23 = tail call i8* @get_ip_from_hostname(i8* %22)
store i8* %23, i8** %17
br label %24
24: ; preds = %15, %21
%25 = add nuw nsw i64 %16, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %13, label %15
27: ; preds = %28, %13
br i1 %10, label %28, label %29
28: ; preds = %29, %27
br label %27
29: ; preds = %27, %29
%30 = phi i64 [ %38, %29 ], [ 0, %27 ]
%31 = call i32 @listen_udp_packet(i8* %5, i32* %4, i32 %1)
%32 = getelementptr inbounds i8*, i8** %8, i64 %30
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i32, i32* %9, i64 %30
%35 = load i32, i32* %34
%36 = load i32, i32* %4
%37 = call i32 @send_udp_packet(i8* %33, i32 %35, i8* %5, i32 %36, i32 %1)
%38 = add nuw nsw i64 %30, 1
%39 = icmp eq i64 %38, %14
br i1 %39, label %28, label %29
}