#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 */
typedef int uint8_t;

/* Variables and functions */
long _GIF_SkipChunk(uint8_t **buff, long size) {
  long skip;
  for (skip = 2, ++size, ++(*buff); ((size -= skip) > 0) && (skip > 1);
       *buff += (skip = 1 + **buff))
    ;
  return size;
}


x86 assembly (clang, -O0):
<_GIF_SkipChunk>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jle    1157 <_GIF_SkipChunk+0x57>
cmpq   $0x1,-0x18(%rbp)
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1167 <_GIF_SkipChunk+0x67>
jmp    1192 <_GIF_SkipChunk+0x92>
jmp    116c <_GIF_SkipChunk+0x6c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
add    $0x1,%eax
movslq %eax,%rcx
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x2,%rcx
add    (%rax),%rcx
mov    %rcx,(%rax)
jmp    112e <_GIF_SkipChunk+0x2e>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_GIF_SkipChunk>:
mov    (%rdi),%rcx
add    $0x4,%rcx
lea    -0x1(%rsi),%rax
cmp    $0x2,%rsi
jl     113c <_GIF_SkipChunk+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq (%rcx),%rdx
lea    0x1(%rdx),%rsi
sub    %rsi,%rax
lea    (%rcx,%rdx,4),%rcx
add    $0x4,%rcx
test   %rdx,%rdx
jle    113c <_GIF_SkipChunk+0x3c>
test   %rax,%rax
jg     1120 <_GIF_SkipChunk+0x20>
mov    %rcx,(%rdi)
ret

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

LLVM IR (-O2):
define i64 @_GIF_SkipChunk(i32** nocapture %0, i64 %1) {
%3 = load i32*, i32** %0
%4 = getelementptr inbounds i32, i32* %3, i64 1
%5 = add nsw i64 %1, -1
%6 = icmp sgt i64 %1, 1
br i1 %6, label %7, label %18
7: ; preds = %2, %7
%8 = phi i64 [ %14, %7 ], [ %5, %2 ]
%9 = phi i32* [ %13, %7 ], [ %4, %2 ]
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %9, i64 %12
%14 = sub nsw i64 %8, %12
%15 = icmp sgt i64 %14, 0
%16 = icmp sgt i32 %10, 0
%17 = and i1 %16, %15
br i1 %17, label %7, label %18
18: ; preds = %7, %2
%19 = phi i32* [ %4, %2 ], [ %13, %7 ]
%20 = phi i64 [ %5, %2 ], [ %14, %7 ]
store i32* %19, i32** %0
ret i64 %20
}