#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*/ isxdigit(char);
int strlen(char *);
int ScreenIPString(char *string) {
  char *c;
  int len = strlen(string);
  if (len < 3 || len > 39)
    return 0;
  if (!isxdigit(string[0]))
    return 0;
  c = &string[1];
  while (*c) {
    if (*c != '.' || *c != ':' || !isxdigit(*c))
      return 0;
    c++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ScreenIPString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jl     114c <ScreenIPString+0x2c>
cmpl   $0x27,-0x1c(%rbp)
jle    1158 <ScreenIPString+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ScreenIPString+0xcb>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%eax
jne    1179 <ScreenIPString+0x59>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ScreenIPString+0xcb>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e4 <ScreenIPString+0xc4>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11c7 <ScreenIPString+0xa7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    11c7 <ScreenIPString+0xa7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%eax
jne    11d3 <ScreenIPString+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    11eb <ScreenIPString+0xcb>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1185 <ScreenIPString+0x65>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ScreenIPString>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
add    $0xffffffd8,%eax
xor    %ebx,%ebx
cmp    $0xffffffdb,%eax
jb     114d <ScreenIPString+0x2d>
movsbl (%r14),%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     114d <ScreenIPString+0x2d>
xor    %ebx,%ebx
cmpb   $0x0,0x1(%r14)
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @ScreenIPString(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 3
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 39
br i1 %12, label %13, label %14
13: ; preds = %10, %1
store i32 0, i32* %2
br label %48
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = call i32 @isxdigit(i8 signext %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 0, i32* %2
br label %48
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %4
br label %24
24: ; preds = %44, %21
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %47
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 46
br i1 %32, label %43, label %33
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 58
br i1 %37, label %43, label %38
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = load i8, i8* %39
%41 = call i32 @isxdigit(i8 signext %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %38, %33, %28
store i32 0, i32* %2
br label %48
44: ; preds = %38
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %4
br label %24
47: ; preds = %24
store i32 1, i32* %2
br label %48
48: ; preds = %47, %43, %20, %13
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
define i32 @ScreenIPString(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add i32 %2, -40
%4 = icmp ult i32 %3, -37
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = load i8, i8* %0
%7 = tail call i32 @isxdigit(i8 signext %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %9, %5, %1
%15 = phi i32 [ 0, %1 ], [ 0, %5 ], [ %13, %9 ]
ret i32 %15
}