#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*/ assert(int);
int /*<<< orphan*/ vcir8_hzoom(unsigned char *, int, int, int, void *, int, int,
                               int);
int /*<<< orphan*/ vcir8_vzoom2(void *, int, int, int, unsigned char const *,
                                int, int, int, int, int);
void vc_image_resize_bytes2(unsigned char *dest_ptr, int destw, int desth,
                            int dest_pitch, const unsigned char *src_ptr,
                            int srcw, int src_pitch, int pos, int step,
                            int limit, int smooth_flag, void *bufptr,
                            int tmp_buf_size) {
  int i, j, buf_pitch;
  if (desth <= 0 || destw <= 0 || srcw <= 0)
    return;
  buf_pitch = (srcw + 15) & ~15;
  j = desth;
  if (j > 64)
    j = 64;
  if (buf_pitch * j > tmp_buf_size) {
    j = 32;
    if (buf_pitch * j > tmp_buf_size) {
      j = tmp_buf_size / buf_pitch;
      if (j > 16)
        j = 16;
      assert(j > 0);
    }
  }
  for (i = 0; i < desth; i += j) {
    if (i + j > desth) {
      j = desth - i;
    }
    vcir8_vzoom2(bufptr, srcw, j, buf_pitch, src_ptr, src_pitch, pos, step,
                 limit, smooth_flag);
    vcir8_hzoom(dest_ptr, destw, j, dest_pitch, bufptr, srcw, buf_pitch,
                smooth_flag);
    pos += j * step;
    dest_ptr += j * dest_pitch;
  }
}


