#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ p264_mc_clip1(int);
int p264_tapfilter1(int /*<<< orphan*/ *);
void mc_hh(uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride,
           int i_width, int i_height) {
  int x, y;
  for (y = 0; y < i_height; y++) {
    for (x = 0; x < i_width; x++) {
      dst[x] = p264_mc_clip1((p264_tapfilter1(&src[x]) + 16) >> 5);
    }
    src += i_src_stride;
    dst += i_dst_stride;
  }
}


x86 assembly (clang, -O0):
<mc_hh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11d8 <mc_hh+0xb8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11a0 <mc_hh+0x80>
mov    -0x8(%rbp),%rdi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <p264_tapfilter1@plt>
mov    %eax,%edi
add    $0x10,%edi
sar    $0x5,%edi
call   1040 <p264_mc_clip1@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1158 <mc_hh+0x38>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1145 <mc_hh+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mc_hh>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0x8(%rsp)
mov    %r9d,0xc(%rsp)
test   %r9d,%r9d
jle    11b4 <mc_hh+0x94>
mov    %rdx,%rbp
mov    %rdi,%rbx
movslq %esi,%r13
movslq %ecx,%rax
mov    0x8(%rsp),%r14d
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
shl    $0x2,%r13
shl    $0x2,%r14
xor    %r15d,%r15d
jmp    1183 <mc_hh+0x63>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15d
add    0x10(%rsp),%rbp
add    %r13,%rbx
cmp    0xc(%rsp),%r15d
je     11b4 <mc_hh+0x94>
cmpl   $0x0,0x8(%rsp)
jle    1170 <mc_hh+0x50>
xor    %r12d,%r12d
nopl   (%rax)
lea    (%rbx,%r12,1),%rdi
call   1030 <p264_tapfilter1@plt>
lea    0x10(%rax),%edi
sar    $0x5,%edi
call   1040 <p264_mc_clip1@plt>
mov    %eax,0x0(%rbp,%r12,1)
add    $0x4,%r12
cmp    %r12,%r14
jne    1190 <mc_hh+0x70>
jmp    1170 <mc_hh+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mc_hh(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 0, i32* %14
br label %15
15: ; preds = %49, %6
%16 = load i32, i32* %14
%17 = load i32, i32* %12
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %52
19: ; preds = %15
store i32 0, i32* %13
br label %20
20: ; preds = %37, %19
%21 = load i32, i32* %13
%22 = load i32, i32* %11
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32*, i32** %7
%26 = load i32, i32* %13
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = call i32 @p264_tapfilter1(i32* %28)
%30 = add nsw i32 %29, 16
%31 = ashr i32 %30, 5
%32 = call i32 @p264_mc_clip1(i32 %31)
%33 = load i32*, i32** %9
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
br label %37
37: ; preds = %24
%38 = load i32, i32* %13
%39 = add nsw i32 %38, 1
store i32 %39, i32* %13
br label %20
40: ; preds = %20
%41 = load i32, i32* %8
%42 = load i32*, i32** %7
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i32, i32* %42, i64 %43
store i32* %44, i32** %7
%45 = load i32, i32* %10
%46 = load i32*, i32** %9
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i32, i32* %46, i64 %47
store i32* %48, i32** %9
br label %49
49: ; preds = %40
%50 = load i32, i32* %14
%51 = add nsw i32 %50, 1
store i32 %51, i32* %14
br label %15
52: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @mc_hh(i32* %0, i32 %1, i32* nocapture writeonly %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %32
8: ; preds = %6
%9 = icmp sgt i32 %4, 0
%10 = sext i32 %1 to i64
%11 = sext i32 %3 to i64
%12 = zext i32 %4 to i64
br label %13
13: ; preds = %8, %27
%14 = phi i32 [ 0, %8 ], [ %30, %27 ]
%15 = phi i32* [ %0, %8 ], [ %28, %27 ]
%16 = phi i32* [ %2, %8 ], [ %29, %27 ]
br i1 %9, label %17, label %27
17: ; preds = %13, %17
%18 = phi i64 [ %25, %17 ], [ 0, %13 ]
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = tail call i32 @p264_tapfilter1(i32* %19)
%21 = add nsw i32 %20, 16
%22 = ashr i32 %21, 5
%23 = tail call i32 @p264_mc_clip1(i32 %22)
%24 = getelementptr inbounds i32, i32* %16, i64 %18
store i32 %23, i32* %24
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %17
27: ; preds = %17, %13
%28 = getelementptr inbounds i32, i32* %15, i64 %10
%29 = getelementptr inbounds i32, i32* %16, i64 %11
%30 = add nuw nsw i32 %14, 1
%31 = icmp eq i32 %30, %5
br i1 %31, label %32, label %13
32: ; preds = %27, %6
ret void
}