#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*/ strcat(char *, char *);
int strlen(char *);
char *ipregex(char *ipX) {
  int i = 0, j = 1;
  static char IP[70];
  IP[0] = '^';
  for (i = 0; i < strlen(ipX); i++) {
    if (*(ipX + i) == 'X') {
      if (*(ipX + i - 1) == '2')
        strcat(IP, "[0-5]");
      else
        strcat(IP, "[0-9]");
      j += 5;
    } else {
      IP[j++] = *(ipX + i);
      IP[j] = '\0';
    }
  }
  IP[j++] = '$';
  IP[j] = '\0';
  return IP;
}


x86 assembly (clang, -O0):
<ipregex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movb   $0x5e,0x2eff(%rip)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    120d <ipregex+0xed>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x58,%eax
jne    11c8 <ipregex+0xa8>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0x32,%eax
jne    11a7 <ipregex+0x87>
lea    0x2eaa(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcat@plt>
jmp    11ba <ipregex+0x9a>
lea    0x2e92(%rip),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x10(%rbp)
jmp    11fa <ipregex+0xda>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2e58(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movslq -0x10(%rbp),%rcx
lea    0x2e4a(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    11ff <ipregex+0xdf>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <ipregex+0x28>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2e1e(%rip),%rax
movb   $0x24,(%rax,%rcx,1)
movslq -0x10(%rbp),%rcx
lea    0x2e0f(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e04(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipregex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
movb   $0x5e,0x2f0b(%rip)
call   1030 <strlen@plt>
mov    $0x1,%r15d
test   %eax,%eax
jle    11a9 <ipregex+0x89>
xor    %ebx,%ebx
lea    0xeb3(%rip),%r13
lea    0xeb2(%rip),%rbp
lea    0x2ee5(%rip),%r14
jmp    1184 <ipregex+0x64>
nopl   (%rax)
movslq %r15d,%rcx
lea    0x1(%rcx),%r15
mov    %al,(%rcx,%r14,1)
movb   $0x0,0x1(%rcx,%r14,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11a9 <ipregex+0x89>
movzbl (%r12,%rbx,1),%eax
cmp    $0x58,%al
jne    1160 <ipregex+0x40>
cmpb   $0x32,-0x1(%r12,%rbx,1)
mov    %r13,%rsi
je     119b <ipregex+0x7b>
mov    %rbp,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
add    $0x5,%r15d
jmp    1171 <ipregex+0x51>
movslq %r15d,%rcx
lea    0x2e8d(%rip),%rax
movw   $0x24,(%rcx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ipregex.IP = internal global [70 x i8] zeroinitializer
@.str = [6 x i8] c"[0-5]\00"
@.str.1 = [6 x i8] c"[0-9]\00"
define i8* @ipregex(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 1, i32* %4
store i8 94, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0)
store i32 0, i32* %3
br label %5
5: ; preds = %48, %1
%6 = load i32, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %51
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 88
br i1 %17, label %18, label %34
18: ; preds = %10
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = getelementptr inbounds i8, i8* %22, i64 -1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 50
br i1 %26, label %27, label %29
27: ; preds = %18
%28 = call i32 @strcat(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %31
29: ; preds = %18
%30 = call i32 @strcat(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 5
store i32 %33, i32* %4
br label %47
34: ; preds = %10
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %42
store i8 %39, i8* %43
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %45
store i8 0, i8* %46
br label %47
47: ; preds = %34, %31
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %5
51: ; preds = %5
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %54
store i8 36, i8* %55
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %57
store i8 0, i8* %58
ret i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0)
}

LLVM IR (-O2):
@ipregex.IP = internal global [70 x i8] zeroinitializer
@.str = [6 x i8] c"[0-5]\00"
@.str.1 = [6 x i8] c"[0-9]\00"
define i8* @ipregex(i8* %0) {
store i8 94, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0)
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %29
4: ; preds = %1, %23
%5 = phi i64 [ %25, %23 ], [ 0, %1 ]
%6 = phi i32 [ %24, %23 ], [ 1, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 88
br i1 %9, label %10, label %17
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %7, i64 -1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 50
%14 = select i1 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%15 = tail call i32 @strcat(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0), i8* %14)
%16 = add nsw i32 %6, 5
br label %23
17: ; preds = %4
%18 = add nsw i32 %6, 1
%19 = sext i32 %6 to i64
%20 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %19
store i8 %8, i8* %20
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %10, %17
%24 = phi i32 [ %16, %10 ], [ %18, %17 ]
%25 = add nuw nsw i64 %5, 1
%26 = tail call i32 @strlen(i8* %0)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %4, label %29
29: ; preds = %23, %1
%30 = phi i32 [ 1, %1 ], [ %24, %23 ]
%31 = add nsw i32 %30, 1
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %32
store i8 36, i8* %33
%34 = sext i32 %31 to i64
%35 = getelementptr inbounds [70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 %34
store i8 0, i8* %35
ret i8* getelementptr inbounds ([70 x i8], [70 x i8]* @ipregex.IP, i64 0, i64 0)
}