int manual_threshold_segmentation(the_image, out_image, hi, low, value, segment,
                                  rows, cols)
int rows, cols, segment;
short hi, low, **the_image, **out_image, value;
{
  threshold_image_array(the_image, out_image, hi, low, value, rows, cols);
  if (segment == 1)
    grow(out_image, value, rows, cols);
  return (1);
}


x86 assembly (clang, -O0):
<manual_threshold_segmentation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %r8w,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %cx,-0x14(%rbp)
mov    %ax,-0x16(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movswl -0x12(%rbp),%edx
movswl -0x14(%rbp),%ecx
movswl -0x16(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%eax
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <threshold_image_array@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    118f <manual_threshold_segmentation+0x6f>
mov    -0x10(%rbp),%rdi
movswl -0x16(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
mov    $0x0,%al
call   1030 <grow@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manual_threshold_segmentation>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9d,%r12d
mov    %rsi,%rbx
mov    0x48(%rsp),%r14d
mov    0x40(%rsp),%r15d
movswl %dx,%edx
movswl %cx,%ecx
movswl %r8w,%ebp
mov    %r14d,(%rsp)
mov    %ebp,%r8d
mov    %r15d,%r9d
xor    %eax,%eax
call   1040 <threshold_image_array@plt>
cmp    $0x1,%r12d
jne    116f <manual_threshold_segmentation+0x4f>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <grow@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @manual_threshold_segmentation(i16** %0, i16** %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i16**
%10 = alloca i16**
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = trunc i32 %2 to i16
%18 = trunc i32 %3 to i16
%19 = trunc i32 %4 to i16
store i16** %0, i16*** %9
store i16** %1, i16*** %10
store i16 %17, i16* %11
store i16 %18, i16* %12
store i16 %19, i16* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%20 = load i16**, i16*** %9
%21 = load i16**, i16*** %10
%22 = load i16, i16* %11
%23 = sext i16 %22 to i32
%24 = load i16, i16* %12
%25 = sext i16 %24 to i32
%26 = load i16, i16* %13
%27 = sext i16 %26 to i32
%28 = load i32, i32* %15
%29 = load i32, i32* %16
%30 = call i32 (i16**, i16**, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @threshold_image_array to i32 (i16**, i16**, i32, i32, i32, i32, i32, ...)*)(i16** %20, i16** %21, i32 %23, i32 %25, i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %14
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %40
33: ; preds = %8
%34 = load i16**, i16*** %10
%35 = load i16, i16* %13
%36 = sext i16 %35 to i32
%37 = load i32, i32* %15
%38 = load i32, i32* %16
%39 = call i32 (i16**, i32, i32, i32, ...) bitcast (i32 (...)* @grow to i32 (i16**, i32, i32, i32, ...)*)(i16** %34, i32 %36, i32 %37, i32 %38)
br label %40
40: ; preds = %33, %8
ret i32 1
}

LLVM IR (-O2):
define i32 @manual_threshold_segmentation(i16** %0, i16** %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = shl i32 %2, 16
%10 = ashr exact i32 %9, 16
%11 = shl i32 %3, 16
%12 = ashr exact i32 %11, 16
%13 = shl i32 %4, 16
%14 = ashr exact i32 %13, 16
%15 = tail call i32 (i16**, i16**, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @threshold_image_array to i32 (i16**, i16**, i32, i32, i32, i32, i32, ...)*)(i16** %0, i16** %1, i32 %10, i32 %12, i32 %14, i32 %6, i32 %7)
%16 = icmp eq i32 %5, 1
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 (i16**, i32, i32, i32, ...) bitcast (i32 (...)* @grow to i32 (i16**, i32, i32, i32, ...)*)(i16** %1, i32 %14, i32 %6, i32 %7)
br label %19
19: ; preds = %17, %8
ret i32 1
}