#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_ipv6address(char const *);
char *scout_ipvfuture(char const *);
const char *scout_ip_literal(const char *c) {
  if (*c == '[') {
    const char *p = scout_ipv6address(c + 1);
    if (p != NULL && *(p + 1) == ']')
      return p + 1;
    else if ((p = scout_ipvfuture(c + 1)) != NULL && *(p + 1) == ']')
      return p + 1;
    else
      return NULL;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<scout_ip_literal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    11c4 <scout_ip_literal+0xa4>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <scout_ipv6address@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117a <scout_ip_literal+0x5a>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5d,%eax
jne    117a <scout_ip_literal+0x5a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <scout_ip_literal+0xac>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1030 <scout_ipvfuture@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11b7 <scout_ip_literal+0x97>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5d,%eax
jne    11b7 <scout_ip_literal+0x97>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <scout_ip_literal+0xac>
movq   $0x0,-0x8(%rbp)
jmp    11cc <scout_ip_literal+0xac>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scout_ip_literal>:
push   %rbx
cmpb   $0x5b,(%rdi)
jne    1159 <scout_ip_literal+0x39>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <scout_ipv6address@plt>
test   %rax,%rax
je     1140 <scout_ip_literal+0x20>
cmpb   $0x5d,0x1(%rax)
je     1153 <scout_ip_literal+0x33>
mov    %rbx,%rdi
call   1030 <scout_ipvfuture@plt>
test   %rax,%rax
je     1159 <scout_ip_literal+0x39>
cmpb   $0x5d,0x1(%rax)
jne    1159 <scout_ip_literal+0x39>
add    $0x1,%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @scout_ip_literal(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 91
br i1 %8, label %9, label %39
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i8* @scout_ipv6address(i8* %11)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 93
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %2
br label %40
24: ; preds = %15, %9
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i8* @scout_ipvfuture(i8* %26)
store i8* %27, i8** %4
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %38
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 93
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %37, i8** %2
br label %40
38: ; preds = %29, %24
store i8* null, i8** %2
br label %40
39: ; preds = %1
store i8* null, i8** %2
br label %40
40: ; preds = %39, %38, %35, %21
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
define i8* @scout_ip_literal(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 91
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = tail call i8* @scout_ipv6address(i8* %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 93
br i1 %11, label %20, label %12
12: ; preds = %8, %4
%13 = tail call i8* @scout_ipvfuture(i8* %5)
%14 = icmp eq i8* %13, null
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 93
br i1 %18, label %20, label %19
19: ; preds = %15, %12
br label %20
20: ; preds = %1, %19, %8, %15
%21 = phi i8* [ null, %19 ], [ %9, %8 ], [ %16, %15 ], [ null, %1 ]
ret i8* %21
}