#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 */
unsigned long VIM_MARB_GetThumbbufEndAddr();
unsigned long VIM_MARB_GetThumbbufStartAddr();
int /*<<< orphan*/ VIM_MARB_SetThumbbufLowThreshold(unsigned long);
int /*<<< orphan*/ VIM_MARB_SetThumbbufUpThreshold(unsigned long);
void VIM_MARB_SetThumbbufGapratio(unsigned char ratio) {
  unsigned long StartAddr, EndAddr, JbufLength;
  StartAddr = VIM_MARB_GetThumbbufStartAddr();
  EndAddr = VIM_MARB_GetThumbbufEndAddr();
  JbufLength = EndAddr - StartAddr;
  JbufLength *= ratio;
  JbufLength /= 10;
  VIM_MARB_SetThumbbufUpThreshold(JbufLength + 40);
  VIM_MARB_SetThumbbufLowThreshold(JbufLength - 40);
}


x86 assembly (clang, -O0):
<VIM_MARB_SetThumbbufGapratio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1060 <VIM_MARB_GetThumbbufStartAddr@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <VIM_MARB_GetThumbbufEndAddr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movzbl -0x1(%rbp),%eax
imul   -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x28,%rdi
call   1040 <VIM_MARB_SetThumbbufUpThreshold@plt>
mov    -0x20(%rbp),%rdi
sub    $0x28,%rdi
call   1050 <VIM_MARB_SetThumbbufLowThreshold@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIM_MARB_SetThumbbufGapratio>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <VIM_MARB_GetThumbbufStartAddr@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <VIM_MARB_GetThumbbufEndAddr@plt>
sub    %rbx,%rax
mov    %ebp,%ecx
imul   %rcx,%rax
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mul    %rcx
mov    %rdx,%rbx
shr    $0x3,%rbx
lea    0x28(%rbx),%rdi
call   1040 <VIM_MARB_SetThumbbufUpThreshold@plt>
add    $0xffffffffffffffd8,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <VIM_MARB_SetThumbbufLowThreshold@plt>

LLVM IR (-O0):
define void @VIM_MARB_SetThumbbufGapratio(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i8 %0, i8* %2
%6 = call i64 (...) @VIM_MARB_GetThumbbufStartAddr()
store i64 %6, i64* %3
%7 = call i64 (...) @VIM_MARB_GetThumbbufEndAddr()
store i64 %7, i64* %4
%8 = load i64, i64* %4
%9 = load i64, i64* %3
%10 = sub i64 %8, %9
store i64 %10, i64* %5
%11 = load i8, i8* %2
%12 = zext i8 %11 to i64
%13 = load i64, i64* %5
%14 = mul i64 %13, %12
store i64 %14, i64* %5
%15 = load i64, i64* %5
%16 = udiv i64 %15, 10
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = add i64 %17, 40
%19 = call i32 @VIM_MARB_SetThumbbufUpThreshold(i64 %18)
%20 = load i64, i64* %5
%21 = sub i64 %20, 40
%22 = call i32 @VIM_MARB_SetThumbbufLowThreshold(i64 %21)
ret void
}

LLVM IR (-O2):
define void @VIM_MARB_SetThumbbufGapratio(i8 zeroext %0) {
%2 = tail call i64 (...) @VIM_MARB_GetThumbbufStartAddr()
%3 = tail call i64 (...) @VIM_MARB_GetThumbbufEndAddr()
%4 = sub i64 %3, %2
%5 = zext i8 %0 to i64
%6 = mul i64 %4, %5
%7 = udiv i64 %6, 10
%8 = add nuw nsw i64 %7, 40
%9 = tail call i32 @VIM_MARB_SetThumbbufUpThreshold(i64 %8)
%10 = add nsw i64 %7, -40
%11 = tail call i32 @VIM_MARB_SetThumbbufLowThreshold(i64 %10)
ret void
}