#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 */
scalar_t__ ReadLine();
int Scan(char c, char **p) {
  do {
    while (**p)
      if (*(*p)++ == c)
        return 0;
  } while (ReadLine());
  return 1;
}


x86 assembly (clang, -O0):
<Scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
jmp    1127 <Scan+0x17>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     1168 <Scan+0x58>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl (%rax),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jne    1163 <Scan+0x53>
movl   $0x0,-0x4(%rbp)
jmp    1185 <Scan+0x75>
jmp    1127 <Scan+0x17>
jmp    116d <Scan+0x5d>
mov    $0x0,%al
call   1030 <ReadLine@plt>
cmp    $0x0,%rax
jne    1122 <Scan+0x12>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Scan>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rbx),%rax
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rax)
je     1140 <Scan+0x30>
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
cmp    %bpl,(%rax)
mov    %rcx,%rax
jne    1120 <Scan+0x10>
jmp    1153 <Scan+0x43>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <ReadLine@plt>
test   %rax,%rax
jne    1118 <Scan+0x8>
mov    $0x1,%eax
jmp    1155 <Scan+0x45>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Scan(i8 signext %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8**
store i8 %0, i8* %4
store i8** %1, i8*** %5
br label %6
6: ; preds = %24, %2
br label %7
7: ; preds = %22, %6
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %13
%16 = load i8, i8* %14
%17 = sext i8 %16 to i32
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %17, %19
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 0, i32* %3
br label %28
22: ; preds = %12
br label %7
23: ; preds = %7
br label %24
24: ; preds = %23
%25 = call i64 (...) @ReadLine()
%26 = icmp ne i64 %25, 0
br i1 %26, label %6, label %27
27: ; preds = %24
store i32 1, i32* %3
br label %28
28: ; preds = %27, %21
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @Scan(i8 signext %0, i8** nocapture %1) {
br label %3
3: ; preds = %13, %2
%4 = load i8*, i8** %1
br label %5
5: ; preds = %9, %3
%6 = phi i8* [ %10, %9 ], [ %4, %3 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %10, i8** %1
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, %0
br i1 %12, label %16, label %5
13: ; preds = %5
%14 = tail call i64 (...) @ReadLine()
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %3
16: ; preds = %13, %9
%17 = phi i32 [ 0, %9 ], [ 1, %13 ]
ret i32 %17
}