#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_span_min_max(unsigned char *, unsigned char const *,
                                        int, int);
void compute_multiple_spans_min_max(unsigned char *min_max_dest,
                                    const unsigned char *source,
                                    int source_stride, int vector_size,
                                    int span_count) {
  int i;
  int increment = vector_size * source_stride;
  for (i = span_count; i > 0; --i) {
    compute_span_min_max(min_max_dest, source, source_stride, vector_size);
    min_max_dest += 2;
    source += increment;
  }
}


x86 assembly (clang, -O0):
<compute_multiple_spans_min_max>:
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)
mov    -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1182 <compute_multiple_spans_min_max+0x72>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <compute_span_min_max@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    113a <compute_multiple_spans_min_max+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_multiple_spans_min_max>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
jle    1162 <compute_multiple_spans_min_max+0x52>
mov    %r8d,%r12d
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %ecx,%eax
imul   %edx,%eax
movslq %eax,%r13
add    $0x1,%r12d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <compute_span_min_max@plt>
add    $0x2,%rbx
add    %r13,%rbp
add    $0xffffffff,%r12d
cmp    $0x1,%r12d
ja     1140 <compute_multiple_spans_min_max+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @compute_multiple_spans_min_max(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = mul nsw i32 %13, %14
store i32 %15, i32* %12
%16 = load i32, i32* %10
store i32 %16, i32* %11
br label %17
17: ; preds = %32, %5
%18 = load i32, i32* %11
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %17
%21 = load i8*, i8** %6
%22 = load i8*, i8** %7
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 @compute_span_min_max(i8* %21, i8* %22, i32 %23, i32 %24)
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8* %27, i8** %6
%28 = load i32, i32* %12
%29 = load i8*, i8** %7
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8* %31, i8** %7
br label %32
32: ; preds = %20
%33 = load i32, i32* %11
%34 = add nsw i32 %33, -1
store i32 %34, i32* %11
br label %17
35: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @compute_multiple_spans_min_max(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %19
7: ; preds = %5
%8 = mul nsw i32 %3, %2
%9 = sext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i8* [ %0, %7 ], [ %15, %10 ]
%12 = phi i32 [ %4, %7 ], [ %17, %10 ]
%13 = phi i8* [ %1, %7 ], [ %16, %10 ]
%14 = tail call i32 @compute_span_min_max(i8* %11, i8* %13, i32 %2, i32 %3)
%15 = getelementptr inbounds i8, i8* %11, i64 2
%16 = getelementptr inbounds i8, i8* %13, i64 %9
%17 = add nsw i32 %12, -1
%18 = icmp ugt i32 %12, 1
br i1 %18, label %10, label %19
19: ; preds = %10, %5
ret void
}