const char *GetParsedIP(const char *ipadd) {
  unsigned b1, b2, b3, b4, port = 0;
  unsigned char c;
  int rc;
  static char ipge[20];
  if (!Q_strncmp(ipadd, "localhost", 9)) {
    return "localhost";
  }
  rc = sscanf(ipadd, "%3u.%3u.%3u.%3u:%u%c", &b1, &b2, &b3, &b4, &port, &c);
  if (rc < 4 || rc > 5) {
    return ((void *)0);
  }
  if ((b1 | b2 | b3 | b4) > 255 || port > 65535) {
    return ((void *)0);
  }
  if (strspn(ipadd, "0123456789.:") < strlen(ipadd)) {
    return ((void *)0);
  }
  sprintf(ipge, "%u.%u.%u.%u", b1, b2, b3, b4);
  return ipge;
}


x86 assembly (clang, -O0):
<GetParsedIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x9,%edx
mov    $0x0,%al
call   1060 <Q_strncmp@plt>
cmp    $0x0,%eax
jne    1193 <GetParsedIP+0x43>
lea    0xe76(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1283 <GetParsedIP+0x133>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
lea    -0x24(%rbp),%r10
lea    -0x25(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jl     11dd <GetParsedIP+0x8d>
cmpl   $0x5,-0x2c(%rbp)
jle    11ea <GetParsedIP+0x9a>
movq   $0x0,-0x8(%rbp)
jmp    1283 <GetParsedIP+0x133>
mov    -0x14(%rbp),%eax
or     -0x18(%rbp),%eax
or     -0x1c(%rbp),%eax
or     -0x20(%rbp),%eax
cmp    $0xff,%eax
ja     120e <GetParsedIP+0xbe>
cmpl   $0xffff,-0x24(%rbp)
jbe    121b <GetParsedIP+0xcb>
movq   $0x0,-0x8(%rbp)
jmp    1283 <GetParsedIP+0x133>
mov    -0x10(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <strspn@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jae    1255 <GetParsedIP+0x105>
movq   $0x0,-0x8(%rbp)
jmp    1283 <GetParsedIP+0x133>
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
lea    0x2df6(%rip),%rdi
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    0x2de1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetParsedIP>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movl   $0x0,0x4(%rsp)
lea    0xe90(%rip),%rbx
mov    %rbx,%rsi
mov    $0x9,%edx
xor    %eax,%eax
call   1060 <Q_strncmp@plt>
test   %eax,%eax
je     1242 <GetParsedIP+0xf2>
lea    0x3(%rsp),%rbp
lea    0x4(%rsp),%r10
lea    0xe72(%rip),%rsi
xor    %ebx,%ebx
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %r14,%rdi
xor    %eax,%eax
push   %rbp
push   %r10
call   1050 <sscanf@plt>
add    $0x10,%rsp
add    $0xfffffffa,%eax
cmp    $0xfffffffe,%eax
jb     1242 <GetParsedIP+0xf2>
mov    0x14(%rsp),%r12d
mov    0x10(%rsp),%r15d
mov    %r15d,%eax
or     %r12d,%eax
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%r13d
mov    %ebp,%ecx
or     %r13d,%ecx
or     %eax,%ecx
xor    %ebx,%ebx
cmp    $0xff,%ecx
ja     1242 <GetParsedIP+0xf2>
cmpl   $0xffff,0x4(%rsp)
ja     1242 <GetParsedIP+0xf2>
lea    0xe1d(%rip),%rsi
mov    %r14,%rdi
call   1040 <strspn@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jae    121e <GetParsedIP+0xce>
xor    %ebx,%ebx
jmp    1242 <GetParsedIP+0xf2>
lea    0x2e3b(%rip),%rbx
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
mov    %r13d,%r9d
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GetParsedIP.ipge = internal global [20 x i8] zeroinitializer
@.str = [10 x i8] c"localhost\00"
@.str.1 = [21 x i8] c"%3u.%3u.%3u.%3u:%u%c\00"
@.str.2 = [13 x i8] c"0123456789.:\00"
@.str.3 = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @GetParsedIP(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %8
%11 = load i8*, i8** %3
%12 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Q_strncmp to i32 (i8*, i8*, i32, ...)*)(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
br label %50
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i8* %9)
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 4
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* %10
%22 = icmp sgt i32 %21, 5
br i1 %22, label %23, label %24
23: ; preds = %20, %15
store i8* null, i8** %2
br label %50
24: ; preds = %20
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = or i32 %25, %26
%28 = load i32, i32* %6
%29 = or i32 %27, %28
%30 = load i32, i32* %7
%31 = or i32 %29, %30
%32 = icmp ugt i32 %31, 255
br i1 %32, label %36, label %33
33: ; preds = %24
%34 = load i32, i32* %8
%35 = icmp ugt i32 %34, 65535
br i1 %35, label %36, label %37
36: ; preds = %33, %24
store i8* null, i8** %2
br label %50
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = call i64 @strspn(i8* %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%40 = load i8*, i8** %3
%41 = call i64 @strlen(i8* %40)
%42 = icmp ult i64 %39, %41
br i1 %42, label %43, label %44
43: ; preds = %37
store i8* null, i8** %2
br label %50
44: ; preds = %37
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @GetParsedIP.ipge, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %46, i32 %47, i32 %48)
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @GetParsedIP.ipge, i64 0, i64 0), i8** %2
br label %50
50: ; preds = %44, %43, %36, %23, %14
%51 = load i8*, i8** %2
ret i8* %51
}

LLVM IR (-O2):
@GetParsedIP.ipge = internal global [20 x i8] zeroinitializer
@.str = [10 x i8] c"localhost\00"
@.str.1 = [21 x i8] c"%3u.%3u.%3u.%3u:%u%c\00"
@.str.2 = [13 x i8] c"0123456789.:\00"
@.str.3 = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @GetParsedIP(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Q_strncmp to i32 (i8*, i8*, i32, ...)*)(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%14 = icmp eq i32 %13, 0
br i1 %14, label %37, label %15
15: ; preds = %1
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i8* %7)
%17 = add i32 %16, -6
%18 = icmp ult i32 %17, -2
br i1 %18, label %37, label %19
19: ; preds = %15
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = or i32 %21, %20
%23 = load i32, i32* %4
%24 = or i32 %22, %23
%25 = load i32, i32* %5
%26 = or i32 %24, %25
%27 = icmp ugt i32 %26, 255
%28 = load i32, i32* %6
%29 = icmp ugt i32 %28, 65535
%30 = select i1 %27, i1 true, i1 %29
br i1 %30, label %37, label %31
31: ; preds = %19
%32 = call i64 @strspn(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%33 = call i64 @strlen(i8* dereferenceable(1) %0)
%34 = icmp ult i64 %32, %33
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @GetParsedIP.ipge, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 %21, i32 %23, i32 %25)
br label %37
37: ; preds = %31, %19, %15, %1, %35
%38 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @GetParsedIP.ipge, i64 0, i64 0), %35 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %1 ], [ null, %15 ], [ null, %19 ], [ null, %31 ]
ret i8* %38
}