#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 */
scalar_t__ min_int(int const, int const);
int compare_intersect_int(const int *vec1, const int *vec2, size_t len) {
  int sum = 0;
  size_t i = 0;
  for (; i < len; i++, vec1++, vec2++)
    sum += min_int(vec1[0], vec2[0]);
  return sum;
}


x86 assembly (clang, -O0):
<compare_intersect_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1188 <compare_intersect_int+0x78>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1030 <min_int@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    1133 <compare_intersect_int+0x23>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_intersect_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdx,%rdx
je     114a <compare_intersect_int+0x3a>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%edi
mov    (%r14,%rbx,4),%esi
call   1030 <min_int@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <compare_intersect_int+0x20>
jmp    114c <compare_intersect_int+0x3c>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @compare_intersect_int(i32* nocapture %0, i32* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %19, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %15, %5 ], [ 0, %3 ]
%7 = phi i32 [ %14, %5 ], [ 0, %3 ]
%8 = phi i32* [ %16, %5 ], [ %0, %3 ]
%9 = phi i32* [ %17, %5 ], [ %1, %3 ]
%10 = load i32, i32* %8
%11 = load i32, i32* %9
%12 = tail call i64 @min_int(i32 %10, i32 %11)
%13 = trunc i64 %12 to i32
%14 = add i32 %7, %13
%15 = add nuw i64 %6, 1
%16 = getelementptr inbounds i32, i32* %8, i64 1
%17 = getelementptr inbounds i32, i32* %9, i64 1
%18 = icmp eq i64 %15, %2
br i1 %18, label %19, label %5
19: ; preds = %5, %3
%20 = phi i32 [ 0, %3 ], [ %14, %5 ]
ret i32 %20
}