#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*/ memcpy(unsigned char *, unsigned char *, int);
void stub1(unsigned char *, int, unsigned char *, int);
void stub2(unsigned char *, unsigned char *, unsigned char *, int,
           unsigned char *, int);
void IMAGE_STRETCH2X(
    unsigned char *dest_ptr, int dest_dx, int dest_dy, int dest_pitch,
    int dest_bpp, unsigned char *src_ptr, int src_dx, int src_dy, int src_pitch,
    int src_bpp, void (*row_func)(unsigned char *, int, unsigned char *, int),
    void (*row2x_func)(unsigned char *, unsigned char *, unsigned char *, int,
                       unsigned char *, int)) {
  register unsigned char *d1 = dest_ptr;
  register unsigned char *d12 = dest_ptr + dest_pitch;
  register unsigned char *d2 = dest_ptr + dest_pitch * 2;
  register unsigned char *s = src_ptr;
  register int dest_dx_bytes = dest_dx * dest_bpp;
  register int count = src_dy;
  if (count) {
    (*row_func)(d1, dest_dx, s, src_dx);
    s += src_pitch;
    while (--count) {
      (*row2x_func)(d1, d12, d2, dest_dx, s, src_dx);
      d1 += 2 * dest_pitch;
      d12 += 2 * dest_pitch;
      d2 += 2 * dest_pitch;
      s += src_pitch;
    }
    memcpy(d12, d1, dest_dx_bytes);
  }
}


