#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;
  for (i = 0; i < span_count; ++i) {
    compute_span_min_max(min_max_dest, source, source_stride, vector_size);
    min_max_dest += 2;
    source += vector_size * source_stride;
  }
}


x86 assembly (clang, -O0):
<compute_multiple_spans_min_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117f <compute_multiple_spans_min_max+0x6f>
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    -0x18(%rbp),%ecx
imul   -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1131 <compute_multiple_spans_min_max+0x21>
add    $0x20,%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    115e <compute_multiple_spans_min_max+0x4e>
mov    %r8d,%r12d
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %ecx,%eax
imul   %edx,%eax
movslq %eax,%r13
nopw   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
jne    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
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
store i32 0, i32* %11
br label %12
12: ; preds = %30, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = call i32 @compute_span_min_max(i8* %17, i8* %18, i32 %19, i32 %20)
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8* %23, i8** %6
%24 = load i32, i32* %9
%25 = load i32, i32* %8
%26 = mul nsw i32 %24, %25
%27 = load i8*, i8** %7
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8, i8* %27, i64 %28
store i8* %29, i8** %7
br label %30
30: ; preds = %16
%31 = load i32, i32* %11
%32 = add nsw i32 %31, 1
store i32 %32, i32* %11
br label %12
33: ; preds = %12
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 i32 [ 0, %7 ], [ %17, %10 ]
%12 = phi i8* [ %0, %7 ], [ %15, %10 ]
%13 = phi i8* [ %1, %7 ], [ %16, %10 ]
%14 = tail call i32 @compute_span_min_max(i8* %12, i8* %13, i32 %2, i32 %3)
%15 = getelementptr inbounds i8, i8* %12, i64 2
%16 = getelementptr inbounds i8, i8* %13, i64 %9
%17 = add nuw nsw i32 %11, 1
%18 = icmp eq i32 %17, %4
br i1 %18, label %19, label %10
19: ; preds = %10, %5
ret void
}