#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 abs(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                          int);
void conv_copy(void *output_, const void *input_, int width, int height,
               int out_stride, int in_stride) {
  int copy_len = abs(out_stride);
  if (abs(in_stride) < copy_len)
    copy_len = abs(in_stride);
  const uint8_t *input = (const uint8_t *)input_;
  uint8_t *output = (uint8_t *)output_;
  for (int h = 0; h < height; h++, output += out_stride, input += in_stride)
    memcpy(output, input, copy_len);
}


x86 assembly (clang, -O0):
<conv_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x24(%rbp),%eax
jge    1165 <conv_copy+0x45>
mov    -0x20(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d0 <conv_copy+0xb0>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    117c <conv_copy+0x5c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%eax
neg    %eax
cmovs  %r8d,%eax
mov    %r9d,%r15d
neg    %r15d
cmovs  %r9d,%r15d
cmp    %eax,%r15d
cmovae %eax,%r15d
test   %ecx,%ecx
jle    116a <conv_copy+0x5a>
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
movslq %r8d,%r12
movslq %r9d,%r13
shl    $0x2,%r12
shl    $0x2,%r13
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <memcpy@plt>
add    %r12,%rbp
add    %r13,%rbx
add    $0xffffffff,%r14d
jne    1150 <conv_copy+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @conv_copy(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @llvm.abs.i32(i32 %4, i1 true)
%8 = tail call i32 @llvm.abs.i32(i32 %5, i1 true)
%9 = icmp ult i32 %8, %7
%10 = select i1 %9, i32 %8, i32 %7
%11 = icmp sgt i32 %3, 0
br i1 %11, label %12, label %17
12: ; preds = %6
%13 = bitcast i8* %0 to i32*
%14 = bitcast i8* %1 to i32*
%15 = sext i32 %4 to i64
%16 = sext i32 %5 to i64
br label %18
17: ; preds = %18, %6
ret void
18: ; preds = %12, %18
%19 = phi i32 [ 0, %12 ], [ %23, %18 ]
%20 = phi i32* [ %13, %12 ], [ %24, %18 ]
%21 = phi i32* [ %14, %12 ], [ %25, %18 ]
%22 = tail call i32 @memcpy(i32* %20, i32* %21, i32 %10)
%23 = add nuw nsw i32 %19, 1
%24 = getelementptr inbounds i32, i32* %20, i64 %15
%25 = getelementptr inbounds i32, i32* %21, i64 %16
%26 = icmp eq i32 %23, %3
br i1 %26, label %17, label %18
}