#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_HAPI_SetCaptureParameter(unsigned short, unsigned short);
unsigned short VIM_HAPI_SetThumbParameter(unsigned short, unsigned short);
unsigned char V5H_Capture_Parameter(unsigned short CapWidth,
                                    unsigned short CapHeight,
                                    unsigned short ThumWidth) {
  unsigned short ThumHeight, Error;
  {
    ThumHeight =
        (unsigned short)(((unsigned long)ThumWidth * (unsigned long)CapHeight) /
                         CapWidth);
    Error = VIM_HAPI_SetCaptureParameter(CapWidth, CapHeight);
    if (Error)
      return Error;
    Error = VIM_HAPI_SetThumbParameter(ThumWidth, ThumHeight);
    return Error;
  }
}


x86 assembly (clang, -O0):
<V5H_Capture_Parameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %di,%dx
mov    %dx,-0x4(%rbp)
mov    %cx,-0x6(%rbp)
mov    %ax,-0x8(%rbp)
movzwl -0x8(%rbp),%eax
movzwl -0x6(%rbp),%ecx
imul   %rcx,%rax
movzwl -0x4(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    %ax,-0xa(%rbp)
mov    -0x4(%rbp),%ax
movzwl %ax,%edi
movzwl -0x6(%rbp),%esi
call   1030 <VIM_HAPI_SetCaptureParameter@plt>
mov    %ax,-0xc(%rbp)
cmpw   $0x0,-0xc(%rbp)
je     1181 <V5H_Capture_Parameter+0x61>
mov    -0xc(%rbp),%ax
mov    %al,-0x1(%rbp)
jmp    119c <V5H_Capture_Parameter+0x7c>
mov    -0x8(%rbp),%ax
movzwl %ax,%edi
movzwl -0xa(%rbp),%esi
call   1040 <VIM_HAPI_SetThumbParameter@plt>
mov    %ax,-0xc(%rbp)
mov    -0xc(%rbp),%ax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<V5H_Capture_Parameter>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <VIM_HAPI_SetCaptureParameter@plt>
test   %ax,%ax
jne    114e <V5H_Capture_Parameter+0x2e>
movzwl %r14w,%edi
movzwl %bp,%eax
imul   %edi,%eax
movzwl %bx,%ecx
xor    %edx,%edx
div    %ecx
movzwl %ax,%esi
call   1040 <VIM_HAPI_SetThumbParameter@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @V5H_Capture_Parameter(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i8
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
store i16 %0, i16* %5
store i16 %1, i16* %6
store i16 %2, i16* %7
%10 = load i16, i16* %7
%11 = zext i16 %10 to i64
%12 = load i16, i16* %6
%13 = zext i16 %12 to i64
%14 = mul i64 %11, %13
%15 = load i16, i16* %5
%16 = zext i16 %15 to i64
%17 = udiv i64 %14, %16
%18 = trunc i64 %17 to i16
store i16 %18, i16* %8
%19 = load i16, i16* %5
%20 = load i16, i16* %6
%21 = call zeroext i16 @VIM_HAPI_SetCaptureParameter(i16 zeroext %19, i16 zeroext %20)
store i16 %21, i16* %9
%22 = load i16, i16* %9
%23 = icmp ne i16 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %3
%25 = load i16, i16* %9
%26 = trunc i16 %25 to i8
store i8 %26, i8* %4
br label %33
27: ; preds = %3
%28 = load i16, i16* %7
%29 = load i16, i16* %8
%30 = call zeroext i16 @VIM_HAPI_SetThumbParameter(i16 zeroext %28, i16 zeroext %29)
store i16 %30, i16* %9
%31 = load i16, i16* %9
%32 = trunc i16 %31 to i8
store i8 %32, i8* %4
br label %33
33: ; preds = %27, %24
%34 = load i8, i8* %4
ret i8 %34
}

LLVM IR (-O2):
define zeroext i8 @V5H_Capture_Parameter(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2) {
%4 = tail call zeroext i16 @VIM_HAPI_SetCaptureParameter(i16 zeroext %0, i16 zeroext %1)
%5 = icmp eq i16 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = zext i16 %2 to i32
%8 = zext i16 %1 to i32
%9 = mul nuw i32 %7, %8
%10 = zext i16 %0 to i32
%11 = udiv i32 %9, %10
%12 = trunc i32 %11 to i16
%13 = tail call zeroext i16 @VIM_HAPI_SetThumbParameter(i16 zeroext %2, i16 zeroext %12)
br label %14
14: ; preds = %3, %6
%15 = phi i16 [ %13, %6 ], [ %4, %3 ]
%16 = trunc i16 %15 to i8
ret i8 %16
}