#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 vGetc();
int skipPastMatch(const char *const pair) {
  const int begin = pair[0], end = pair[1];
  int matchLevel = 1;
  int c;
  do {
    c = vGetc();
    if (c == begin)
      ++matchLevel;
    else if (c == end)
      --matchLevel;
  } while (matchLevel > 0);
  return vGetc();
}


x86 assembly (clang, -O0):
<skipPastMatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    $0x0,%al
call   1030 <vGetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    115c <skipPastMatch+0x4c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <skipPastMatch+0x66>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1171 <skipPastMatch+0x61>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <skipPastMatch+0x66>
jmp    117b <skipPastMatch+0x6b>
cmpl   $0x0,-0x14(%rbp)
jg     1138 <skipPastMatch+0x28>
mov    $0x0,%al
call   1030 <vGetc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skipPastMatch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsbl (%rdi),%r15d
movsbl 0x1(%rdi),%ebp
mov    $0x1,%r14d
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <vGetc@plt>
xor    %ecx,%ecx
cmp    %ebp,%eax
sete   %cl
neg    %ecx
cmp    %r15d,%eax
cmove  %r14d,%ecx
add    %ecx,%ebx
jne    1130 <skipPastMatch+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <vGetc@plt>

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

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