#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*/ dilate_erode(short *, short *, int, int, int);
int /*<<< orphan*/ free(short *);
scalar_t__ malloc(int);
void close_img(short int *src, short int *dst, int n, int ncol, int npix) {
  short int *tmp;
  tmp = (short int *)malloc(npix * sizeof(short int));
  dilate_erode(src, tmp, n, ncol, npix);
  dilate_erode(tmp, dst, 17 - n, ncol, npix);
  free(tmp);
}


x86 assembly (clang, -O0):
<close_img>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <dilate_erode@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x11,%edx
sub    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <dilate_erode@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_img>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %rsi,%r15
mov    %rdi,%r12
lea    (%rbx,%rbx,1),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r13d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1040 <dilate_erode@plt>
mov    $0x11,%edx
sub    %r13d,%edx
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1040 <dilate_erode@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @close_img(i16* %0, i16* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i16*
%7 = alloca i16*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i16*
store i16* %0, i16** %6
store i16* %1, i16** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %10
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 2
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i16*
store i16* %17, i16** %11
%18 = load i16*, i16** %6
%19 = load i16*, i16** %11
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = call i32 @dilate_erode(i16* %18, i16* %19, i32 %20, i32 %21, i32 %22)
%24 = load i16*, i16** %11
%25 = load i16*, i16** %7
%26 = load i32, i32* %8
%27 = sub nsw i32 17, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %10
%30 = call i32 @dilate_erode(i16* %24, i16* %25, i32 %27, i32 %28, i32 %29)
%31 = load i16*, i16** %11
%32 = call i32 @free(i16* %31)
ret void
}

LLVM IR (-O2):
define void @close_img(i16* %0, i16* %1, i32 %2, i32 %3, i32 %4) {
%6 = shl i32 %4, 1
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i16*
%9 = tail call i32 @dilate_erode(i16* %0, i16* %8, i32 %2, i32 %3, i32 %4)
%10 = sub nsw i32 17, %2
%11 = tail call i32 @dilate_erode(i16* %8, i16* %1, i32 %10, i32 %3, i32 %4)
%12 = tail call i32 @free(i16* %8)
ret void
}