#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 count_blocks(int);
int total_free() {
  int i, bytecount = 0;
  for (i = 0; i <= 10; i++) {
    bytecount += count_blocks(i) * (1 << (i));
  }
  return bytecount;
}


x86 assembly (clang, -O0):
<total_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jg     115b <total_free+0x4b>
mov    -0x4(%rbp),%edi
call   1030 <count_blocks@plt>
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
imul   %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1126 <total_free+0x16>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<total_free>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   1030 <count_blocks@plt>
lea    (%rbx,%rax,2),%ebx
mov    $0x2,%edi
call   1030 <count_blocks@plt>
lea    (%rbx,%rax,4),%ebx
mov    $0x3,%edi
call   1030 <count_blocks@plt>
lea    (%rbx,%rax,8),%ebp
mov    $0x4,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
add    %ebp,%ebx
mov    $0x5,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebp
shl    $0x5,%ebp
add    %ebx,%ebp
mov    $0x6,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebx
shl    $0x6,%ebx
add    %ebp,%ebx
mov    $0x7,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebp
shl    $0x7,%ebp
add    %ebx,%ebp
mov    $0x8,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebx
shl    $0x8,%ebx
add    %ebp,%ebx
mov    $0x9,%edi
call   1030 <count_blocks@plt>
mov    %eax,%ebp
shl    $0x9,%ebp
add    %ebx,%ebp
mov    $0xa,%edi
call   1030 <count_blocks@plt>
shl    $0xa,%eax
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @total_free() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %1
br label %3
3: ; preds = %14, %0
%4 = load i32, i32* %1
%5 = icmp sle i32 %4, 10
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = load i32, i32* %1
%8 = call i32 @count_blocks(i32 %7)
%9 = load i32, i32* %1
%10 = shl i32 1, %9
%11 = mul nsw i32 %8, %10
%12 = load i32, i32* %2
%13 = add nsw i32 %12, %11
store i32 %13, i32* %2
br label %14
14: ; preds = %6
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %3
17: ; preds = %3
%18 = load i32, i32* %2
ret i32 %18
}

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