x86 assembly (clang, -O0):
<vc_image_resize_bytes2>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1182 <vc_image_resize_bytes2+0x52>
cmpl   $0x0,-0x14(%rbp)
jle    1182 <vc_image_resize_bytes2+0x52>
cmpl   $0x0,-0x2c(%rbp)
jg     1187 <vc_image_resize_bytes2+0x57>
jmp    12bf <vc_image_resize_bytes2+0x18f>
mov    -0x2c(%rbp),%eax
add    $0xf,%eax
and    $0xfffffff0,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x40,-0x34(%rbp)
jle    11aa <vc_image_resize_bytes2+0x7a>
movl   $0x40,-0x34(%rbp)
mov    -0x38(%rbp),%eax
imul   -0x34(%rbp),%eax
cmp    0x40(%rbp),%eax
jle    1202 <vc_image_resize_bytes2+0xd2>
movl   $0x20,-0x34(%rbp)
mov    -0x38(%rbp),%eax
imul   -0x34(%rbp),%eax
cmp    0x40(%rbp),%eax
jle    11fd <vc_image_resize_bytes2+0xcd>
mov    0x40(%rbp),%eax
cltd
idivl  -0x38(%rbp)
mov    %eax,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
jle    11ec <vc_image_resize_bytes2+0xbc>
movl   $0x10,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    1202 <vc_image_resize_bytes2+0xd2>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12bf <vc_image_resize_bytes2+0x18f>
mov    -0x30(%rbp),%eax
add    -0x34(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    122d <vc_image_resize_bytes2+0xfd>
mov    -0x18(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%ebx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <vcir8_vzoom2@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    0x38(%rbp),%r8
mov    -0x2c(%rbp),%r9d
mov    -0x38(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <vcir8_hzoom@plt>
mov    -0x34(%rbp),%eax
imul   0x20(%rbp),%eax
add    0x18(%rbp),%eax
mov    %eax,0x18(%rbp)
mov    -0x34(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x34(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1209 <vc_image_resize_bytes2+0xd9>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<vc_image_resize_bytes2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %esi,%esi
jle    12b4 <vc_image_resize_bytes2+0x184>
mov    %edx,%r12d
test   %edx,%edx
jle    12b4 <vc_image_resize_bytes2+0x184>
test   %r9d,%r9d
jle    12b4 <vc_image_resize_bytes2+0x184>
mov    %ecx,%r10d
mov    %esi,%ebx
mov    0x90(%rsp),%eax
lea    0xf(%r9),%r15d
and    $0xfffffff0,%r15d
cmp    $0x40,%r12d
mov    $0x40,%r14d
cmovb  %r12d,%r14d
mov    %r15d,%ecx
imul   %r14d,%ecx
cmp    %eax,%ecx
jle    11d5 <vc_image_resize_bytes2+0xa5>
mov    %r15d,%ecx
shl    $0x5,%ecx
mov    $0x20,%r14d
cmp    %eax,%ecx
jle    11d5 <vc_image_resize_bytes2+0xa5>
cltd
idiv   %r15d
cmp    $0x10,%eax
mov    $0x10,%r14d
cmovl  %eax,%r14d
mov    %rdi,0x8(%rsp)
xor    %edi,%edi
test   %eax,%eax
setg   %dil
mov    %r9,%r13
mov    %r8,%rbp
mov    %r10d,0x4(%rsp)
call   1050 <assert@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%r10d
mov    %rbp,%r8
mov    %r13,%r9
mov    %r15,0x18(%rsp)
mov    0x68(%rsp),%r13d
xor    %r15d,%r15d
mov    %ebx,0x4(%rsp)
mov    %r12d,0x14(%rsp)
mov    %r8,0x20(%rsp)
mov    %rdi,0x8(%rsp)
lea    (%r14,%r15,1),%eax
mov    %r12d,%ebp
sub    %r15d,%ebp
cmp    %r12d,%eax
cmovle %r14d,%ebp
mov    0x88(%rsp),%rdi
mov    %r9d,%esi
mov    %ebp,%edx
mov    0x18(%rsp),%r14
mov    %r14d,%ecx
mov    0x20(%rsp),%r8
mov    %r9,%rbx
mov    0x60(%rsp),%r9d
mov    0x80(%rsp),%eax
push   %rax
mov    0x80(%rsp),%eax
push   %rax
mov    0x80(%rsp),%eax
push   %rax
push   %r13
mov    %r10d,%r12d
call   1040 <vcir8_vzoom2@plt>
add    $0x20,%rsp
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    0x88(%rsp),%r8
mov    %ebx,%r9d
mov    0x80(%rsp),%eax
push   %rax
push   %r14
call   1030 <vcir8_hzoom@plt>
mov    0x18(%rsp),%rdi
mov    %r12d,%r10d
mov    0x24(%rsp),%r12d
mov    %rbx,%r9
add    $0x10,%rsp
mov    %ebp,%eax
mov    0x70(%rsp),%ecx
imul   %ecx,%eax
add    %r13d,%eax
mov    %ebp,%ecx
imul   %r10d,%ecx
movslq %ecx,%rcx
add    %rcx,%rdi
add    %ebp,%r15d
mov    %ebp,%r14d
mov    %eax,%r13d
cmp    %r12d,%r15d
jl     11f0 <vc_image_resize_bytes2+0xc0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vc_image_resize_bytes2(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i8* %11, i32 %12) {
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i8*
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
store i8* %0, i8** %14
store i32 %1, i32* %15
store i32 %2, i32* %16
store i32 %3, i32* %17
store i8* %4, i8** %18
store i32 %5, i32* %19
store i32 %6, i32* %20
store i32 %7, i32* %21
store i32 %8, i32* %22
store i32 %9, i32* %23
store i32 %10, i32* %24
store i8* %11, i8** %25
store i32 %12, i32* %26
%30 = load i32, i32* %16
%31 = icmp sle i32 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %13
%33 = load i32, i32* %15
%34 = icmp sle i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %19
%37 = icmp sle i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35, %32, %13
br label %123
39: ; preds = %35
%40 = load i32, i32* %19
%41 = add nsw i32 %40, 15
%42 = and i32 %41, -16
store i32 %42, i32* %29
%43 = load i32, i32* %16
store i32 %43, i32* %28
%44 = load i32, i32* %28
%45 = icmp sgt i32 %44, 64
br i1 %45, label %46, label %47
46: ; preds = %39
store i32 64, i32* %28
br label %47
47: ; preds = %46, %39
%48 = load i32, i32* %29
%49 = load i32, i32* %28
%50 = mul nsw i32 %48, %49
%51 = load i32, i32* %26
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %72
53: ; preds = %47
store i32 32, i32* %28
%54 = load i32, i32* %29
%55 = load i32, i32* %28
%56 = mul nsw i32 %54, %55
%57 = load i32, i32* %26
%58 = icmp sgt i32 %56, %57
br i1 %58, label %59, label %71
59: ; preds = %53
%60 = load i32, i32* %26
%61 = load i32, i32* %29
%62 = sdiv i32 %60, %61
store i32 %62, i32* %28
%63 = load i32, i32* %28
%64 = icmp sgt i32 %63, 16
br i1 %64, label %65, label %66
65: ; preds = %59
store i32 16, i32* %28
br label %66
66: ; preds = %65, %59
%67 = load i32, i32* %28
%68 = icmp sgt i32 %67, 0
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
br label %71
71: ; preds = %66, %53
br label %72
72: ; preds = %71, %47
store i32 0, i32* %27
br label %73
73: ; preds = %119, %72
%74 = load i32, i32* %27
%75 = load i32, i32* %16
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %123
77: ; preds = %73
%78 = load i32, i32* %27
%79 = load i32, i32* %28
%80 = add nsw i32 %78, %79
%81 = load i32, i32* %16
%82 = icmp sgt i32 %80, %81
br i1 %82, label %83, label %87
83: ; preds = %77
%84 = load i32, i32* %16
%85 = load i32, i32* %27
%86 = sub nsw i32 %84, %85
store i32 %86, i32* %28
br label %87
87: ; preds = %83, %77
%88 = load i8*, i8** %25
%89 = load i32, i32* %19
%90 = load i32, i32* %28
%91 = load i32, i32* %29
%92 = load i8*, i8** %18
%93 = load i32, i32* %20
%94 = load i32, i32* %21
%95 = load i32, i32* %22
%96 = load i32, i32* %23
%97 = load i32, i32* %24
%98 = call i32 @vcir8_vzoom2(i8* %88, i32 %89, i32 %90, i32 %91, i8* %92, i32 %93, i32 %94, i32 %95, i32 %96, i32 %97)
%99 = load i8*, i8** %14
%100 = load i32, i32* %15
%101 = load i32, i32* %28
%102 = load i32, i32* %17
%103 = load i8*, i8** %25
%104 = load i32, i32* %19
%105 = load i32, i32* %29
%106 = load i32, i32* %24
%107 = call i32 @vcir8_hzoom(i8* %99, i32 %100, i32 %101, i32 %102, i8* %103, i32 %104, i32 %105, i32 %106)
%108 = load i32, i32* %28
%109 = load i32, i32* %22
%110 = mul nsw i32 %108, %109
%111 = load i32, i32* %21
%112 = add nsw i32 %111, %110
store i32 %112, i32* %21
%113 = load i32, i32* %28
%114 = load i32, i32* %17
%115 = mul nsw i32 %113, %114
%116 = load i8*, i8** %14
%117 = sext i32 %115 to i64
%118 = getelementptr inbounds i8, i8* %116, i64 %117
store i8* %118, i8** %14
br label %119
119: ; preds = %87
%120 = load i32, i32* %28
%121 = load i32, i32* %27
%122 = add nsw i32 %121, %120
store i32 %122, i32* %27
br label %73
123: ; preds = %38, %73
ret void
}

LLVM IR (-O2):
define void @vc_image_resize_bytes2(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i8* %11, i32 %12) {
%14 = icmp slt i32 %2, 1
%15 = icmp slt i32 %1, 1
%16 = or i1 %15, %14
%17 = icmp slt i32 %5, 1
%18 = or i1 %16, %17
br i1 %18, label %56, label %19
19: ; preds = %13
%20 = add nuw nsw i32 %5, 15
%21 = and i32 %20, -16
%22 = icmp ult i32 %2, 64
%23 = select i1 %22, i32 %2, i32 64
%24 = mul nsw i32 %21, %23
%25 = icmp sgt i32 %24, %12
br i1 %25, label %26, label %36
26: ; preds = %19
%27 = shl nsw i32 %21, 5
%28 = icmp sgt i32 %27, %12
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = sdiv i32 %12, %21
%31 = icmp slt i32 %30, 16
%32 = select i1 %31, i32 %30, i32 16
%33 = icmp sgt i32 %30, 0
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
br label %36
36: ; preds = %19, %29, %26
%37 = phi i32 [ 32, %26 ], [ %32, %29 ], [ %23, %19 ]
br label %38
38: ; preds = %36, %38
%39 = phi i8* [ %53, %38 ], [ %0, %36 ]
%40 = phi i32 [ %46, %38 ], [ %37, %36 ]
%41 = phi i32 [ %54, %38 ], [ 0, %36 ]
%42 = phi i32 [ %50, %38 ], [ %7, %36 ]
%43 = add nsw i32 %40, %41
%44 = icmp sgt i32 %43, %2
%45 = sub nsw i32 %2, %41
%46 = select i1 %44, i32 %45, i32 %40
%47 = tail call i32 @vcir8_vzoom2(i8* %11, i32 %5, i32 %46, i32 %21, i8* %4, i32 %6, i32 %42, i32 %8, i32 %9, i32 %10)
%48 = tail call i32 @vcir8_hzoom(i8* %39, i32 %1, i32 %46, i32 %3, i8* %11, i32 %5, i32 %21, i32 %10)
%49 = mul nsw i32 %46, %8
%50 = add nsw i32 %49, %42
%51 = mul nsw i32 %46, %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %39, i64 %52
%54 = add nsw i32 %46, %41
%55 = icmp slt i32 %54, %2
br i1 %55, label %38, label %56
56: ; preds = %38, %13
ret void
}