#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
void hostport_param(char *param, char **host, char **port) {
  if (param && *param) {
    if (*param != ':') {
      *host = param;
      if (*param == '[') {
        (*host)++;
        param = strchr(param, ']');
        if (param) {
          *param++ = '\0';
        } else {
          fprintf(stderr, "Malformed Ipv6 address!\n");
          exit(1);
        }
      }
    }
    param = strchr(param, ':');
    if (param) {
      *param++ = '\0';
      *port = param;
    }
  }
}


x86 assembly (clang, -O0):
<hostport_param>:
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     1234 <hostport_param+0x104>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1234 <hostport_param+0x104>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     11f5 <hostport_param+0xc5>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    11f0 <hostport_param+0xc0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11cc <hostport_param+0x9c>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
jmp    11eb <hostport_param+0xbb>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11f0 <hostport_param+0xc0>
jmp    11f5 <hostport_param+0xc5>
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     122f <hostport_param+0xff>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1234 <hostport_param+0x104>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hostport_param>:
push   %rbx
test   %rdi,%rdi
je     1187 <hostport_param+0x57>
mov    (%rdi),%al
test   %al,%al
je     1187 <hostport_param+0x57>
mov    %rdx,%rbx
cmp    $0x3a,%al
je     116b <hostport_param+0x3b>
mov    %rdi,(%rsi)
cmpb   $0x5b,(%rdi)
jne    116b <hostport_param+0x3b>
lea    0x1(%rdi),%rax
mov    %rax,(%rsi)
mov    $0x5d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1189 <hostport_param+0x59>
mov    %rax,%rdi
add    $0x1,%rdi
movb   $0x0,(%rax)
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1187 <hostport_param+0x57>
mov    %rax,%rcx
add    $0x1,%rcx
movb   $0x0,(%rax)
mov    %rcx,(%rbx)
pop    %rbx
ret
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Malformed Ipv6 address!\0A\00"
define void @hostport_param(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %54
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %54
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 58
br i1 %18, label %19, label %43
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8**, i8*** %5
store i8* %20, i8** %21
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 91
br i1 %25, label %26, label %42
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %27
%30 = load i8*, i8** %4
%31 = call i8* @strchr(i8* %30, i8 signext 93)
store i8* %31, i8** %4
%32 = load i8*, i8** %4
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %26
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
store i8 0, i8* %35
br label %41
37: ; preds = %26
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %34
br label %42
42: ; preds = %41, %19
br label %43
43: ; preds = %42, %14
%44 = load i8*, i8** %4
%45 = call i8* @strchr(i8* %44, i8 signext 58)
store i8* %45, i8** %4
%46 = load i8*, i8** %4
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %4
store i8 0, i8* %49
%51 = load i8*, i8** %4
%52 = load i8**, i8*** %6
store i8* %51, i8** %52
br label %53
53: ; preds = %48, %43
br label %54
54: ; preds = %53, %9, %3
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Malformed Ipv6 address!\0A\00"
define void @hostport_param(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %26, label %5
5: ; preds = %3
%6 = load i8, i8* %0
switch i8 %6, label %7 [
i8 0, label %26
i8 58, label %20
]
7: ; preds = %5
store i8* %0, i8** %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 91
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %11, i8** %1
%12 = tail call i8* @strchr(i8* %0, i8 signext 93)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %12, i64 1
store i8 0, i8* %12
br label %20
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %5, %7, %14
%21 = phi i8* [ %15, %14 ], [ %0, %7 ], [ %0, %5 ]
%22 = tail call i8* @strchr(i8* %21, i8 signext 58)
%23 = icmp eq i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %22, i64 1
store i8 0, i8* %22
store i8* %25, i8** %2
br label %26
26: ; preds = %5, %20, %24, %3
ret void
}