#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;
  goto yy0;
yy1:
  ++p;
yy0:
  if (p <= p)
    ;
  yych = *p;
  switch (yych) {
  case 0x00:
    goto yy5;
  case '\n':
    goto yy3;
  default:
    goto yy1;
  }
yy3:
  ++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
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     11a3 <scan+0x93>
jmp    1192 <scan+0x82>
mov    -0x20(%rbp),%eax
sub    $0xa,%eax
je     11a8 <scan+0x98>
jmp    11ad <scan+0x9d>
jmp    11cc <scan+0xbc>
jmp    11b2 <scan+0xa2>
jmp    1156 <scan+0x46>
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    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movsbl -0x1(%rbx),%ecx
test   %ecx,%ecx
je     1156 <scan+0x46>
cmp    $0xa,%ecx
jne    1140 <scan+0x30>
add    $0x1,%eax
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"
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 = %27, %1
br label %14
11: ; preds = %26
%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
switch i32 %23, label %26 [
i32 0, label %24
i32 10, label %25
]
24: ; preds = %19
br label %32
25: ; preds = %19
br label %27
26: ; preds = %19
br label %11
27: ; preds = %25
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %2
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %10
32: ; preds = %24
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %2
%35 = load i32, i32* %3
ret i32 %35
}

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 = %14, %1
%6 = phi i32 [ 0, %1 ], [ %15, %14 ]
%7 = phi i8* [ %0, %1 ], [ %16, %14 ]
br label %8
8: ; preds = %12, %5
%9 = phi i8* [ %7, %5 ], [ %13, %12 ]
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %12 [
i32 0, label %17
i32 10, label %14
]
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
14: ; preds = %8
%15 = add nuw nsw i32 %6, 1
%16 = getelementptr inbounds i8, i8* %9, i64 1
br label %5
17: ; preds = %8
ret i32 %6
}