#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*/ sscanf(char *, char *, int *);
void ParseAddr(char *hostname, int *port, int def, char *addr) {
  char *s, *t;
  *port = def;
  hostname[0] = 0;
  s = hostname;
  t = addr;
  while (*t != 0 && *t != ':')
    *s++ = *t++;
  *s = 0;
  if (*t == ':')
    sscanf(t + 1, "%d", port);
}


x86 assembly (clang, -O0):
<ParseAddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     116c <ParseAddr+0x5c>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    117c <ParseAddr+0x6c>
jmp    11a3 <ParseAddr+0x93>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    1147 <ParseAddr+0x37>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    11d2 <ParseAddr+0xc2>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rdx
lea    0xe33(%rip),%rsi
call   1030 <sscanf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseAddr>:
mov    %rsi,%rax
mov    %edx,(%rsi)
movb   $0x0,(%rdi)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
movzbl -0x1(%rcx),%edx
test   %dl,%dl
je     1139 <ParseAddr+0x29>
cmp    $0x3a,%dl
je     1139 <ParseAddr+0x29>
mov    %dl,(%rdi)
add    $0x1,%rdi
jmp    1120 <ParseAddr+0x10>
movb   $0x0,(%rdi)
cmpb   $0x3a,-0x1(%rcx)
jne    1154 <ParseAddr+0x44>
lea    0xeb7(%rip),%rsi
mov    %rcx,%rdi
mov    %rax,%rdx
jmp    1030 <sscanf@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @ParseAddr(i8* %0, i32* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i32, i32* %7
%12 = load i32*, i32** %6
store i32 %11, i32* %12
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 0
store i8 0, i8* %14
%15 = load i8*, i8** %5
store i8* %15, i8** %9
%16 = load i8*, i8** %8
store i8* %16, i8** %10
br label %17
17: ; preds = %29, %4
%18 = load i8*, i8** %10
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %10
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 58
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ false, %17 ], [ %26, %22 ]
br i1 %28, label %29, label %35
29: ; preds = %27
%30 = load i8*, i8** %10
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %10
%32 = load i8, i8* %30
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %9
store i8 %32, i8* %33
br label %17
35: ; preds = %27
%36 = load i8*, i8** %9
store i8 0, i8* %36
%37 = load i8*, i8** %10
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 58
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = load i8*, i8** %10
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i32*, i32** %6
%45 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %44)
br label %46
46: ; preds = %41, %35
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @ParseAddr(i8* nocapture writeonly %0, i32* %1, i32 %2, i8* nocapture %3) {
store i32 %2, i32* %1
store i8 0, i8* %0
br label %5
5: ; preds = %9, %4
%6 = phi i8* [ %0, %4 ], [ %11, %9 ]
%7 = phi i8* [ %3, %4 ], [ %10, %9 ]
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %12
i8 58, label %12
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %8, i8* %6
br label %5
12: ; preds = %5, %5
store i8 0, i8* %6
%13 = load i8, i8* %7
%14 = icmp eq i8 %13, 58
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %7, i64 1
%17 = tail call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %18
18: ; preds = %15, %12
ret void
}