#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*/ compute_multiple_spans_min_max(unsigned char *,
                                                  unsigned char const *, int,
                                                  int, int);
int /*<<< orphan*/ compute_span_min_max(unsigned char *, unsigned char const *,
                                        int, int);
void compute_line_min_max_spans(unsigned char *min_max_dest,
                                const unsigned char *source, int source_stride,
                                int first_vector_size, int full_span_count,
                                int last_vector_size, int tile_size) {
  compute_span_min_max(min_max_dest, source, source_stride, first_vector_size);
  source += source_stride * first_vector_size;
  min_max_dest += 2;
  compute_multiple_spans_min_max(min_max_dest, source, source_stride, tile_size,
                                 full_span_count);
  source += source_stride * full_span_count * tile_size;
  min_max_dest += 2 * full_span_count;
  compute_span_min_max(min_max_dest, source, source_stride, last_vector_size);
}


x86 assembly (clang, -O0):
<compute_line_min_max_spans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <compute_span_min_max@plt>
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <compute_multiple_spans_min_max@plt>
mov    -0x14(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
imul   0x10(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <compute_span_min_max@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_line_min_max_spans>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%r15
mov    0x40(%rsp),%r14d
call   1030 <compute_span_min_max@plt>
imul   %r12d,%ebp
movslq %ebp,%rbp
add    %r13,%rbp
lea    0x2(%r15),%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %ebx,%r8d
call   1040 <compute_multiple_spans_min_max@plt>
mov    %ebx,%eax
imul   %r12d,%eax
imul   %r14d,%eax
movslq %eax,%rsi
add    %rbp,%rsi
add    %ebx,%ebx
movslq %ebx,%rax
lea    (%r15,%rax,1),%rdi
add    $0x2,%rdi
mov    %r12d,%edx
mov    0x4(%rsp),%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <compute_span_min_max@plt>

LLVM IR (-O0):
define void @compute_line_min_max_spans(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = load i32, i32* %10
%18 = load i32, i32* %11
%19 = call i32 @compute_span_min_max(i8* %15, i8* %16, i32 %17, i32 %18)
%20 = load i32, i32* %10
%21 = load i32, i32* %11
%22 = mul nsw i32 %20, %21
%23 = load i8*, i8** %9
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %9
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = load i8*, i8** %9
%30 = load i32, i32* %10
%31 = load i32, i32* %14
%32 = load i32, i32* %12
%33 = call i32 @compute_multiple_spans_min_max(i8* %28, i8* %29, i32 %30, i32 %31, i32 %32)
%34 = load i32, i32* %10
%35 = load i32, i32* %12
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %14
%38 = mul nsw i32 %36, %37
%39 = load i8*, i8** %9
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i8, i8* %39, i64 %40
store i8* %41, i8** %9
%42 = load i32, i32* %12
%43 = mul nsw i32 2, %42
%44 = load i8*, i8** %8
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %8
%47 = load i8*, i8** %8
%48 = load i8*, i8** %9
%49 = load i32, i32* %10
%50 = load i32, i32* %13
%51 = call i32 @compute_span_min_max(i8* %47, i8* %48, i32 %49, i32 %50)
ret void
}

LLVM IR (-O2):
define void @compute_line_min_max_spans(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = tail call i32 @compute_span_min_max(i8* %0, i8* %1, i32 %2, i32 %3)
%9 = mul nsw i32 %3, %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = tail call i32 @compute_multiple_spans_min_max(i8* %12, i8* %11, i32 %2, i32 %6, i32 %4)
%14 = mul nsw i32 %4, %2
%15 = mul nsw i32 %14, %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %11, i64 %16
%18 = shl nsw i32 %4, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %12, i64 %19
%21 = tail call i32 @compute_span_min_max(i8* %20, i8* %17, i32 %2, i32 %5)
ret void
}