#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*/ free(void *);
void *malloc(int);
int /*<<< orphan*/ scale4x_buf(void *, unsigned int, void *, unsigned int,
                               void const *, unsigned int, unsigned int,
                               unsigned int, unsigned int);
void scale4x(void *void_dst, unsigned dst_slice, const void *void_src,
             unsigned src_slice, unsigned pixel, unsigned width,
             unsigned height) {
  unsigned mid_slice;
  void *mid;
  mid_slice = 2 * pixel * width;
  mid_slice = (mid_slice + 0x7) & ~0x7;
  mid = malloc(6 * mid_slice);
  if (!mid)
    return;
  scale4x_buf(void_dst, dst_slice, mid, mid_slice, void_src, src_slice, pixel,
              width, height);
  free(mid);
}


x86 assembly (clang, -O0):
<scale4x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
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    -0x20(%rbp),%eax
shl    $0x1,%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x7,%eax
and    $0xfffffff8,%eax
mov    %eax,-0x28(%rbp)
imul   $0x6,-0x28(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1187 <scale4x+0x57>
jmp    11c3 <scale4x+0x93>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    -0x24(%rbp),%r10d
mov    0x10(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <scale4x_buf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale4x>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebx
mov    %r8d,%r14d
mov    %ecx,0x4(%rsp)
mov    %rdx,0x10(%rsp)
mov    %esi,%r13d
mov    %rdi,%r15
mov    0x50(%rsp),%eax
mov    %rax,0x8(%rsp)
mov    %r8d,%eax
imul   %r9d,%eax
lea    (%rax,%rax,1),%r12d
add    $0x7,%r12d
and    $0xfffffff8,%r12d
lea    (%r12,%r12,1),%eax
lea    (%rax,%rax,2),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11c3 <scale4x+0x93>
mov    %rax,%rbp
sub    $0x8,%rsp
mov    %r15,%rdi
mov    %r13d,%esi
mov    %rax,%rdx
mov    %r12d,%ecx
mov    0x18(%rsp),%r8
mov    0xc(%rsp),%r9d
push   0x10(%rsp)
push   %rbx
push   %r14
call   1040 <scale4x_buf@plt>
add    $0x20,%rsp
mov    %rbp,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @scale4x(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = load i32, i32* %12
%18 = mul i32 2, %17
%19 = load i32, i32* %13
%20 = mul i32 %18, %19
store i32 %20, i32* %15
%21 = load i32, i32* %15
%22 = add i32 %21, 7
%23 = and i32 %22, -8
store i32 %23, i32* %15
%24 = load i32, i32* %15
%25 = mul i32 6, %24
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %16
%27 = load i8*, i8** %16
%28 = icmp ne i8* %27, null
br i1 %28, label %30, label %29
29: ; preds = %7
br label %43
30: ; preds = %7
%31 = load i8*, i8** %8
%32 = load i32, i32* %9
%33 = load i8*, i8** %16
%34 = load i32, i32* %15
%35 = load i8*, i8** %10
%36 = load i32, i32* %11
%37 = load i32, i32* %12
%38 = load i32, i32* %13
%39 = load i32, i32* %14
%40 = call i32 @scale4x_buf(i8* %31, i32 %32, i8* %33, i32 %34, i8* %35, i32 %36, i32 %37, i32 %38, i32 %39)
%41 = load i8*, i8** %16
%42 = call i32 @free(i8* %41)
br label %43
43: ; preds = %30, %29
ret void
}

LLVM IR (-O2):
define void @scale4x(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = shl i32 %4, 1
%9 = mul i32 %8, %5
%10 = add i32 %9, 7
%11 = and i32 %10, -8
%12 = mul i32 %11, 6
%13 = tail call i8* @malloc(i32 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %7
%16 = tail call i32 @scale4x_buf(i8* %0, i32 %1, i8* %13, i32 %11, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6)
%17 = tail call i32 @free(i8* %13)
br label %18
18: ; preds = %7, %15
ret void
}