#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 /*<<< orphan*/ snprintf(char *, int, char *, char *);
char *strchr(char *, char);
void _parse_hostport(char *s, char *host, char *port) {
  char *p;
  if (s)
    snprintf(host, 64, "%s", s);
  else
    snprintf(host, 64, "%s", "localhost");
  if ((p = strchr(host, ':'))) {
    *p++ = '\0';
    snprintf(port, 64, "%s", p);
  } else
    snprintf(port, 64, "%s", "10101");
}


x86 assembly (clang, -O0):
<_parse_hostport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     115d <_parse_hostport+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x40,%esi
lea    0xead(%rip),%rdx
call   1040 <snprintf@plt>
jmp    1179 <_parse_hostport+0x59>
mov    -0x10(%rbp),%rdi
mov    $0x40,%esi
lea    0xe93(%rip),%rdx
lea    0xe8f(%rip),%rcx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c5 <_parse_hostport+0xa5>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x40,%esi
lea    0xe45(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11e1 <_parse_hostport+0xc1>
mov    -0x18(%rbp),%rdi
mov    $0x40,%esi
lea    0xe2b(%rip),%rdx
lea    0xe31(%rip),%rcx
call   1040 <snprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_parse_hostport>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
test   %rdi,%rdi
je     113b <_parse_hostport+0x1b>
mov    %rdi,%rcx
lea    0xec7(%rip),%rdx
jmp    1149 <_parse_hostport+0x29>
lea    0xebe(%rip),%rdx
lea    0xeba(%rip),%rcx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117b <_parse_hostport+0x5b>
mov    %rax,%rcx
add    $0x1,%rcx
movb   $0x0,(%rax)
lea    0xe87(%rip),%rdx
jmp    1189 <_parse_hostport+0x69>
lea    0xe7e(%rip),%rdx
lea    0xe84(%rip),%rcx
mov    %r14,%rdi
mov    $0x40,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <snprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"localhost\00"
@.str.2 = [6 x i8] c"10101\00"
define void @_parse_hostport(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8*, i8** %4
%13 = call i32 @snprintf(i8* %11, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %17
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = call i32 @snprintf(i8* %15, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %14, %10
%18 = load i8*, i8** %5
%19 = call i8* @strchr(i8* %18, i8 signext 58)
store i8* %19, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %7
store i8 0, i8* %22
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 @snprintf(i8* %24, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %30
27: ; preds = %17
%28 = load i8*, i8** %6
%29 = call i32 @snprintf(i8* %28, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %27, %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"localhost\00"
@.str.2 = [6 x i8] c"10101\00"
define void @_parse_hostport(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @snprintf(i8* %1, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
7: ; preds = %3
%8 = tail call i32 @snprintf(i8* %1, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 58)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
store i8 0, i8* %10
%14 = tail call i32 @snprintf(i8* %2, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %9
%16 = tail call i32 @snprintf(i8* %2, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
ret void
}