#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_scale3x(unsigned char *, unsigned char *,
                                 unsigned char *, unsigned char const *,
                                 unsigned char const *, unsigned char const *,
                                 unsigned int, unsigned int, unsigned int);
void scale3x(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_scale3x((dst + (0) * dst_slice), (dst + (1) * dst_slice),
                (dst + (2) * dst_slice), (src + (0) * src_slice),
                (src + (0) * src_slice), (src + (1) * src_slice), pixel, width,
                opt);
  dst = (dst + (3) * dst_slice);
  count -= 2;
  while (count) {
    stage_scale3x((dst + (0) * dst_slice), (dst + (1) * dst_slice),
                  (dst + (2) * dst_slice), (src + (0) * src_slice),
                  (src + (1) * src_slice), (src + (2) * src_slice), pixel,
                  width, opt);
    dst = (dst + (3) * dst_slice);
    src = (src + (1) * src_slice);
    --count;
  }
  stage_scale3x((dst + (0) * dst_slice), (dst + (1) * dst_slice),
                (dst + (2) * dst_slice), (src + (0) * src_slice),
                (src + (1) * src_slice), (src + (1) * src_slice), pixel, width,
                opt);
}


x86 assembly (clang, -O0):
<scale3x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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   1030 <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    -0x30(%rbp),%rdx
mov    -0xc(%rbp),%eax
shl    $0x1,%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
imul   $0x0,-0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%r8
mov    -0x38(%rbp),%r9
mov    -0x1c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%r9
mov    -0x20(%rbp),%r11d
mov    -0x24(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <stage_scale3x@plt>
mov    -0x30(%rbp),%rax
imul   $0x3,-0xc(%rbp),%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     12a5 <scale3x+0x185>
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    -0x30(%rbp),%rdx
mov    -0xc(%rbp),%eax
shl    $0x1,%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    -0x38(%rbp),%r9
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,%eax
add    %rax,%r9
mov    -0x20(%rbp),%r11d
mov    -0x24(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <stage_scale3x@plt>
mov    -0x30(%rbp),%rax
imul   $0x3,-0xc(%rbp),%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    11f6 <scale3x+0xd6>
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    -0x30(%rbp),%rdx
mov    -0xc(%rbp),%eax
shl    $0x1,%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    -0x38(%rbp),%r9
mov    -0x1c(%rbp),%eax
shl    $0x0,%eax
mov    %eax,%eax
add    %rax,%r9
mov    -0x20(%rbp),%r11d
mov    -0x24(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <stage_scale3x@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale3x>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%ebp
mov    %r8,0x10(%rsp)
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %esi,%r15d
mov    %rdi,%rbx
mov    0x70(%rsp),%r12d
xor    %edi,%edi
cmp    $0x2,%r12d
setae  %dil
call   1030 <assert@plt>
mov    %r15d,%eax
mov    %rax,0x18(%rsp)
lea    (%rbx,%rax,1),%rsi
lea    (%r15,%r15,1),%eax
mov    %rax,0x28(%rsp)
lea    (%rbx,%rax,1),%rdx
mov    %r14,0x8(%rsp)
mov    %r14d,%eax
mov    %rax,0x20(%rsp)
lea    (%rax,%r13,1),%r9
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r13,%rcx
mov    %r13,%r8
mov    0x80(%rsp),%eax
push   %rax
mov    %rbp,0x40(%rsp)
push   %rbp
push   0x28(%rsp)
call   1040 <stage_scale3x@plt>
add    $0x20,%rsp
lea    (%r15,%r15,2),%ebp
add    %rbp,%rbx
add    $0xfffffffe,%r12d
je     1223 <scale3x+0x103>
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    0x28(%rsp),%rax
lea    (%rbx,%rax,1),%rdx
mov    0x20(%rsp),%rax
lea    (%rax,%r13,1),%r15
mov    0x8(%rsp),%rax
lea    (%rax,%r13,1),%r9
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r13,%rcx
mov    %r15,%r8
mov    0x80(%rsp),%eax
push   %rax
push   0x40(%rsp)
push   0x28(%rsp)
call   1040 <stage_scale3x@plt>
add    $0x20,%rsp
add    %rbp,%rbx
mov    %r15,%r13
add    $0xffffffff,%r12d
jne    11d0 <scale3x+0xb0>
jmp    122b <scale3x+0x10b>
mov    %r13,%r15
mov    0x18(%rsp),%r14
add    %rbx,%r14
mov    0x28(%rsp),%rdx
add    %rbx,%rdx
mov    0x20(%rsp),%r8
add    %r15,%r8
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rcx
mov    %r8,%r9
mov    0x80(%rsp),%eax
push   %rax
push   0x40(%rsp)
push   0x28(%rsp)
call   1040 <stage_scale3x@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @scale3x(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** %17
%38 = load i32, i32* %10
%39 = mul i32 2, %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 0, %48
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
%52 = load i8*, i8** %18
%53 = load i32, i32* %12
%54 = mul i32 1, %53
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
%57 = load i32, i32* %13
%58 = load i32, i32* %14
%59 = load i32, i32* %16
%60 = call i32 @stage_scale3x(i8* %31, i8* %36, i8* %41, i8* %46, i8* %51, i8* %56, i32 %57, i32 %58, i32 %59)
%61 = load i8*, i8** %17
%62 = load i32, i32* %10
%63 = mul i32 3, %62
%64 = zext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
store i8* %65, i8** %17
%66 = load i32, i32* %19
%67 = sub i32 %66, 2
store i32 %67, i32* %19
br label %68
68: ; preds = %71, %8
%69 = load i32, i32* %19
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %118
71: ; preds = %68
%72 = load i8*, i8** %17
%73 = load i32, i32* %10
%74 = mul i32 0, %73
%75 = zext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %72, i64 %75
%77 = load i8*, i8** %17
%78 = load i32, i32* %10
%79 = mul i32 1, %78
%80 = zext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %77, i64 %80
%82 = load i8*, i8** %17
%83 = load i32, i32* %10
%84 = mul i32 2, %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 0, %88
%90 = zext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
%92 = load i8*, i8** %18
%93 = load i32, i32* %12
%94 = mul i32 1, %93
%95 = zext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %92, i64 %95
%97 = load i8*, i8** %18
%98 = load i32, i32* %12
%99 = mul i32 2, %98
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %97, i64 %100
%102 = load i32, i32* %13
%103 = load i32, i32* %14
%104 = load i32, i32* %16
%105 = call i32 @stage_scale3x(i8* %76, i8* %81, i8* %86, i8* %91, i8* %96, i8* %101, i32 %102, i32 %103, i32 %104)
%106 = load i8*, i8** %17
%107 = load i32, i32* %10
%108 = mul i32 3, %107
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %106, i64 %109
store i8* %110, i8** %17
%111 = load i8*, i8** %18
%112 = load i32, i32* %12
%113 = mul i32 1, %112
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %111, i64 %114
store i8* %115, i8** %18
%116 = load i32, i32* %19
%117 = add i32 %116, -1
store i32 %117, i32* %19
br label %68
118: ; preds = %68
%119 = load i8*, i8** %17
%120 = load i32, i32* %10
%121 = mul i32 0, %120
%122 = zext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %119, i64 %122
%124 = load i8*, i8** %17
%125 = load i32, i32* %10
%126 = mul i32 1, %125
%127 = zext i32 %126 to i64
%128 = getelementptr inbounds i8, i8* %124, i64 %127
%129 = load i8*, i8** %17
%130 = load i32, i32* %10
%131 = mul i32 2, %130
%132 = zext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %129, i64 %132
%134 = load i8*, i8** %18
%135 = load i32, i32* %12
%136 = mul i32 0, %135
%137 = zext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %134, i64 %137
%139 = load i8*, i8** %18
%140 = load i32, i32* %12
%141 = mul i32 1, %140
%142 = zext i32 %141 to i64
%143 = getelementptr inbounds i8, i8* %139, i64 %142
%144 = load i8*, i8** %18
%145 = load i32, i32* %12
%146 = mul i32 1, %145
%147 = zext i32 %146 to i64
%148 = getelementptr inbounds i8, i8* %144, i64 %147
%149 = load i32, i32* %13
%150 = load i32, i32* %14
%151 = load i32, i32* %16
%152 = call i32 @stage_scale3x(i8* %123, i8* %128, i8* %133, i8* %138, i8* %143, i8* %148, i32 %149, i32 %150, i32 %151)
ret void
}

LLVM IR (-O2):
define void @scale3x(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 = shl i32 %1, 1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = zext i32 %3 to i64
%18 = getelementptr inbounds i8, i8* %2, i64 %17
%19 = tail call i32 @stage_scale3x(i8* %0, i8* %13, i8* %16, i8* %2, i8* %2, i8* %18, i32 %4, i32 %5, i32 %7)
%20 = mul i32 %1, 3
%21 = zext i32 %20 to i64
%22 = add i32 %6, -2
%23 = getelementptr inbounds i8, i8* %0, i64 %21
%24 = icmp eq i32 %22, 0
br i1 %24, label %40, label %25
25: ; preds = %8
%26 = shl i32 %3, 1
%27 = zext i32 %26 to i64
br label %28
28: ; preds = %25, %28
%29 = phi i8* [ %23, %25 ], [ %38, %28 ]
%30 = phi i32 [ %22, %25 ], [ %37, %28 ]
%31 = phi i8* [ %2, %25 ], [ %34, %28 ]
%32 = getelementptr inbounds i8, i8* %29, i64 %12
%33 = getelementptr inbounds i8, i8* %29, i64 %15
%34 = getelementptr inbounds i8, i8* %31, i64 %17
%35 = getelementptr inbounds i8, i8* %31, i64 %27
%36 = tail call i32 @stage_scale3x(i8* %29, i8* %32, i8* %33, i8* %31, i8* %34, i8* %35, i32 %4, i32 %5, i32 %7)
%37 = add i32 %30, -1
%38 = getelementptr inbounds i8, i8* %29, i64 %21
%39 = icmp eq i32 %37, 0
br i1 %39, label %40, label %28
40: ; preds = %28, %8
%41 = phi i8* [ %2, %8 ], [ %34, %28 ]
%42 = phi i8* [ %23, %8 ], [ %38, %28 ]
%43 = getelementptr inbounds i8, i8* %42, i64 %12
%44 = getelementptr inbounds i8, i8* %42, i64 %15
%45 = getelementptr inbounds i8, i8* %41, i64 %17
%46 = tail call i32 @stage_scale3x(i8* %42, i8* %43, i8* %44, i8* %41, i8* %45, i8* %45, i32 %4, i32 %5, i32 %7)
ret void
}