#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_GetJbufEndAddr();
unsigned long VIM_MARB_GetJbufStartAddr();
int /*<<< orphan*/ VIM_MARB_SetJbufLowThreshold(unsigned long);
int /*<<< orphan*/ VIM_MARB_SetJbufUpThreshold(unsigned long);
void VIM_MARB_SetJpegbufGapratio(unsigned char ratio) {
  unsigned long StartAddr, EndAddr, JbufLength;
  StartAddr = VIM_MARB_GetJbufStartAddr();
  EndAddr = VIM_MARB_GetJbufEndAddr() + 4;
  JbufLength = EndAddr - StartAddr;
  JbufLength *= ratio;
  JbufLength /= 10;
  VIM_MARB_SetJbufUpThreshold(JbufLength + 40);
  VIM_MARB_SetJbufLowThreshold(JbufLength - 40);
}


x86 assembly (clang, -O0):
<VIM_MARB_SetJpegbufGapratio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1060 <VIM_MARB_GetJbufStartAddr@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <VIM_MARB_GetJbufEndAddr@plt>
add    $0x4,%eax
cltq
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   1050 <VIM_MARB_SetJbufUpThreshold@plt>
mov    -0x20(%rbp),%rdi
sub    $0x28,%rdi
call   1030 <VIM_MARB_SetJbufLowThreshold@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIM_MARB_SetJpegbufGapratio>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <VIM_MARB_GetJbufStartAddr@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <VIM_MARB_GetJbufEndAddr@plt>
add    $0x4,%eax
movslq %eax,%rcx
sub    %rbx,%rcx
mov    %ebp,%eax
imul   %rcx,%rax
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mul    %rcx
mov    %rdx,%rbx
shr    $0x3,%rbx
lea    0x28(%rbx),%rdi
call   1050 <VIM_MARB_SetJbufUpThreshold@plt>
add    $0xffffffffffffffd8,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <VIM_MARB_SetJbufLowThreshold@plt>

LLVM IR (-O0):
define void @VIM_MARB_SetJpegbufGapratio(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_GetJbufStartAddr()
store i64 %6, i64* %3
%7 = call i32 (...) @VIM_MARB_GetJbufEndAddr()
%8 = add nsw i32 %7, 4
%9 = sext i32 %8 to i64
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = load i64, i64* %3
%12 = sub i64 %10, %11
store i64 %12, i64* %5
%13 = load i8, i8* %2
%14 = zext i8 %13 to i64
%15 = load i64, i64* %5
%16 = mul i64 %15, %14
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = udiv i64 %17, 10
store i64 %18, i64* %5
%19 = load i64, i64* %5
%20 = add i64 %19, 40
%21 = call i32 @VIM_MARB_SetJbufUpThreshold(i64 %20)
%22 = load i64, i64* %5
%23 = sub i64 %22, 40
%24 = call i32 @VIM_MARB_SetJbufLowThreshold(i64 %23)
ret void
}

LLVM IR (-O2):
define void @VIM_MARB_SetJpegbufGapratio(i8 zeroext %0) {
%2 = tail call i64 (...) @VIM_MARB_GetJbufStartAddr()
%3 = tail call i32 (...) @VIM_MARB_GetJbufEndAddr()
%4 = add nsw i32 %3, 4
%5 = sext i32 %4 to i64
%6 = sub i64 %5, %2
%7 = zext i8 %0 to i64
%8 = mul i64 %6, %7
%9 = udiv i64 %8, 10
%10 = add nuw nsw i64 %9, 40
%11 = tail call i32 @VIM_MARB_SetJbufUpThreshold(i64 %10)
%12 = add nsw i64 %9, -40
%13 = tail call i32 @VIM_MARB_SetJbufLowThreshold(i64 %12)
ret void
}