#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 short VIM_JPEG_GetFrameCount();
int /*<<< orphan*/ VIM_USER_DelayMs(int);
void VIM_MAPI_Delay_Frame(unsigned char FrameCount) {
  unsigned short iStartFram, iCurrentFrame;
  unsigned long i = 800 * FrameCount;
  if (i == 0)
    i = 300;
  iStartFram = VIM_JPEG_GetFrameCount();
  while (i--) {
    iCurrentFrame = VIM_JPEG_GetFrameCount();
    if ((iCurrentFrame - iStartFram) > FrameCount)
      break;
    VIM_USER_DelayMs(1);
  }
}


x86 assembly (clang, -O0):
<VIM_MAPI_Delay_Frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
imul   $0x320,%eax,%eax
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1151 <VIM_MAPI_Delay_Frame+0x31>
movq   $0x12c,-0x10(%rbp)
mov    $0x0,%al
call   1030 <VIM_JPEG_GetFrameCount@plt>
mov    %ax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11aa <VIM_MAPI_Delay_Frame+0x8a>
mov    $0x0,%al
call   1030 <VIM_JPEG_GetFrameCount@plt>
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
movzwl -0x4(%rbp),%ecx
sub    %ecx,%eax
movzbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jle    119b <VIM_MAPI_Delay_Frame+0x7b>
jmp    11aa <VIM_MAPI_Delay_Frame+0x8a>
mov    $0x1,%edi
call   1040 <VIM_USER_DelayMs@plt>
jmp    115c <VIM_MAPI_Delay_Frame+0x3c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIM_MAPI_Delay_Frame>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
imul   $0x320,%edi,%ebp
xor    %eax,%eax
call   1030 <VIM_JPEG_GetFrameCount@plt>
test   %r14d,%r14d
mov    $0x12c,%ebx
cmovne %rbp,%rbx
test   %rbx,%rbx
je     1174 <VIM_MAPI_Delay_Frame+0x54>
movzwl %ax,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <VIM_JPEG_GetFrameCount@plt>
movzwl %ax,%eax
sub    %ebp,%eax
cmp    %r14d,%eax
jg     1174 <VIM_MAPI_Delay_Frame+0x54>
add    $0xffffffffffffffff,%rbx
mov    $0x1,%edi
call   1040 <VIM_USER_DelayMs@plt>
test   %rbx,%rbx
jne    1150 <VIM_MAPI_Delay_Frame+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @VIM_MAPI_Delay_Frame(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i16
%4 = alloca i16
%5 = alloca i64
store i8 %0, i8* %2
%6 = load i8, i8* %2
%7 = zext i8 %6 to i32
%8 = mul nsw i32 800, %7
%9 = sext i32 %8 to i64
store i64 %9, i64* %5
%10 = load i64, i64* %5
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i64 300, i64* %5
br label %13
13: ; preds = %12, %1
%14 = call zeroext i16 (...) @VIM_JPEG_GetFrameCount()
store i16 %14, i16* %3
br label %15
15: ; preds = %30, %13
%16 = load i64, i64* %5
%17 = add i64 %16, -1
store i64 %17, i64* %5
%18 = icmp ne i64 %16, 0
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = call zeroext i16 (...) @VIM_JPEG_GetFrameCount()
store i16 %20, i16* %4
%21 = load i16, i16* %4
%22 = zext i16 %21 to i32
%23 = load i16, i16* %3
%24 = zext i16 %23 to i32
%25 = sub nsw i32 %22, %24
%26 = load i8, i8* %2
%27 = zext i8 %26 to i32
%28 = icmp sgt i32 %25, %27
br i1 %28, label %29, label %30
29: ; preds = %19
br label %32
30: ; preds = %19
%31 = call i32 @VIM_USER_DelayMs(i32 1)
br label %15
32: ; preds = %29, %15
ret void
}

LLVM IR (-O2):
define void @VIM_MAPI_Delay_Frame(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = mul nuw nsw i32 %2, 800
%4 = zext i32 %3 to i64
%5 = icmp eq i8 %0, 0
%6 = tail call zeroext i16 (...) @VIM_JPEG_GetFrameCount()
%7 = select i1 %5, i64 300, i64 %4
%8 = icmp eq i64 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %1
%10 = zext i16 %6 to i32
br label %11
11: ; preds = %9, %18
%12 = phi i64 [ %7, %9 ], [ %13, %18 ]
%13 = add nsw i64 %12, -1
%14 = tail call zeroext i16 (...) @VIM_JPEG_GetFrameCount()
%15 = zext i16 %14 to i32
%16 = sub nsw i32 %15, %10
%17 = icmp sgt i32 %16, %2
br i1 %17, label %21, label %18
18: ; preds = %11
%19 = tail call i32 @VIM_USER_DelayMs(i32 1)
%20 = icmp eq i64 %13, 0
br i1 %20, label %21, label %11
21: ; preds = %18, %11, %1
ret void
}