#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 VIM_MARB_GetThumbbufEndAddr();
unsigned long VIM_MARB_ReadBuf(unsigned char *, unsigned long,
                               int /*<<< orphan*/, unsigned long,
                               unsigned long);
unsigned long VIM_MARB_ReadThumbData(unsigned char *Start, unsigned long length,
                                     unsigned long pos) {
  unsigned long dwEndAddr = VIM_MARB_GetThumbbufEndAddr() + 4;
  if (Start == 0)
    return pos;
  pos = VIM_MARB_ReadBuf(Start, length, 0, dwEndAddr, pos);
  return pos;
}


x86 assembly (clang, -O0):
<VIM_MARB_ReadThumbData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1030 <VIM_MARB_GetThumbbufEndAddr@plt>
add    $0x4,%eax
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <VIM_MARB_ReadThumbData+0x3c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <VIM_MARB_ReadThumbData+0x5f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
xor    %edx,%edx
call   1040 <VIM_MARB_ReadBuf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIM_MARB_ReadThumbData>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <VIM_MARB_GetThumbbufEndAddr@plt>
test   %rbx,%rbx
je     1155 <VIM_MARB_ReadThumbData+0x35>
add    $0x4,%eax
movslq %eax,%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %r15,%r8
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <VIM_MARB_ReadBuf@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @VIM_MARB_ReadThumbData(i8* %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%9 = call i32 (...) @VIM_MARB_GetThumbbufEndAddr()
%10 = add nsw i32 %9, 4
%11 = sext i32 %10 to i64
store i64 %11, i64* %8
%12 = load i8*, i8** %5
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i64, i64* %7
store i64 %15, i64* %4
br label %23
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i64, i64* %6
%19 = load i64, i64* %8
%20 = load i64, i64* %7
%21 = call i64 @VIM_MARB_ReadBuf(i8* %17, i64 %18, i32 0, i64 %19, i64 %20)
store i64 %21, i64* %7
%22 = load i64, i64* %7
store i64 %22, i64* %4
br label %23
23: ; preds = %16, %14
%24 = load i64, i64* %4
ret i64 %24
}

LLVM IR (-O2):
define i64 @VIM_MARB_ReadThumbData(i8* %0, i64 %1, i64 %2) {
%4 = tail call i32 (...) @VIM_MARB_GetThumbbufEndAddr()
%5 = icmp eq i8* %0, null
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = add nsw i32 %4, 4
%8 = sext i32 %7 to i64
%9 = tail call i64 @VIM_MARB_ReadBuf(i8* %0, i64 %1, i32 0, i64 %8, i64 %2)
br label %10
10: ; preds = %3, %6
%11 = phi i64 [ %9, %6 ], [ %2, %3 ]
ret i64 %11
}