#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__ bla(int);
int foo(void) {
  int i;
  int sum;
  for (i = 0; i < 4; i++) {
    sum += bla(i);
    sum += bla(2 * i);
    sum += bla(3 * i);
    sum += bla(4 * i);
    sum += bla(5 * i);
    sum += bla(6 * i);
    sum += bla(7 * i);
    sum += bla(8 * i);
  }
  return sum;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    11ec <foo+0xdc>
mov    -0x4(%rbp),%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
shl    $0x1,%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
imul   $0x3,-0x4(%rbp),%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
shl    $0x2,%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
imul   $0x5,-0x4(%rbp),%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
imul   $0x6,-0x4(%rbp),%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
imul   $0x7,-0x4(%rbp),%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
shl    $0x3,%edi
call   1030 <bla@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <foo+0xf>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rax
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
xor    %edi,%edi
call   1030 <bla@plt>
mov    $0x1,%edi
call   1030 <bla@plt>
mov    $0x2,%edi
call   1030 <bla@plt>
mov    $0x3,%edi
call   1030 <bla@plt>
mov    $0x4,%edi
call   1030 <bla@plt>
mov    $0x5,%edi
call   1030 <bla@plt>
mov    $0x6,%edi
call   1030 <bla@plt>
mov    $0x7,%edi
call   1030 <bla@plt>
mov    $0x8,%edi
call   1030 <bla@plt>
mov    $0x2,%edi
call   1030 <bla@plt>
mov    $0x4,%edi
call   1030 <bla@plt>
mov    $0x6,%edi
call   1030 <bla@plt>
mov    $0x8,%edi
call   1030 <bla@plt>
mov    $0xa,%edi
call   1030 <bla@plt>
mov    $0xc,%edi
call   1030 <bla@plt>
mov    $0xe,%edi
call   1030 <bla@plt>
mov    $0x10,%edi
call   1030 <bla@plt>
mov    $0x3,%edi
call   1030 <bla@plt>
mov    $0x6,%edi
call   1030 <bla@plt>
mov    $0x9,%edi
call   1030 <bla@plt>
mov    $0xc,%edi
call   1030 <bla@plt>
mov    $0xf,%edi
call   1030 <bla@plt>
mov    $0x12,%edi
call   1030 <bla@plt>
mov    $0x15,%edi
call   1030 <bla@plt>
mov    $0x18,%edi
pop    %rax
jmp    1030 <bla@plt>

LLVM IR (-O0):
define i32 @foo() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %62, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 4
br i1 %5, label %6, label %65
6: ; preds = %3
%7 = load i32, i32* %1
%8 = call i64 @bla(i32 %7)
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %8
%12 = trunc i64 %11 to i32
store i32 %12, i32* %2
%13 = load i32, i32* %1
%14 = mul nsw i32 2, %13
%15 = call i64 @bla(i32 %14)
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = add nsw i64 %17, %15
%19 = trunc i64 %18 to i32
store i32 %19, i32* %2
%20 = load i32, i32* %1
%21 = mul nsw i32 3, %20
%22 = call i64 @bla(i32 %21)
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = add nsw i64 %24, %22
%26 = trunc i64 %25 to i32
store i32 %26, i32* %2
%27 = load i32, i32* %1
%28 = mul nsw i32 4, %27
%29 = call i64 @bla(i32 %28)
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = add nsw i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %2
%34 = load i32, i32* %1
%35 = mul nsw i32 5, %34
%36 = call i64 @bla(i32 %35)
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = add nsw i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %2
%41 = load i32, i32* %1
%42 = mul nsw i32 6, %41
%43 = call i64 @bla(i32 %42)
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = add nsw i64 %45, %43
%47 = trunc i64 %46 to i32
store i32 %47, i32* %2
%48 = load i32, i32* %1
%49 = mul nsw i32 7, %48
%50 = call i64 @bla(i32 %49)
%51 = load i32, i32* %2
%52 = sext i32 %51 to i64
%53 = add nsw i64 %52, %50
%54 = trunc i64 %53 to i32
store i32 %54, i32* %2
%55 = load i32, i32* %1
%56 = mul nsw i32 8, %55
%57 = call i64 @bla(i32 %56)
%58 = load i32, i32* %2
%59 = sext i32 %58 to i64
%60 = add nsw i64 %59, %57
%61 = trunc i64 %60 to i32
store i32 %61, i32* %2
br label %62
62: ; preds = %6
%63 = load i32, i32* %1
%64 = add nsw i32 %63, 1
store i32 %64, i32* %1
br label %3
65: ; preds = %3
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
define i32 @foo() {
%1 = tail call i64 @bla(i32 0)
%2 = tail call i64 @bla(i32 0)
%3 = tail call i64 @bla(i32 0)
%4 = tail call i64 @bla(i32 0)
%5 = tail call i64 @bla(i32 0)
%6 = tail call i64 @bla(i32 0)
%7 = tail call i64 @bla(i32 0)
%8 = tail call i64 @bla(i32 0)
%9 = tail call i64 @bla(i32 1)
%10 = tail call i64 @bla(i32 2)
%11 = tail call i64 @bla(i32 3)
%12 = tail call i64 @bla(i32 4)
%13 = tail call i64 @bla(i32 5)
%14 = tail call i64 @bla(i32 6)
%15 = tail call i64 @bla(i32 7)
%16 = tail call i64 @bla(i32 8)
%17 = tail call i64 @bla(i32 2)
%18 = tail call i64 @bla(i32 4)
%19 = tail call i64 @bla(i32 6)
%20 = tail call i64 @bla(i32 8)
%21 = tail call i64 @bla(i32 10)
%22 = tail call i64 @bla(i32 12)
%23 = tail call i64 @bla(i32 14)
%24 = tail call i64 @bla(i32 16)
%25 = tail call i64 @bla(i32 3)
%26 = tail call i64 @bla(i32 6)
%27 = tail call i64 @bla(i32 9)
%28 = tail call i64 @bla(i32 12)
%29 = tail call i64 @bla(i32 15)
%30 = tail call i64 @bla(i32 18)
%31 = tail call i64 @bla(i32 21)
%32 = tail call i64 @bla(i32 24)
ret i32 undef
}