#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*/ strchr(char const *, char);
int IsIP6Address(char *Str) {
  char *ptr;
  const char *IP6CHARS = "0123456789abcdefABCDEF:%";
  if (!Str)
    return (0);
  for (ptr = Str; *ptr != '\0'; ptr++) {
    if (*ptr == '%')
      break;
    if (!strchr(IP6CHARS, *ptr))
      return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<IsIP6Address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113e <IsIP6Address+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11ad <IsIP6Address+0x9d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a6 <IsIP6Address+0x96>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    116b <IsIP6Address+0x5b>
jmp    11a6 <IsIP6Address+0x96>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    1190 <IsIP6Address+0x80>
movl   $0x0,-0x4(%rbp)
jmp    11ad <IsIP6Address+0x9d>
jmp    1195 <IsIP6Address+0x85>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1146 <IsIP6Address+0x36>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsIP6Address>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1154 <IsIP6Address+0x44>
mov    %rdi,%rbx
lea    0xedd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%ecx
mov    $0x1,%eax
test   %cl,%cl
je     1156 <IsIP6Address+0x46>
cmp    $0x25,%cl
je     1156 <IsIP6Address+0x46>
movsbl %cl,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1130 <IsIP6Address+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"0123456789abcdefABCDEF:%\00"
define i32 @IsIP6Address(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %34
9: ; preds = %1
%10 = load i8*, i8** %3
store i8* %10, i8** %4
br label %11
11: ; preds = %30, %9
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 37
br i1 %20, label %21, label %22
21: ; preds = %16
br label %33
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = call i32 @strchr(i8* %23, i8 signext %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %22
store i32 0, i32* %2
br label %34
29: ; preds = %22
br label %30
30: ; preds = %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %11
33: ; preds = %21, %11
store i32 1, i32* %2
br label %34
34: ; preds = %33, %28, %8
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [25 x i8] c"0123456789abcdefABCDEF:%\00"
define i32 @IsIP6Address(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %10, label %3
3: ; preds = %1, %6
%4 = phi i8* [ %9, %6 ], [ %0, %1 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %10
i8 37, label %10
]
6: ; preds = %3
%7 = tail call i32 @strchr(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%8 = icmp eq i32 %7, 0
%9 = getelementptr inbounds i8, i8* %4, i64 1
br i1 %8, label %10, label %3
10: ; preds = %3, %3, %6, %1
%11 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 1, %3 ], [ 0, %6 ]
ret i32 %11
}