#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 sql_select(char *);
int strlen(char *);
int url_judge(char *input) {
  char output[50];
  int len = strlen(input);
  int i, countdown = 0, cnt_tmp = 0, n;
  for (i = len - 1; i > 0; i--) {
    if (input[i] == '.') {
      n = i + 1;
      for (cnt_tmp = 0; cnt_tmp < countdown; cnt_tmp++) {
        output[cnt_tmp] = input[n];
        n++;
      }
      output[cnt_tmp] = '\0';
      if (sql_select(output) == 1) {
        return 1;
      }
      countdown++;
    } else {
      countdown++;
    }
  }
  if (sql_select(input) == 1) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<url_judge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jle    1205 <url_judge+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11e9 <url_judge+0xc9>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jge    11b4 <url_judge+0x94>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x60(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    117e <url_judge+0x5e>
movslq -0x60(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
call   1030 <sql_select@plt>
cmp    $0x1,%eax
jne    11db <url_judge+0xbb>
movl   $0x1,-0x4(%rbp)
jmp    122a <url_judge+0x10a>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11f2 <url_judge+0xd2>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11f7 <url_judge+0xd7>
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
jmp    114f <url_judge+0x2f>
mov    -0x10(%rbp),%rdi
call   1030 <sql_select@plt>
cmp    $0x1,%eax
jne    1223 <url_judge+0x103>
movl   $0x1,-0x4(%rbp)
jmp    122a <url_judge+0x10a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<url_judge>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r15
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11a7 <url_judge+0x77>
mov    %eax,%r14d
mov    %eax,%r13d
add    $0xffffffff,%r14d
add    $0xffffffffffffffff,%r13
xor    %ebx,%ebx
mov    %rsp,%r12
jmp    1195 <url_judge+0x65>
nop
lea    (%r15,%r13,1),%rsi
add    $0x1,%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
call   1050 <memcpy@plt>
mov    %ebx,%eax
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r12,%rdi
call   1030 <sql_select@plt>
cmp    $0x1,%eax
je     11c7 <url_judge+0x97>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r13
cmp    %rbx,%r14
je     11a7 <url_judge+0x77>
mov    %r13d,%eax
cmpb   $0x2e,(%r15,%rax,1)
jne    1188 <url_judge+0x58>
test   %ebx,%ebx
jne    1160 <url_judge+0x30>
xor    %eax,%eax
jmp    1175 <url_judge+0x45>
mov    %r15,%rdi
call   1030 <sql_select@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    $0x1,%eax
jmp    11b9 <url_judge+0x89>

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

LLVM IR (-O2):
define i32 @url_judge(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %37
7: ; preds = %1
%8 = zext i32 %5 to i64
%9 = add nsw i32 %5, -1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %7, %33
%12 = phi i32 [ -1, %7 ], [ %35, %33 ]
%13 = phi i64 [ %8, %7 ], [ %18, %33 ]
%14 = phi i64 [ 0, %7 ], [ %34, %33 ]
%15 = add i32 %12, 1
%16 = sub nsw i64 %8, %14
%17 = getelementptr i8, i8* %0, i64 %16
%18 = add nsw i64 %13, -1
%19 = and i64 %18, 4294967295
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 46
br i1 %22, label %23, label %33
23: ; preds = %11
%24 = trunc i64 %14 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %23
br label %27
27: ; preds = %26, %23
%28 = phi i32 [ 0, %23 ], [ %15, %26 ]
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %29
store i8 0, i8* %30
%31 = call i32 @sql_select(i8* %4)
%32 = icmp eq i32 %31, 1
br i1 %32, label %41, label %33
33: ; preds = %11, %27
%34 = add nuw nsw i64 %14, 1
%35 = add nsw i32 %12, 1
%36 = icmp eq i64 %34, %10
br i1 %36, label %37, label %11
37: ; preds = %33, %1
%38 = call i32 @sql_select(i8* %0)
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i32
br label %41
41: ; preds = %27, %37
%42 = phi i32 [ %40, %37 ], [ 1, %27 ]
ret i32 %42
}