#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 escape_lookup(char *);
scalar_t__ in_set(int, char *);
int weird(char *string) {
  int c;
  string = string + 1;
weird_reset:
  c = string[0];
  if (0 == c)
    return 0;
  if ('\\' == c) {
    c = escape_lookup(string);
    if ('x' == string[1])
      string = string + 2;
    string = string + 1;
  }
  if (!in_set(c, "\t\n "
                 "!#$%&'()*+,-./"
                 "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
                 "abcdefghijklmnopqrstuvwxyz{|}~"))
    return 1;
  if (in_set(c, " \t\n\r") && (':' == string[1]))
    return 1;
  string = string + 1;
  goto weird_reset;
}


x86 assembly (clang, -O0):
<weird>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    1159 <weird+0x39>
movl   $0x0,-0x4(%rbp)
jmp    1210 <weird+0xf0>
mov    $0x5c,%eax
cmp    -0x14(%rbp),%eax
jne    11a0 <weird+0x80>
mov    -0x10(%rbp),%rdi
call   1030 <escape_lookup@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%ecx
mov    $0x78,%eax
cmp    %ecx,%eax
jne    1194 <weird+0x74>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%edi
lea    0xe56(%rip),%rsi
call   1040 <in_set@plt>
cmp    $0x0,%rax
jne    11c5 <weird+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    1210 <weird+0xf0>
mov    -0x14(%rbp),%edi
lea    0xe92(%rip),%rsi
call   1040 <in_set@plt>
cmp    $0x0,%rax
je     11ff <weird+0xdf>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%ecx
mov    $0x3a,%eax
cmp    %ecx,%eax
jne    11ff <weird+0xdf>
movl   $0x1,-0x4(%rbp)
jmp    1210 <weird+0xf0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <weird+0x18>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weird>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x1(%rdi),%cl
test   %cl,%cl
je     11b1 <weird+0x91>
mov    %rdi,%r12
add    $0x1,%rdi
lea    0xebf(%rip),%r14
lea    0xf19(%rip),%r15
mov    $0x1,%ebx
jmp    1159 <weird+0x39>
nop
lea    0x1(%r12),%rdi
test   %cl,%cl
je     11b1 <weird+0x91>
cmp    $0x5c,%cl
jne    1180 <weird+0x60>
call   1030 <escape_lookup@plt>
mov    %eax,%ebp
xor    %eax,%eax
cmpb   $0x78,0x2(%r12)
sete   %al
lea    (%r12,%rax,2),%r12
add    $0x2,%r12
jmp    1186 <weird+0x66>
nopw   0x0(%rax,%rax,1)
movsbl %cl,%ebp
mov    %rdi,%r12
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <in_set@plt>
test   %rax,%rax
je     11b3 <weird+0x93>
mov    %ebp,%edi
mov    %r15,%rsi
call   1040 <in_set@plt>
movzbl 0x1(%r12),%ecx
test   %rax,%rax
je     1150 <weird+0x30>
cmp    $0x3a,%cl
jne    1150 <weird+0x30>
jmp    11b3 <weird+0x93>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [97 x i8] c"\09\0A !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\00"
@.str.1 = [5 x i8] c" \09\0A\0D\00"
define i32 @weird(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 1
store i8* %6, i8** %3
br label %7
7: ; preds = %48, %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp eq i32 0, %12
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 0, i32* %2
br label %51
15: ; preds = %7
%16 = load i32, i32* %4
%17 = icmp eq i32 92, %16
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i8*, i8** %3
%20 = call i32 @escape_lookup(i8* %19)
store i32 %20, i32* %4
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 120, %24
br i1 %25, label %26, label %29
26: ; preds = %18
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8* %28, i8** %3
br label %29
29: ; preds = %26, %18
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %3
br label %32
32: ; preds = %29, %15
%33 = load i32, i32* %4
%34 = call i64 @in_set(i32 %33, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
store i32 1, i32* %2
br label %51
37: ; preds = %32
%38 = load i32, i32* %4
%39 = call i64 @in_set(i32 %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 58, %45
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 1, i32* %2
br label %51
48: ; preds = %41, %37
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 1
store i8* %50, i8** %3
br label %7
51: ; preds = %47, %36, %14
%52 = load i32, i32* %2
ret i32 %52
}

LLVM IR (-O2):
@.str = [97 x i8] c"\09\0A !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\00"
@.str.1 = [5 x i8] c" \09\0A\0D\00"
define i32 @weird(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %1, %31
%6 = phi i8 [ %28, %31 ], [ %3, %1 ]
%7 = phi i8* [ %32, %31 ], [ %2, %1 ]
%8 = phi i8* [ %20, %31 ], [ %0, %1 ]
%9 = sext i8 %6 to i32
%10 = icmp eq i8 %6, 92
br i1 %10, label %11, label %19
11: ; preds = %5
%12 = tail call i32 @escape_lookup(i8* %7)
%13 = getelementptr inbounds i8, i8* %8, i64 2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 120
%16 = select i1 %15, i64 3, i64 1
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = getelementptr inbounds i8, i8* %17, i64 %16
br label %19
19: ; preds = %11, %5
%20 = phi i8* [ %18, %11 ], [ %7, %5 ]
%21 = phi i32 [ %12, %11 ], [ %9, %5 ]
%22 = tail call i64 @in_set(i32 %21, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %34, label %24
24: ; preds = %19
%25 = tail call i64 @in_set(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
%27 = getelementptr inbounds i8, i8* %20, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 58
%30 = select i1 %26, i1 %29, i1 false
br i1 %30, label %34, label %31
31: ; preds = %24
%32 = getelementptr inbounds i8, i8* %20, i64 1
%33 = icmp eq i8 %28, 0
br i1 %33, label %34, label %5
34: ; preds = %31, %19, %24, %1
%35 = phi i32 [ 0, %1 ], [ 1, %19 ], [ 0, %31 ], [ 1, %24 ]
ret i32 %35
}