#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 */
scalar_t__ index(char *, char);
scalar_t__ rindex(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
void get_host_port(char *adr, char *host, char *port) {
  char *fp;
  char *fpx;
  char adr_field[50];
  strcpy(adr_field, adr);
  fp = (char *)rindex(adr_field, '.');
  *fp = '\0';
  strcpy(host, adr_field);
  fp++;
  fpx = (char *)index(fp, ':');
  if (fpx != NULL)
    *fpx = '\0';
  strcpy(port, fp);
}


x86 assembly (clang, -O0):
<get_host_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <rindex@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <index@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a7 <get_host_port+0x77>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_host_port>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %rsp,%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    $0x2e,%esi
call   1050 <rindex@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <index@plt>
test   %rax,%rax
je     1186 <get_host_port+0x56>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @get_host_port(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [50 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%14 = call i64 @rindex(i8* %13, i8 signext 46)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
%16 = load i8*, i8** %7
store i8 0, i8* %16
%17 = load i8*, i8** %5
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = call i64 @index(i8* %22, i8 signext 58)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %29
27: ; preds = %3
%28 = load i8*, i8** %8
store i8 0, i8* %28
br label %29
29: ; preds = %27, %3
%30 = load i8*, i8** %6
%31 = load i8*, i8** %7
%32 = call i32 @strcpy(i8* %30, i8* %31)
ret void
}

LLVM IR (-O2):
define void @get_host_port(i8* %0, i8* %1, i8* %2) {
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = call i64 @rindex(i8* %5, i8 signext 46)
%8 = inttoptr i64 %7 to i8*
store i8 0, i8* %8
%9 = call i32 @strcpy(i8* %1, i8* %5)
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = call i64 @index(i8* %10, i8 signext 58)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %3
%14 = inttoptr i64 %11 to i8*
store i8 0, i8* %14
br label %15
15: ; preds = %13, %3
%16 = call i32 @strcpy(i8* %2, i8* %10)
ret void
}