#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__ calc_error(int, int);
float calc_total_error(int *a, int *b, const int size) {
  float sum = 0.0f;
  for (int i = 0; i < size; i++)
    sum += calc_error(a[i], b[i]);
  return sum;
}


x86 assembly (clang, -O0):
<calc_total_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1176 <calc_total_error+0x66>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <calc_error@plt>
cvtsi2ss %rax,%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1132 <calc_total_error+0x22>
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_total_error>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    116c <calc_total_error+0x5c>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movss  %xmm0,0x4(%rsp)
mov    (%r15,%rbx,4),%edi
mov    (%r14,%rbx,4),%esi
call   1030 <calc_error@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <calc_total_error+0x20>
jmp    116f <calc_total_error+0x5f>
xorps  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define float @calc_total_error(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %9
7: ; preds = %9, %3
%8 = phi float [ 0.000000e+00, %3 ], [ %18, %9 ]
ret float %8
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %19, %9 ]
%11 = phi float [ 0.000000e+00, %5 ], [ %18, %9 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %10
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %1, i64 %10
%15 = load i32, i32* %14
%16 = tail call i64 @calc_error(i32 %13, i32 %15)
%17 = sitofp i64 %16 to float
%18 = fadd float %11, %17
%19 = add nuw nsw i64 %10, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %7, label %9
}