#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*/ fts3GetDeltaPosition(char **, int *);
void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext) {
  char *pIter = *ppIter;
  if (pIter) {
    int iIter = *piIter;
    while (iIter < iNext) {
      if (0 == (*pIter & 0xFE)) {
        iIter = -1;
        pIter = 0;
        break;
      }
      fts3GetDeltaPosition(&pIter, &iIter);
    }
    *piIter = iIter;
    *ppIter = pIter;
  }
}


x86 assembly (clang, -O0):
<fts3SnippetAdvance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119f <fts3SnippetAdvance+0x8f>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118b <fts3SnippetAdvance+0x7b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
and    $0xfe,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1179 <fts3SnippetAdvance+0x69>
movl   $0xffffffff,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
jmp    118b <fts3SnippetAdvance+0x7b>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <fts3GetDeltaPosition@plt>
jmp    1142 <fts3SnippetAdvance+0x32>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts3SnippetAdvance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    (%rdi),%rax
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     118a <fts3SnippetAdvance+0x7a>
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rsi),%ebx
mov    %ebx,0xc(%rsp)
cmp    %edx,%ebx
jge    1183 <fts3SnippetAdvance+0x73>
mov    $0xffffffff,%ebx
cmpb   $0x2,(%rax)
jb     117d <fts3SnippetAdvance+0x6d>
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <fts3GetDeltaPosition@plt>
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%rax
cmp    %ebp,%ecx
jge    1181 <fts3SnippetAdvance+0x71>
cmpb   $0x1,(%rax)
ja     1160 <fts3SnippetAdvance+0x50>
xor    %eax,%eax
jmp    1183 <fts3SnippetAdvance+0x73>
mov    %ecx,%ebx
mov    %ebx,(%r14)
mov    %rax,(%r12)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fts3SnippetAdvance(i8** %0, i32* %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = load i8**, i8*** %4
%10 = load i8*, i8** %9
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %34
13: ; preds = %3
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
store i32 %15, i32* %8
br label %16
16: ; preds = %27, %13
%17 = load i32, i32* %8
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = and i32 %23, 254
%25 = icmp eq i32 0, %24
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 -1, i32* %8
store i8* null, i8** %7
br label %29
27: ; preds = %20
%28 = call i32 @fts3GetDeltaPosition(i8** %7, i32* %8)
br label %16
29: ; preds = %26, %16
%30 = load i32, i32* %8
%31 = load i32*, i32** %5
store i32 %30, i32* %31
%32 = load i8*, i8** %7
%33 = load i8**, i8*** %4
store i8* %32, i8** %33
br label %34
34: ; preds = %29, %3
ret void
}

LLVM IR (-O2):
define void @fts3SnippetAdvance(i8** nocapture %0, i32* nocapture %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
%7 = load i8*, i8** %0
store i8* %7, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %27, label %9
9: ; preds = %3
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* %1
store i32 %11, i32* %5
%12 = icmp slt i32 %11, %2
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i8, i8* %7
%15 = icmp ult i8 %14, 2
br i1 %15, label %24, label %16
16: ; preds = %13, %21
%17 = call i32 @fts3GetDeltaPosition(i8** %4, i32* %5)
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, %2
%20 = load i8*, i8** %4
br i1 %19, label %21, label %24
21: ; preds = %16
%22 = load i8, i8* %20
%23 = icmp ult i8 %22, 2
br i1 %23, label %24, label %16
24: ; preds = %21, %16, %13, %9
%25 = phi i8* [ %7, %9 ], [ null, %13 ], [ null, %21 ], [ %20, %16 ]
%26 = phi i32 [ %11, %9 ], [ -1, %13 ], [ -1, %21 ], [ %18, %16 ]
store i32 %26, i32* %1
store i8* %25, i8** %0
br label %27
27: ; preds = %24, %3
ret void
}