#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 *);
char *strsep(char **, char *);
int ParseHostPort(char *address, char **host, int *port) {
  *host = strsep(&address, ":");
  if (*host == NULL)
    return -1;
  if (address == NULL)
    *port = 1863;
  else
    *port = atoi(address);
  return 0;
}


x86 assembly (clang, -O0):
<ParseHostPort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1030 <strsep@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1168 <ParseHostPort+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <ParseHostPort+0x7a>
cmpq   $0x0,-0x10(%rbp)
jne    1182 <ParseHostPort+0x62>
mov    -0x20(%rbp),%rax
movl   $0x747,(%rax)
jmp    1193 <ParseHostPort+0x73>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseHostPort>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,(%rsp)
lea    0xecb(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strsep@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1155 <ParseHostPort+0x35>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     115c <ParseHostPort+0x3c>
call   1040 <atoi@plt>
jmp    1161 <ParseHostPort+0x41>
mov    $0xffffffff,%eax
jmp    1166 <ParseHostPort+0x46>
mov    $0x747,%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define i32 @ParseHostPort(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%8 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i8**, i8*** %6
store i8* %8, i8** %9
%10 = load i8**, i8*** %6
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -1, i32* %4
br label %24
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = load i32*, i32** %7
store i32 1863, i32* %18
br label %23
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = call i32 @atoi(i8* %20)
%22 = load i32*, i32** %7
store i32 %21, i32* %22
br label %23
23: ; preds = %19, %17
store i32 0, i32* %4
br label %24
24: ; preds = %23, %13
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define i32 @ParseHostPort(i8* %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
store i8* %0, i8** %4
%5 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @atoi(i8* %8)
br label %12
12: ; preds = %7, %10
%13 = phi i32 [ %11, %10 ], [ 1863, %7 ]
store i32 %13, i32* %2
br label %14
14: ; preds = %3, %12
%15 = phi i32 [ 0, %12 ], [ -1, %3 ]
ret i32 %15
}