#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 */
char *scout_h16(char const *);
char *scout_ipv6address_rh1(char const *);
char *scout_ipv6address_rh2(char const *);
char *scout_ipv6address_rh3(char const *);
char *scout_ipv6address_rh4(char const *);
char *scout_ipv6address_rh5(char const *);
char *scout_ipv6address_rh6(char const *);
char *scout_ls32(char const *);
const char *scout_ipv6address(const char *c) {
  const char *p = NULL;
  int left_hand_count = 0;
  if ((p = scout_ipv6address_rh6(c)) != NULL)
    return p;
  else {
    p = c;
    c = scout_h16(c);
    while (c != NULL) {
      p = c++;
      left_hand_count++;
      if (*c == ':')
        c = scout_h16(c + 1);
    }
    p += (left_hand_count == 0) ? 2 : 3;
    switch (left_hand_count) {
    case 0:
      if ((c = scout_ipv6address_rh5(p)) != NULL)
        return c;
    case 1:
      if ((c = scout_ipv6address_rh4(p)) != NULL)
        return c;
    case 2:
      if ((c = scout_ipv6address_rh3(p)) != NULL)
        return c;
    case 3:
      if ((c = scout_ipv6address_rh2(p)) != NULL)
        return c;
    case 4:
      if ((c = scout_ipv6address_rh1(p)) != NULL)
        return c;
    case 5:
      if ((c = scout_ls32(p)) != NULL)
        return c;
    case 6:
      if ((c = scout_h16(p)) != NULL)
        return c;
    case 7:
      return p;
    default:
      return NULL;
    }
  }
}


x86 assembly (clang, -O0):
<scout_ipv6address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <scout_ipv6address_rh6@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11bf <scout_ipv6address+0x3f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <scout_h16@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1221 <scout_ipv6address+0xa1>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    121c <scout_ipv6address+0x9c>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1030 <scout_h16@plt>
mov    %rax,-0x10(%rbp)
jmp    11d4 <scout_ipv6address+0x54>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    $0x3,%ecx
sbb    $0x0,%ecx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x7,%rax
ja     138b <scout_ipv6address+0x20b>
mov    -0x28(%rbp),%rax
lea    0xdaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
call   1090 <scout_ipv6address_rh5@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1283 <scout_ipv6address+0x103>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    1288 <scout_ipv6address+0x108>
mov    -0x18(%rbp),%rdi
call   1040 <scout_ipv6address_rh4@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12ac <scout_ipv6address+0x12c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    12b1 <scout_ipv6address+0x131>
mov    -0x18(%rbp),%rdi
call   10a0 <scout_ipv6address_rh3@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12d5 <scout_ipv6address+0x155>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    12da <scout_ipv6address+0x15a>
mov    -0x18(%rbp),%rdi
call   1050 <scout_ipv6address_rh2@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12fe <scout_ipv6address+0x17e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    1303 <scout_ipv6address+0x183>
mov    -0x18(%rbp),%rdi
call   1080 <scout_ipv6address_rh1@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1327 <scout_ipv6address+0x1a7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    132c <scout_ipv6address+0x1ac>
mov    -0x18(%rbp),%rdi
call   1070 <scout_ls32@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1350 <scout_ipv6address+0x1d0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    1355 <scout_ipv6address+0x1d5>
mov    -0x18(%rbp),%rdi
call   1030 <scout_h16@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1379 <scout_ipv6address+0x1f9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
jmp    137e <scout_ipv6address+0x1fe>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1393 <scout_ipv6address+0x213>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scout_ipv6address>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <scout_ipv6address_rh6@plt>
test   %rax,%rax
je     1197 <scout_ipv6address+0x17>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <scout_h16@plt>
test   %rax,%rax
je     11ef <scout_ipv6address+0x6f>
mov    $0xffffffff,%ebp
jmp    11c1 <scout_ipv6address+0x41>
nopl   0x0(%rax,%rax,1)
lea    0x2(%rbx),%rdi
call   1030 <scout_h16@plt>
add    $0x1,%ebp
test   %rax,%rax
je     11d0 <scout_ipv6address+0x50>
mov    %rax,%rbx
cmpb   $0x3a,0x1(%rax)
je     11b0 <scout_ipv6address+0x30>
lea    0x1(%rbx),%rax
jmp    11b9 <scout_ipv6address+0x39>
cmp    $0x6,%ebp
ja     126a <scout_ipv6address+0xea>
add    $0x3,%rbx
mov    %ebp,%eax
lea    0xe1a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x2,%rbx
mov    %rbx,%rdi
call   1090 <scout_ipv6address_rh5@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rdi
call   1040 <scout_ipv6address_rh4@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rdi
call   10a0 <scout_ipv6address_rh3@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rdi
call   1050 <scout_ipv6address_rh2@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rdi
call   1080 <scout_ipv6address_rh1@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rdi
call   1070 <scout_ls32@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rdi
call   1030 <scout_h16@plt>
test   %rax,%rax
jne    1190 <scout_ipv6address+0x10>
mov    %rbx,%rax
jmp    1190 <scout_ipv6address+0x10>
xor    %eax,%eax
jmp    1190 <scout_ipv6address+0x10>

