#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;
  if (yych <= 0x00)
    goto yy5;
  if (yych != '\n')
    goto yy1;
  ++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
cmp    $0x0,%eax
jg     1190 <scan+0x80>
jmp    11bc <scan+0xac>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     11a2 <scan+0x92>
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>
mov    (%rbx),%cl
xor    %eax,%eax
test   %cl,%cl
jle    1169 <scan+0x59>
add    $0x1,%rbx
cmp    $0xa,%cl
je     1160 <scan+0x50>
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jg     1140 <scan+0x30>
jmp    1169 <scan+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%eax
mov    (%rbx),%cl
test   %cl,%cl
jg     113c <scan+0x2c>
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 = %31, %1
br label %14
11: ; preds = %30
%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 = icmp sle i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
br label %36
26: ; preds = %19
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %26
br label %11
31: ; preds = %26
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %2
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %10
36: ; preds = %25
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %2
%39 = load i32, i32* %3
ret i32 %39
}

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))
%5 = load i8, i8* %0
%6 = icmp slt i8 %5, 1
br i1 %6, label %24, label %7
7: ; preds = %1, %19
%8 = phi i8 [ %22, %19 ], [ %5, %1 ]
%9 = phi i8* [ %21, %19 ], [ %0, %1 ]
%10 = phi i32 [ %20, %19 ], [ 0, %1 ]
br label %11
11: ; preds = %7, %15
%12 = phi i8 [ %8, %7 ], [ %17, %15 ]
%13 = phi i8* [ %9, %7 ], [ %16, %15 ]
%14 = icmp eq i8 %12, 10
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = load i8, i8* %16
%18 = icmp slt i8 %17, 1
br i1 %18, label %24, label %11
19: ; preds = %11
%20 = add nuw nsw i32 %10, 1
%21 = getelementptr inbounds i8, i8* %13, i64 1
%22 = load i8, i8* %21
%23 = icmp slt i8 %22, 1
br i1 %23, label %24, label %7
24: ; preds = %19, %15, %1
%25 = phi i32 [ 0, %1 ], [ %10, %15 ], [ %20, %19 ]
ret i32 %25
}