#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*/ VIM_HIF_ReadSram(scalar_t__, unsigned char *, int);
int /*<<< orphan*/ VIM_HIF_WriteSram(scalar_t__, unsigned char *, int);
int /*<<< orphan*/ VIM_IPP_Reset();
int /*<<< orphan*/ VIM_JPEG_FeedHeaderEnable(int /*<<< orphan*/);
int /*<<< orphan*/ VIM_JPEG_ResetState();
int /*<<< orphan*/ VIM_JPEG_SetDefaultHT();
int /*<<< orphan*/ VIM_JPEG_SetUseCustomQTEnable(int /*<<< orphan*/);
int /*<<< orphan*/ VIM_JPEG_SetUseSameQTEnable(int /*<<< orphan*/);
int /*<<< orphan*/ VIM_MAPI_StartDecode();
scalar_t__ VIM_MARB_GetJbufStartAddr();
void VIM_MAPI_JpegAutoDecode(unsigned long Datasize) {
  unsigned char dat[4];
  VIM_JPEG_ResetState();
  VIM_IPP_Reset();
  VIM_JPEG_SetDefaultHT();
  VIM_JPEG_SetUseCustomQTEnable(0);
  VIM_JPEG_SetUseSameQTEnable(0);
  VIM_JPEG_FeedHeaderEnable(0);
  VIM_JPEG_ResetState();
  VIM_MAPI_StartDecode();
  VIM_HIF_ReadSram(VIM_MARB_GetJbufStartAddr() + Datasize - 4, dat, 4);
  VIM_HIF_WriteSram(VIM_MARB_GetJbufStartAddr() + Datasize - 4, dat, 4);
}


x86 assembly (clang, -O0):
<VIM_MAPI_JpegAutoDecode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <VIM_JPEG_ResetState@plt>
mov    $0x0,%al
call   10c0 <VIM_IPP_Reset@plt>
mov    $0x0,%al
call   1080 <VIM_JPEG_SetDefaultHT@plt>
xor    %edi,%edi
call   1070 <VIM_JPEG_SetUseCustomQTEnable@plt>
xor    %edi,%edi
call   10b0 <VIM_JPEG_SetUseSameQTEnable@plt>
xor    %edi,%edi
call   1050 <VIM_JPEG_FeedHeaderEnable@plt>
mov    $0x0,%al
call   1060 <VIM_JPEG_ResetState@plt>
mov    $0x0,%al
call   1040 <VIM_MAPI_StartDecode@plt>
mov    $0x0,%al
call   10a0 <VIM_MARB_GetJbufStartAddr@plt>
mov    %rax,%rdi
add    -0x8(%rbp),%rdi
sub    $0x4,%rdi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1030 <VIM_HIF_ReadSram@plt>
mov    $0x0,%al
call   10a0 <VIM_MARB_GetJbufStartAddr@plt>
mov    %rax,%rdi
add    -0x8(%rbp),%rdi
sub    $0x4,%rdi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1090 <VIM_HIF_WriteSram@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIM_MAPI_JpegAutoDecode>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <VIM_JPEG_ResetState@plt>
xor    %eax,%eax
call   10c0 <VIM_IPP_Reset@plt>
xor    %eax,%eax
call   1080 <VIM_JPEG_SetDefaultHT@plt>
xor    %edi,%edi
call   1070 <VIM_JPEG_SetUseCustomQTEnable@plt>
xor    %edi,%edi
call   10b0 <VIM_JPEG_SetUseSameQTEnable@plt>
xor    %edi,%edi
call   1050 <VIM_JPEG_FeedHeaderEnable@plt>
xor    %eax,%eax
call   1060 <VIM_JPEG_ResetState@plt>
xor    %eax,%eax
call   1040 <VIM_MAPI_StartDecode@plt>
xor    %eax,%eax
call   10a0 <VIM_MARB_GetJbufStartAddr@plt>
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0x4(%rsp),%r14
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <VIM_HIF_ReadSram@plt>
xor    %eax,%eax
call   10a0 <VIM_MARB_GetJbufStartAddr@plt>
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1090 <VIM_HIF_WriteSram@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @VIM_MAPI_JpegAutoDecode(i64 %0) {
%2 = alloca i64
%3 = alloca [4 x i8]
store i64 %0, i64* %2
%4 = call i32 (...) @VIM_JPEG_ResetState()
%5 = call i32 (...) @VIM_IPP_Reset()
%6 = call i32 (...) @VIM_JPEG_SetDefaultHT()
%7 = call i32 @VIM_JPEG_SetUseCustomQTEnable(i32 0)
%8 = call i32 @VIM_JPEG_SetUseSameQTEnable(i32 0)
%9 = call i32 @VIM_JPEG_FeedHeaderEnable(i32 0)
%10 = call i32 (...) @VIM_JPEG_ResetState()
%11 = call i32 (...) @VIM_MAPI_StartDecode()
%12 = call i64 (...) @VIM_MARB_GetJbufStartAddr()
%13 = load i64, i64* %2
%14 = add i64 %12, %13
%15 = sub i64 %14, 4
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%17 = call i32 @VIM_HIF_ReadSram(i64 %15, i8* %16, i32 4)
%18 = call i64 (...) @VIM_MARB_GetJbufStartAddr()
%19 = load i64, i64* %2
%20 = add i64 %18, %19
%21 = sub i64 %20, 4
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%23 = call i32 @VIM_HIF_WriteSram(i64 %21, i8* %22, i32 4)
ret void
}

LLVM IR (-O2):
define void @VIM_MAPI_JpegAutoDecode(i64 %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @VIM_JPEG_ResetState()
%5 = tail call i32 (...) @VIM_IPP_Reset()
%6 = tail call i32 (...) @VIM_JPEG_SetDefaultHT()
%7 = tail call i32 @VIM_JPEG_SetUseCustomQTEnable(i32 0)
%8 = tail call i32 @VIM_JPEG_SetUseSameQTEnable(i32 0)
%9 = tail call i32 @VIM_JPEG_FeedHeaderEnable(i32 0)
%10 = tail call i32 (...) @VIM_JPEG_ResetState()
%11 = tail call i32 (...) @VIM_MAPI_StartDecode()
%12 = tail call i64 (...) @VIM_MARB_GetJbufStartAddr()
%13 = add i64 %0, -4
%14 = add i64 %13, %12
%15 = call i32 @VIM_HIF_ReadSram(i64 %14, i8* %3, i32 4)
%16 = call i64 (...) @VIM_MARB_GetJbufStartAddr()
%17 = add i64 %13, %16
%18 = call i32 @VIM_HIF_WriteSram(i64 %17, i8* %3, i32 4)
ret void
}