int special_opening(the_image, out_image, value, threshold, number, rows, cols)
int number;
short **the_image, **out_image, threshold, value;
long cols, rows;
{
  int a, b, count, i, j, k;
  thinning(the_image, out_image, value, threshold, 1, rows, cols);
  if (number > 1) {
    count = 1;
    while (count < number) {
      count++;
      thinning(the_image, out_image, value, threshold, 1, rows, cols);
    }
  }
  dilation(the_image, out_image, value, threshold, rows, cols);
  return (1);
}


x86 assembly (clang, -O0):
<special_opening>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %ecx,%eax
mov    0x10(%rbp),%rcx
mov    %dx,%cx
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cx,-0x12(%rbp)
mov    %ax,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movswl -0x12(%rbp),%edx
movswl -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r9
mov    0x10(%rbp),%rax
mov    $0x1,%r8d
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <thinning@plt>
cmpl   $0x1,-0x18(%rbp)
jle    11cb <special_opening+0xab>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c6 <special_opening+0xa6>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movswl -0x12(%rbp),%edx
movswl -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r9
mov    0x10(%rbp),%rax
mov    $0x1,%r8d
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <thinning@plt>
jmp    1183 <special_opening+0x63>
jmp    11cb <special_opening+0xab>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movswl -0x12(%rbp),%edx
movswl -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
mov    $0x0,%al
call   1040 <dilation@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<special_opening>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8d,%ebp
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x40(%rsp),%rax
movswl %dx,%ebx
movswl %cx,%r14d
mov    %rax,(%rsp)
mov    %ebx,%edx
mov    %r14d,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1030 <thinning@plt>
cmp    $0x2,%ebp
jl     1199 <special_opening+0x79>
add    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x40(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    $0x1,%r8d
mov    %r15,%r9
xor    %eax,%eax
call   1030 <thinning@plt>
add    $0xffffffff,%ebp
jne    1170 <special_opening+0x50>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    %r15,%r8
mov    0x40(%rsp),%r9
xor    %eax,%eax
call   1040 <dilation@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @special_opening(i16** %0, i16** %1, i32 %2, i32 %3, i32 %4, i64 %5, i64 %6) {
%8 = alloca i16**
%9 = alloca i16**
%10 = alloca i16
%11 = alloca i16
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = trunc i32 %2 to i16
%22 = trunc i32 %3 to i16
store i16** %0, i16*** %8
store i16** %1, i16*** %9
store i16 %21, i16* %10
store i16 %22, i16* %11
store i32 %4, i32* %12
store i64 %5, i64* %13
store i64 %6, i64* %14
%23 = load i16**, i16*** %8
%24 = load i16**, i16*** %9
%25 = load i16, i16* %10
%26 = sext i16 %25 to i32
%27 = load i16, i16* %11
%28 = sext i16 %27 to i32
%29 = load i64, i64* %13
%30 = load i64, i64* %14
%31 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @thinning to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %23, i16** %24, i32 %26, i32 %28, i32 1, i64 %29, i64 %30)
%32 = load i32, i32* %12
%33 = icmp sgt i32 %32, 1
br i1 %33, label %34, label %52
34: ; preds = %7
store i32 1, i32* %17
br label %35
35: ; preds = %39, %34
%36 = load i32, i32* %17
%37 = load i32, i32* %12
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %51
39: ; preds = %35
%40 = load i32, i32* %17
%41 = add nsw i32 %40, 1
store i32 %41, i32* %17
%42 = load i16**, i16*** %8
%43 = load i16**, i16*** %9
%44 = load i16, i16* %10
%45 = sext i16 %44 to i32
%46 = load i16, i16* %11
%47 = sext i16 %46 to i32
%48 = load i64, i64* %13
%49 = load i64, i64* %14
%50 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @thinning to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %42, i16** %43, i32 %45, i32 %47, i32 1, i64 %48, i64 %49)
br label %35
51: ; preds = %35
br label %52
52: ; preds = %51, %7
%53 = load i16**, i16*** %8
%54 = load i16**, i16*** %9
%55 = load i16, i16* %10
%56 = sext i16 %55 to i32
%57 = load i16, i16* %11
%58 = sext i16 %57 to i32
%59 = load i64, i64* %13
%60 = load i64, i64* %14
%61 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @dilation to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %53, i16** %54, i32 %56, i32 %58, i64 %59, i64 %60)
ret i32 1
}

LLVM IR (-O2):
define i32 @special_opening(i16** %0, i16** %1, i32 %2, i32 %3, i32 %4, i64 %5, i64 %6) {
%8 = shl i32 %2, 16
%9 = ashr exact i32 %8, 16
%10 = shl i32 %3, 16
%11 = ashr exact i32 %10, 16
%12 = tail call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @thinning to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %0, i16** %1, i32 %9, i32 %11, i32 1, i64 %5, i64 %6)
%13 = icmp sgt i32 %4, 1
br i1 %13, label %14, label %19
14: ; preds = %7, %14
%15 = phi i32 [ %16, %14 ], [ 1, %7 ]
%16 = add nuw nsw i32 %15, 1
%17 = tail call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @thinning to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %0, i16** %1, i32 %9, i32 %11, i32 1, i64 %5, i64 %6)
%18 = icmp eq i32 %16, %4
br i1 %18, label %19, label %14
19: ; preds = %14, %7
%20 = tail call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @dilation to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %0, i16** %1, i32 %9, i32 %11, i64 %5, i64 %6)
ret i32 1
}