#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*/ printf(char *, ...);
int scan(char *p) {
  int n = 0;
  char *q;
  printf("[--------------\n");
  printf("%s\n", p);
  printf("]--------------\n");
start : {
  char yych;
  static const unsigned char yybm[] = {
      0,   128, 128, 128, 128, 128, 128, 128, 128, 128, 0,   128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
      128,
  };
  goto yy0;
yy1:
  ++p;
yy0:
  if (p <= p)
    ;
  yych = *p;
  if (yybm[0 + yych] & 128) {
    goto yy1;
  }
  if (yych <= 0x00)
    goto yy5;
  ++p;
  {
    ++n;
    goto start;
  }
yy5:
  ++p;
  { return n; }
}
}


x86 assembly (clang, -O0):
<scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1162 <scan+0x52>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x8(%rbp),%rax
ja     1175 <scan+0x65>
jmp    1175 <scan+0x65>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
add    $0x0,%eax
movslq %eax,%rcx
lea    0xea1(%rip),%rax
movzbl (%rax,%rcx,1),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11a6 <scan+0x96>
jmp    1156 <scan+0x46>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jg     11b8 <scan+0xa8>
jmp    11d2 <scan+0xc2>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <scan+0x41>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
xor    %edx,%edx
jmp    1147 <scan+0x37>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rax),%edx
test   %cl,%cl
je     1163 <scan+0x53>
mov    %edx,%eax
nopl   0x0(%rax)
add    $0x1,%rbx
movzbl -0x1(%rbx),%ecx
test   %cl,%cl
je     1140 <scan+0x30>
cmp    $0xa,%cl
jne    1150 <scan+0x40>
jmp    1140 <scan+0x30>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"[--------------\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [17 x i8] c"]--------------\0A\00"
@scan.yybm = internal constant [256 x i8] c"\00\80\80\80\80\80\80\80\80\80\00\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80\80"
define i32 @scan(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %37, %1
br label %14
11: ; preds = %31
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %2
br label %14
14: ; preds = %11, %10
%15 = load i8*, i8** %2
%16 = load i8*, i8** %2
%17 = icmp ule i8* %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
br label %19
19: ; preds = %18, %14
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
store i8 %21, i8* %5
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = add nsw i32 0, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* @scan.yybm, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = and i32 %28, 128
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %19
br label %11
32: ; preds = %19
%33 = load i8, i8* %5
%34 = sext i8 %33 to i32
%35 = icmp sle i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
br label %42
37: ; preds = %32
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %2
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %10
42: ; preds = %36
%43 = load i8*, i8** %2
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %2
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@str = [16 x i8] c"[--------------\00"
@str.3 = [16 x i8] c"]--------------\00"
define i32 @scan(i8* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) %0)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
br label %5
5: ; preds = %13, %1
%6 = phi i32 [ 0, %1 ], [ %15, %13 ]
%7 = phi i8* [ %0, %1 ], [ %16, %13 ]
br label %8
8: ; preds = %11, %5
%9 = phi i8* [ %7, %5 ], [ %12, %11 ]
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 10, label %13
i8 0, label %13
]
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
13: ; preds = %8, %8
%14 = icmp eq i8 %10, 0
%15 = add nuw nsw i32 %6, 1
%16 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %14, label %17, label %5
17: ; preds = %13
ret i32 %6
}