#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*/ advance(size_t);
char peek(size_t);
int /*<<< orphan*/ skip_spaces();
bool TST(const char *s) {
  skip_spaces();
  for (size_t i = 0;; ++i) {
    char c = s[i];
    if (c == 0) {
      advance(i);
      return true;
    }
    if (c != peek(i))
      return false;
  }
}


x86 assembly (clang, -O0):
<TST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <skip_spaces@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    117b <TST+0x4b>
mov    -0x18(%rbp),%rdi
call   1040 <advance@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bd <TST+0x8d>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <peek@plt>
mov    %al,%cl
mov    -0x20(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     11a7 <TST+0x77>
movl   $0x0,-0x4(%rbp)
jmp    11bd <TST+0x8d>
jmp    11ac <TST+0x7c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114b <TST+0x1b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TST>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <skip_spaces@plt>
mov    (%r14),%bpl
test   %bpl,%bpl
je     116c <TST+0x3c>
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    %rbx,%rdi
call   1030 <peek@plt>
cmp    %al,%bpl
jne    117a <TST+0x4a>
movzbl 0x1(%r14,%rbx,1),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
jne    1150 <TST+0x20>
mov    %rbx,%rdi
call   1040 <advance@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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