#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__ funcion(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, double);
int main(int argc, const char *argv[]) {
  double suma = 0.0;
  unsigned i;
  for (i = 0; i < 100000; i++) {
    suma += funcion(i, i % 5);
  }
  printf("suma = %g\n", suma);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x186a0,-0x1c(%rbp)
jae    1185 <main+0x65>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%esi
call   1040 <funcion@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <main+0x25>
movsd  -0x18(%rbp),%xmm0
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
mov    $0xcccccccd,%r14d
nop
movsd  %xmm0,(%rsp)
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
mov    %ebx,%esi
sub    %eax,%esi
mov    %ebx,%edi
call   1040 <funcion@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%ebx
cmp    $0x186a0,%ebx
jne    1130 <main+0x10>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"suma = %g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
store i32 0, i32* %7
br label %8
8: ; preds = %19, %2
%9 = load i32, i32* %7
%10 = icmp ult i32 %9, 100000
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %7
%13 = load i32, i32* %7
%14 = urem i32 %13, 5
%15 = call i64 @funcion(i32 %12, i32 %14)
%16 = sitofp i64 %15 to double
%17 = load double, double* %6
%18 = fadd double %17, %16
store double %18, double* %6
br label %19
19: ; preds = %11
%20 = load i32, i32* %7
%21 = add i32 %20, 1
store i32 %21, i32* %7
br label %8
22: ; preds = %8
%23 = load double, double* %6
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"suma = %g\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %10, %3 ]
%5 = phi double [ 0.000000e+00, %2 ], [ %9, %3 ]
%6 = urem i32 %4, 5
%7 = tail call i64 @funcion(i32 %4, i32 %6)
%8 = sitofp i64 %7 to double
%9 = fadd double %5, %8
%10 = add nuw nsw i32 %4, 1
%11 = icmp eq i32 %10, 100000
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %9)
ret i32 0
}