LLVM IR (-O0):
define i8* @scout_ipv6address(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* null, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i8* @scout_ipv6address_rh6(i8* %6)
store i8* %7, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %4
store i8* %10, i8** %2
br label %93
11: ; preds = %1
%12 = load i8*, i8** %3
store i8* %12, i8** %4
%13 = load i8*, i8** %3
%14 = call i8* @scout_h16(i8* %13)
store i8* %14, i8** %3
br label %15
15: ; preds = %31, %11
%16 = load i8*, i8** %3
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8* %19, i8** %4
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 58
br i1 %26, label %27, label %31
27: ; preds = %18
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = call i8* @scout_h16(i8* %29)
store i8* %30, i8** %3
br label %31
31: ; preds = %27, %18
br label %15
32: ; preds = %15
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 2, i32 3
%37 = load i8*, i8** %4
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8* %39, i8** %4
%40 = load i32, i32* %5
switch i32 %40, label %92 [
i32 0, label %41
i32 1, label %48
i32 2, label %55
i32 3, label %62
i32 4, label %69
i32 5, label %76
i32 6, label %83
i32 7, label %90
]
41: ; preds = %32
%42 = load i8*, i8** %4
%43 = call i8* @scout_ipv6address_rh5(i8* %42)
store i8* %43, i8** %3
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i8*, i8** %3
store i8* %46, i8** %2
br label %93
47: ; preds = %41
br label %48
48: ; preds = %32, %47
%49 = load i8*, i8** %4
%50 = call i8* @scout_ipv6address_rh4(i8* %49)
store i8* %50, i8** %3
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = load i8*, i8** %3
store i8* %53, i8** %2
br label %93
54: ; preds = %48
br label %55
55: ; preds = %32, %54
%56 = load i8*, i8** %4
%57 = call i8* @scout_ipv6address_rh3(i8* %56)
store i8* %57, i8** %3
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = load i8*, i8** %3
store i8* %60, i8** %2
br label %93
61: ; preds = %55
br label %62
62: ; preds = %32, %61
%63 = load i8*, i8** %4
%64 = call i8* @scout_ipv6address_rh2(i8* %63)
store i8* %64, i8** %3
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = load i8*, i8** %3
store i8* %67, i8** %2
br label %93
68: ; preds = %62
br label %69
69: ; preds = %32, %68
%70 = load i8*, i8** %4
%71 = call i8* @scout_ipv6address_rh1(i8* %70)
store i8* %71, i8** %3
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %75
73: ; preds = %69
%74 = load i8*, i8** %3
store i8* %74, i8** %2
br label %93
75: ; preds = %69
br label %76
76: ; preds = %32, %75
%77 = load i8*, i8** %4
%78 = call i8* @scout_ls32(i8* %77)
store i8* %78, i8** %3
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = load i8*, i8** %3
store i8* %81, i8** %2
br label %93
82: ; preds = %76
br label %83
83: ; preds = %32, %82
%84 = load i8*, i8** %4
%85 = call i8* @scout_h16(i8* %84)
store i8* %85, i8** %3
%86 = icmp ne i8* %85, null
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = load i8*, i8** %3
store i8* %88, i8** %2
br label %93
89: ; preds = %83
br label %90
90: ; preds = %32, %89
%91 = load i8*, i8** %4
store i8* %91, i8** %2
br label %93
92: ; preds = %32
store i8* null, i8** %2
br label %93
93: ; preds = %92, %90, %87, %80, %73, %66, %59, %52, %45, %9
%94 = load i8*, i8** %2
ret i8* %94
}

LLVM IR (-O2):
define i8* @scout_ipv6address(i8* %0) {
%2 = tail call i8* @scout_ipv6address_rh6(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %52
4: ; preds = %1
%5 = tail call i8* @scout_h16(i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 2
%9 = tail call i8* @scout_ipv6address_rh5(i8* %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %26, label %52
11: ; preds = %4, %21
%12 = phi i32 [ %15, %21 ], [ 0, %4 ]
%13 = phi i8* [ %22, %21 ], [ %5, %4 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = add nuw nsw i32 %12, 1
%16 = load i8, i8* %14
%17 = icmp eq i8 %16, 58
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = getelementptr inbounds i8, i8* %13, i64 2
%20 = tail call i8* @scout_h16(i8* %19)
br label %21
21: ; preds = %18, %11
%22 = phi i8* [ %20, %18 ], [ %14, %11 ]
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %11
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %13, i64 3
switch i32 %12, label %52 [
i32 6, label %50
i32 0, label %26
i32 1, label %30
i32 2, label %34
i32 3, label %38
i32 4, label %42
i32 5, label %46
]
26: ; preds = %7, %24
%27 = phi i8* [ %8, %7 ], [ %25, %24 ]
%28 = tail call i8* @scout_ipv6address_rh4(i8* %27)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %52
30: ; preds = %26, %24
%31 = phi i8* [ %27, %26 ], [ %25, %24 ]
%32 = tail call i8* @scout_ipv6address_rh3(i8* %31)
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %52
34: ; preds = %30, %24
%35 = phi i8* [ %31, %30 ], [ %25, %24 ]
%36 = tail call i8* @scout_ipv6address_rh2(i8* %35)
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %52
38: ; preds = %34, %24
%39 = phi i8* [ %35, %34 ], [ %25, %24 ]
%40 = tail call i8* @scout_ipv6address_rh1(i8* %39)
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %52
42: ; preds = %38, %24
%43 = phi i8* [ %39, %38 ], [ %25, %24 ]
%44 = tail call i8* @scout_ls32(i8* %43)
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %52
46: ; preds = %42, %24
%47 = phi i8* [ %43, %42 ], [ %25, %24 ]
%48 = tail call i8* @scout_h16(i8* %47)
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %52
50: ; preds = %24, %46
%51 = phi i8* [ %47, %46 ], [ %25, %24 ]
br label %52
52: ; preds = %24, %46, %42, %38, %34, %30, %26, %7, %1, %50
%53 = phi i8* [ %51, %50 ], [ %2, %1 ], [ %9, %7 ], [ %28, %26 ], [ %32, %30 ], [ %36, %34 ], [ %40, %38 ], [ %44, %42 ], [ %48, %46 ], [ null, %24 ]
ret i8* %53
}