x86 assembly (clang, -O0):
<IMAGE_STRETCH2X>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    0x18(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     1244 <IMAGE_STRETCH2X+0x134>
mov    0x30(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    0x10(%rbp),%ecx
call   *%rax
mov    0x20(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
cmp    $0x0,%eax
je     1234 <IMAGE_STRETCH2X+0x124>
mov    0x38(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x40(%rbp),%r8
mov    0x10(%rbp),%r9d
call   *%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    0x20(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
jmp    11b3 <IMAGE_STRETCH2X+0xa3>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1030 <memcpy@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IMAGE_STRETCH2X>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x68(%rsp),%r14d
test   %r14d,%r14d
je     11dc <IMAGE_STRETCH2X+0xcc>
mov    %r9,%rbp
mov    %r8d,%r15d
mov    %ecx,%edx
mov    %rdi,%rbx
mov    0x88(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x70(%rsp),%eax
mov    %eax,(%rsp)
mov    0x60(%rsp),%ecx
imul   %esi,%r15d
mov    %edx,%r13d
movslq %edx,%rax
mov    %rax,0x8(%rsp)
mov    %esi,0x14(%rsp)
mov    %r9,%rdx
mov    %ecx,%r12d
call   *0x80(%rsp)
add    $0xffffffff,%r14d
je     11eb <IMAGE_STRETCH2X+0xdb>
mov    %r15d,0x10(%rsp)
add    %r13d,%r13d
movslq %r13d,%rax
mov    %rax,0x20(%rsp)
movslq (%rsp),%rax
mov    %rax,(%rsp)
add    %rax,%rbp
mov    0x14(%rsp),%r13d
mov    0x18(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    0x8(%rsp),%rax
lea    (%rbx,%rax,1),%rsi
mov    0x20(%rsp),%rax
add    %rax,%rbx
mov    %rbx,%rdx
mov    %r13d,%ecx
mov    %rbp,%r8
mov    %r12d,%r9d
call   *%r15
add    (%rsp),%rbp
add    $0xffffffff,%r14d
jne    11a0 <IMAGE_STRETCH2X+0x90>
mov    0x8(%rsp),%rdi
add    %rbx,%rdi
mov    0x10(%rsp),%r15d
jmp    11f3 <IMAGE_STRETCH2X+0xe3>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rdi
add    %rbx,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
define void @IMAGE_STRETCH2X(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i32 %9, void (i8*, i32, i8*, i32)* %10, void (i8*, i8*, i8*, i32, i8*, i32)* %11) {
%13 = alloca i8*
%14 = alloca i32
%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 void (i8*, i32, i8*, i32)*
%24 = alloca void (i8*, i8*, i8*, i32, i8*, i32)*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca i8*
%29 = alloca i32
%30 = alloca i32
store i8* %0, i8** %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i8* %5, i8** %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store i32 %9, i32* %22
store void (i8*, i32, i8*, i32)* %10, void (i8*, i32, i8*, i32)** %23
store void (i8*, i8*, i8*, i32, i8*, i32)* %11, void (i8*, i8*, i8*, i32, i8*, i32)** %24
%31 = load i8*, i8** %13
store i8* %31, i8** %25
%32 = load i8*, i8** %13
%33 = load i32, i32* %16
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8* %35, i8** %26
%36 = load i8*, i8** %13
%37 = load i32, i32* %16
%38 = mul nsw i32 %37, 2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
store i8* %40, i8** %27
%41 = load i8*, i8** %18
store i8* %41, i8** %28
%42 = load i32, i32* %14
%43 = load i32, i32* %17
%44 = mul nsw i32 %42, %43
store i32 %44, i32* %29
%45 = load i32, i32* %20
store i32 %45, i32* %30
%46 = load i32, i32* %30
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %94
48: ; preds = %12
%49 = load void (i8*, i32, i8*, i32)*, void (i8*, i32, i8*, i32)** %23
%50 = load i8*, i8** %25
%51 = load i32, i32* %14
%52 = load i8*, i8** %28
%53 = load i32, i32* %19
%54 = load i32, i32* %21
%55 = load i8*, i8** %28
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds i8, i8* %55, i64 %56
store i8* %57, i8** %28
br label %58
58: ; preds = %62, %48
%59 = load i32, i32* %30
%60 = add nsw i32 %59, -1
store i32 %60, i32* %30
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %89
62: ; preds = %58
%63 = load void (i8*, i8*, i8*, i32, i8*, i32)*, void (i8*, i8*, i8*, i32, i8*, i32)** %24
%64 = load i8*, i8** %25
%65 = load i8*, i8** %26
%66 = load i8*, i8** %27
%67 = load i32, i32* %14
%68 = load i8*, i8** %28
%69 = load i32, i32* %19
%70 = load i32, i32* %16
%71 = mul nsw i32 2, %70
%72 = load i8*, i8** %25
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8, i8* %72, i64 %73
store i8* %74, i8** %25
%75 = load i32, i32* %16
%76 = mul nsw i32 2, %75
%77 = load i8*, i8** %26
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds i8, i8* %77, i64 %78
store i8* %79, i8** %26
%80 = load i32, i32* %16
%81 = mul nsw i32 2, %80
%82 = load i8*, i8** %27
%83 = sext i32 %81 to i64
%84 = getelementptr inbounds i8, i8* %82, i64 %83
store i8* %84, i8** %27
%85 = load i32, i32* %21
%86 = load i8*, i8** %28
%87 = sext i32 %85 to i64
%88 = getelementptr inbounds i8, i8* %86, i64 %87
store i8* %88, i8** %28
br label %58
89: ; preds = %58
%90 = load i8*, i8** %26
%91 = load i8*, i8** %25
%92 = load i32, i32* %29
%93 = call i32 @memcpy(i8* %90, i8* %91, i32 %92)
br label %94
94: ; preds = %89, %12
ret void
}

LLVM IR (-O2):
define void @IMAGE_STRETCH2X(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i32 %9, void (i8*, i32, i8*, i32)* nocapture %10, void (i8*, i8*, i8*, i32, i8*, i32)* nocapture %11) {
%13 = shl nsw i32 %3, 1
%14 = sext i32 %13 to i64
%15 = mul nsw i32 %4, %1
%16 = icmp eq i32 %7, 0
br i1 %16, label %37, label %17
17: ; preds = %12
%18 = sext i32 %3 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
tail call void %10(i8* %0, i32 %1, i8* %5, i32 %6)
%20 = sext i32 %8 to i64
%21 = add nsw i32 %7, -1
%22 = icmp eq i32 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %17, %23
%24 = phi i32 [ %31, %23 ], [ %21, %17 ]
%25 = phi i8* [ %29, %23 ], [ %0, %17 ]
%26 = phi i8* [ %28, %23 ], [ %5, %17 ]
%27 = phi i8* [ %30, %23 ], [ %19, %17 ]
%28 = getelementptr inbounds i8, i8* %26, i64 %20
%29 = getelementptr inbounds i8, i8* %25, i64 %14
tail call void %11(i8* %25, i8* %27, i8* %29, i32 %1, i8* %28, i32 %6)
%30 = getelementptr inbounds i8, i8* %27, i64 %14
%31 = add nsw i32 %24, -1
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %23
33: ; preds = %23, %17
%34 = phi i8* [ %19, %17 ], [ %30, %23 ]
%35 = phi i8* [ %0, %17 ], [ %29, %23 ]
%36 = tail call i32 @memcpy(i8* %34, i8* %35, i32 %15)
br label %37
37: ; preds = %33, %12
ret void
}