#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 */
int atoi(char *);
int /*<<< orphan*/ memcpy(void *, void const *, size_t);
char *trim(char *, char);
char *conn_insert_resp_parser(char *result, char *rg_ip, int rg_port) {
  int addr_idx;
  char port_addr[16];
  addr_idx = 0;
  result = trim(result, ' ');
  while (result[addr_idx++] != ':')
    ;
  memcpy((void *)(rg_ip), (const void *)(result), (size_t)((addr_idx - 1)));
  result = &(result[addr_idx]);
  result = trim(result, ' ');
  addr_idx = 0;
  while (result[addr_idx] != ':') {
    port_addr[addr_idx] = result[addr_idx];
    addr_idx++;
  }
  port_addr[addr_idx] = '\0';
  rg_port = atoi(port_addr);
  result = &(result[addr_idx++]);
  result = trim(result, ' ');
  return result;
}


x86 assembly (clang, -O0):
<conn_insert_resp_parser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <trim@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     1180 <conn_insert_resp_parser+0x50>
jmp    115c <conn_insert_resp_parser+0x2c>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rdx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <trim@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     11f4 <conn_insert_resp_parser+0xc4>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11be <conn_insert_resp_parser+0x8e>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <trim@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conn_insert_resp_parser>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    $0x20,%esi
call   1030 <trim@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x3a,(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1140 <conn_insert_resp_parser+0x20>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <memcpy@plt>
mov    %ebx,%eax
add    %rax,%r15
mov    %r15,%rdi
mov    $0x20,%esi
call   1030 <trim@plt>
mov    $0xffffffffffffffff,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x3a,0x1(%rax,%rcx,1)
lea    0x1(%rcx),%rcx
jne    1180 <conn_insert_resp_parser+0x60>
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,%rdi
mov    $0x20,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <trim@plt>

LLVM IR (-O0):
define i8* @conn_insert_resp_parser(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [16 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%9 = load i8*, i8** %4
%10 = call i8* @trim(i8* %9, i8 signext 32)
store i8* %10, i8** %4
br label %11
11: ; preds = %20, %3
%12 = load i8*, i8** %4
%13 = load i32, i32* %7
%14 = add nsw i32 %13, 1
store i32 %14, i32* %7
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 58
br i1 %19, label %20, label %21
20: ; preds = %11
br label %11
21: ; preds = %11
%22 = load i8*, i8** %5
%23 = load i8*, i8** %4
%24 = load i32, i32* %7
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = call i32 @memcpy(i8* %22, i8* %23, i64 %26)
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8* %31, i8** %4
%32 = load i8*, i8** %4
%33 = call i8* @trim(i8* %32, i8 signext 32)
store i8* %33, i8** %4
store i32 0, i32* %7
br label %34
34: ; preds = %42, %21
%35 = load i8*, i8** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 58
br i1 %41, label %42, label %53
42: ; preds = %34
%43 = load i8*, i8** %4
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %49
store i8 %47, i8* %50
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %34
53: ; preds = %34
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %55
store i8 0, i8* %56
%57 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%58 = call i32 @atoi(i8* %57)
store i32 %58, i32* %6
%59 = load i8*, i8** %4
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i8, i8* %59, i64 %62
store i8* %63, i8** %4
%64 = load i8*, i8** %4
%65 = call i8* @trim(i8* %64, i8 signext 32)
store i8* %65, i8** %4
%66 = load i8*, i8** %4
ret i8* %66
}

LLVM IR (-O2):
define i8* @conn_insert_resp_parser(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @trim(i8* %0, i8 signext 32)
br label %5
5: ; preds = %5, %3
%6 = phi i64 [ %7, %5 ], [ 0, %3 ]
%7 = add nuw i64 %6, 1
%8 = getelementptr inbounds i8, i8* %4, i64 %6
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 58
br i1 %10, label %11, label %5
11: ; preds = %5
%12 = and i64 %6, 4294967295
%13 = tail call i32 @memcpy(i8* %1, i8* %4, i64 %12)
%14 = and i64 %7, 4294967295
%15 = getelementptr inbounds i8, i8* %4, i64 %14
%16 = tail call i8* @trim(i8* %15, i8 signext 32)
br label %17
17: ; preds = %17, %11
%18 = phi i64 [ %22, %17 ], [ 0, %11 ]
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 58
%22 = add nuw i64 %18, 1
br i1 %21, label %23, label %17
23: ; preds = %17
%24 = and i64 %18, 4294967295
%25 = getelementptr inbounds i8, i8* %16, i64 %24
%26 = tail call i8* @trim(i8* %25, i8 signext 32)
ret i8* %26
}