#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 strlen(char *);
scalar_t__ strn_casecmp(char *, char *, int);
int has_IN_IP(char *inp, char *str) {
  int l;
  char *p;
  l = strlen(inp);
  if (l < 10)
    return 0;
  if (strn_casecmp(inp, "c=IN IP4 ", 9) != 0)
    return 0;
  p = inp + 9;
  while (*p && (*p == ' '))
    p++;
  while (*p && ((*p >= '0' && *p <= '9') || *p == '.'))
    *str++ = *p++;
  *str = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<has_IN_IP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    1152 <has_IN_IP+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1269 <has_IN_IP+0x149>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x9,%edx
call   1030 <strn_casecmp@plt>
cmp    $0x0,%rax
je     117d <has_IN_IP+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    1269 <has_IN_IP+0x149>
mov    -0x10(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11ae <has_IN_IP+0x8e>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11be <has_IN_IP+0x9e>
jmp    11cf <has_IN_IP+0xaf>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <has_IN_IP+0x69>
jmp    11d4 <has_IN_IP+0xb4>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2a(%rbp)
je     1224 <has_IN_IP+0x104>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     120e <has_IN_IP+0xee>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x39,%ecx
mov    %al,-0x2b(%rbp)
jle    121e <has_IN_IP+0xfe>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x2b(%rbp)
mov    -0x2b(%rbp),%al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    1234 <has_IN_IP+0x114>
jmp    125b <has_IN_IP+0x13b>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11d4 <has_IN_IP+0xb4>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_IN_IP>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    $0xa,%eax
jl     11a8 <has_IN_IP+0x88>
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1030 <strn_casecmp@plt>
test   %rax,%rax
jne    11a8 <has_IN_IP+0x88>
add    $0x9,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x20,%al
je     1160 <has_IN_IP+0x40>
test   %al,%al
je     119f <has_IN_IP+0x7f>
xor    %ecx,%ecx
jmp    1190 <has_IN_IP+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%r14,%rcx,1)
movzbl (%rbx,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
je     119c <has_IN_IP+0x7c>
cmp    $0x2e,%al
je     1180 <has_IN_IP+0x60>
lea    -0x30(%rax),%edx
cmp    $0x9,%dl
jbe    1180 <has_IN_IP+0x60>
add    %rcx,%r14
movb   $0x0,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"c=IN IP4 \00"
define i32 @has_IN_IP(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %69
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strn_casecmp(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %3
br label %69
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 9
store i8* %20, i8** %7
br label %21
21: ; preds = %33, %18
%22 = load i8*, i8** %7
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 32
br label %31
31: ; preds = %26, %21
%32 = phi i1 [ false, %21 ], [ %30, %26 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
br label %21
36: ; preds = %31
br label %37
37: ; preds = %61, %36
%38 = load i8*, i8** %7
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %59
42: ; preds = %37
%43 = load i8*, i8** %7
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp sge i32 %45, 48
br i1 %46, label %47, label %52
47: ; preds = %42
%48 = load i8*, i8** %7
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp sle i32 %50, 57
br i1 %51, label %57, label %52
52: ; preds = %47, %42
%53 = load i8*, i8** %7
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 46
br label %57
57: ; preds = %52, %47
%58 = phi i1 [ true, %47 ], [ %56, %52 ]
br label %59
59: ; preds = %57, %37
%60 = phi i1 [ false, %37 ], [ %58, %57 ]
br i1 %60, label %61, label %67
61: ; preds = %59
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %7
%64 = load i8, i8* %62
%65 = load i8*, i8** %5
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %5
store i8 %64, i8* %65
br label %37
67: ; preds = %59
%68 = load i8*, i8** %5
store i8 0, i8* %68
store i32 1, i32* %3
br label %69
69: ; preds = %67, %17, %12
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [10 x i8] c"c=IN IP4 \00"
define i32 @has_IN_IP(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, 10
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = tail call i64 @strn_casecmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %29
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %0, i64 9
br label %10
10: ; preds = %10, %8
%11 = phi i8* [ %9, %8 ], [ %13, %10 ]
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %11, i64 1
switch i8 %12, label %14 [
i8 32, label %10
i8 0, label %27
]
14: ; preds = %10, %22
%15 = phi i8* [ %23, %22 ], [ %11, %10 ]
%16 = phi i8* [ %24, %22 ], [ %1, %10 ]
%17 = phi i8 [ %25, %22 ], [ %12, %10 ]
%18 = add i8 %17, -48
%19 = icmp ult i8 %18, 10
%20 = icmp eq i8 %17, 46
%21 = or i1 %20, %19
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = getelementptr inbounds i8, i8* %15, i64 1
%24 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %17, i8* %16
%25 = load i8, i8* %23
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %14
27: ; preds = %10, %22, %14
%28 = phi i8* [ %16, %14 ], [ %24, %22 ], [ %1, %10 ]
store i8 0, i8* %28
br label %29
29: ; preds = %5, %2, %27
%30 = phi i32 [ 1, %27 ], [ 0, %2 ], [ 0, %5 ]
ret i32 %30
}