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


x86 assembly (clang, -O0):
<dilate_erode>:
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    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <conv_de@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%r8d
mov    $0xfff,%ecx
call   1060 <segment_img@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dilate_erode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r13
lea    (%rbx,%rbx,1),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1040 <conv_de@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    $0xfff,%ecx
mov    %ebx,%r8d
call   1060 <segment_img@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 @dilate_erode(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 i32
%12 = 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
%13 = load i32, i32* %10
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 2
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i16*
store i16* %18, i16** %12
%19 = load i16*, i16** %6
%20 = load i16*, i16** %12
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = load i16*, i16** %12
%24 = load i16*, i16** %7
%25 = load i32, i32* %8
%26 = load i32, i32* %10
%27 = call i32 @segment_img(i16* %23, i16* %24, i32 %25, i32 4095, i32 %26)
%28 = load i16*, i16** %12
%29 = call i32 @free(i16* %28)
ret void
}

LLVM IR (-O2):
define void @dilate_erode(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*
tail call void @conv_de(i16* %0, i16* %8, i32 %3, i32 %4)
%9 = tail call i32 @segment_img(i16* %8, i16* %1, i32 %2, i32 4095, i32 %4)
%10 = tail call i32 @free(i16* %8)
ret void
}