#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*/ stage_scale2x(unsigned char *, unsigned char *,
                                 unsigned char const *, unsigned char const *,
                                 unsigned char const *, unsigned int,
                                 unsigned int, unsigned int);
void scale2x(void *void_dst, unsigned dst_slice, const void *void_src,
             unsigned src_slice, unsigned pixel, unsigned width,
             unsigned height, unsigned opt) {
  unsigned char *dst = (unsigned char *)void_dst;
  const unsigned char *src = (const unsigned char *)void_src;
  unsigned count;
  assert(height >= 2);
  count = height;
  stage_scale2x((dst + (0) * dst_slice), (dst + (1) * dst_slice),
                (src + (0) * src_slice), (src + (0) * src_slice),
                (src + (1) * src_slice), pixel, width, opt);
  dst = (dst + (2) * dst_slice);
  count -= 2;
  while (count) {
    stage_scale2x((dst + (0) * dst_slice), (dst + (1) * dst_slice),
                  (src + (0) * src_slice), (src + (1) * src_slice),
                  (src + (2) * src_slice), pixel, width, opt);
    dst = (dst + (2) * dst_slice);
    src = (src + (1) * src_slice);
    --count;
  }
  stage_scale2x((dst + (0) * dst_slice), (dst + (1) * dst_slice),
                (src + (0) * src_slice), (src + (1) * src_slice),
                (src + (1) * src_slice), pixel, width, opt);
}


x86 assembly (clang, -O0):
<scale2x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x2,0x10(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
imul   $0x0,-0xc(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%rsi
mov    -0x38(%rbp),%rdx
imul   $0x0,-0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdx
mov    -0x38(%rbp),%rcx
imul   $0x0,-0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%rcx
mov    -0x38(%rbp),%r8
mov    -0x1c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%r8
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <stage_scale2x@plt>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1281 <scale2x+0x161>
mov    -0x30(%rbp),%rdi
imul   $0x0,-0xc(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%rsi
mov    -0x38(%rbp),%rdx
imul   $0x0,-0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdx
mov    -0x38(%rbp),%rcx
mov    -0x1c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%rcx
mov    -0x38(%rbp),%r8
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,%eax
add    %rax,%r8
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <stage_scale2x@plt>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x0,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e4 <scale2x+0xc4>
mov    -0x30(%rbp),%rdi
imul   $0x0,-0xc(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%rsi
mov    -0x38(%rbp),%rdx
imul   $0x0,-0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdx
mov    -0x38(%rbp),%rcx
mov    -0x1c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%rcx
mov    -0x38(%rbp),%r8
mov    -0x1c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%r8
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <stage_scale2x@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale2x>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0x60(%rsp),%r13d
xor    %edi,%edi
cmp    $0x2,%r13d
setae  %dil
call   1040 <assert@plt>
mov    %r15d,%eax
mov    %rax,0x18(%rsp)
lea    (%rbx,%rax,1),%rsi
mov    %r14,0x8(%rsp)
mov    %r14d,%eax
mov    %rax,0x20(%rsp)
lea    (%r12,%rax,1),%r8
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r12,%rcx
mov    %ebp,0x4(%rsp)
mov    %ebp,%r9d
mov    0x68(%rsp),%eax
push   %rax
mov    0x18(%rsp),%rax
push   %rax
call   1030 <stage_scale2x@plt>
mov    %r15,%rbp
add    $0x10,%rsp
add    %ebp,%ebp
add    %rbp,%rbx
add    $0xfffffffe,%r13d
je     1204 <scale2x+0xe4>
mov    0x8(%rsp),%rax
add    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x18(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
lea    (%rbx,%r14,1),%rsi
mov    0x20(%rsp),%rax
lea    (%r12,%rax,1),%r15
mov    0x8(%rsp),%rax
lea    (%r12,%rax,1),%r8
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
mov    0x4(%rsp),%r9d
mov    0x68(%rsp),%eax
push   %rax
push   0x18(%rsp)
call   1030 <stage_scale2x@plt>
add    $0x10,%rsp
add    %rbp,%rbx
mov    %r15,%r12
add    $0xffffffff,%r13d
jne    11c0 <scale2x+0xa0>
jmp    120c <scale2x+0xec>
mov    %r12,%r15
mov    0x18(%rsp),%r14
add    %rbx,%r14
mov    0x20(%rsp),%rcx
add    %r15,%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rcx,%r8
mov    0x4(%rsp),%r9d
mov    0x68(%rsp),%eax
push   %rax
push   0x18(%rsp)
call   1030 <stage_scale2x@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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