#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 **malloc(int);
char *strdup(char *);
char *strsep(char **, char *);
char **get_servers_hosts(char **servers_list, int servers_amount) {
  char *server_raw, *server_host, serve;
  char **servers_hosts = malloc(1024 * sizeof(char *));
  unsigned int i;
  for (i = 0; i < servers_amount; i++) {
    server_raw = strdup(servers_list[i]);
    server_host = strsep(&server_raw, ":");
    servers_hosts[i] = server_host;
  }
  return servers_hosts;
}


x86 assembly (clang, -O0):
<get_servers_hosts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x2000,%edi
call   1030 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a5 <get_servers_hosts+0x75>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1154 <get_servers_hosts+0x24>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_servers_hosts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0x2000,%edi
call   1030 <malloc@plt>
mov    %rax,%r13
test   %ebp,%ebp
je     1186 <get_servers_hosts+0x56>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xea4(%rip),%r15
mov    %rsp,%r12
nop
mov    (%r14,%rbx,8),%rdi
call   1050 <strdup@plt>
mov    %rax,(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strsep@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <get_servers_hosts+0x30>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define i8** @get_servers_hosts(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8**
%9 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%10 = call i8** @malloc(i32 8192)
store i8** %10, i8*** %8
store i32 0, i32* %9
br label %11
11: ; preds = %28, %2
%12 = load i32, i32* %9
%13 = load i32, i32* %4
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load i8**, i8*** %3
%17 = load i32, i32* %9
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i8* @strdup(i8* %20)
store i8* %21, i8** %5
%22 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = load i8**, i8*** %8
%25 = load i32, i32* %9
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
store i8* %23, i8** %27
br label %28
28: ; preds = %15
%29 = load i32, i32* %9
%30 = add i32 %29, 1
store i32 %30, i32* %9
br label %11
31: ; preds = %11
%32 = load i8**, i8*** %8
ret i8** %32
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define noalias i8** @get_servers_hosts(i8** nocapture %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8** @malloc(i32 8192)
%6 = icmp eq i32 %1, 0
br i1 %6, label %18, label %7
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %16, %9 ]
%11 = getelementptr inbounds i8*, i8** %0, i64 %10
%12 = load i8*, i8** %11
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %3
%14 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %5, i64 %10
store i8* %14, i8** %15
%16 = add nuw nsw i64 %10, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %18, label %9
18: ; preds = %9, %2
ret i8** %5
}