#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 lookup(int);
int test(int i) {
  return lookup(i) + lookup(2 * i) + lookup(3 * i) + lookup(4 * i) +
         lookup(5 * i) + lookup(6 * i) + lookup(7 * i) + lookup(8 * i) +
         lookup(9 * i);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <lookup@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
shl    $0x1,%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
imul   $0x3,-0x4(%rbp),%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
shl    $0x2,%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
imul   $0x5,-0x4(%rbp),%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
imul   $0x6,-0x4(%rbp),%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
imul   $0x7,-0x4(%rbp),%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
shl    $0x3,%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
imul   $0x9,-0x4(%rbp),%edi
call   1030 <lookup@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r12d
call   1030 <lookup@plt>
mov    %eax,%r15d
lea    (%r12,%r12,1),%r14d
mov    %r14d,%edi
call   1030 <lookup@plt>
mov    %eax,%ebp
add    %r15d,%ebp
lea    (%r12,%r12,2),%edi
call   1030 <lookup@plt>
mov    %eax,%ebx
add    %ebp,%ebx
lea    0x0(,%r12,4),%edi
call   1030 <lookup@plt>
mov    %eax,%ebp
add    %ebx,%ebp
lea    (%r12,%r12,4),%edi
call   1030 <lookup@plt>
mov    %eax,%ebx
add    %ebp,%ebx
lea    (%r14,%r14,2),%edi
call   1030 <lookup@plt>
mov    %eax,%ebp
add    %ebx,%ebp
lea    0x0(,%r12,8),%r14d
mov    %r14d,%edi
sub    %r12d,%edi
call   1030 <lookup@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r14d,%edi
call   1030 <lookup@plt>
mov    %eax,%ebp
add    %ebx,%ebp
lea    (%r12,%r12,8),%edi
call   1030 <lookup@plt>
add    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @lookup(i32 %3)
%5 = load i32, i32* %2
%6 = mul nsw i32 2, %5
%7 = call i32 @lookup(i32 %6)
%8 = add nsw i32 %4, %7
%9 = load i32, i32* %2
%10 = mul nsw i32 3, %9
%11 = call i32 @lookup(i32 %10)
%12 = add nsw i32 %8, %11
%13 = load i32, i32* %2
%14 = mul nsw i32 4, %13
%15 = call i32 @lookup(i32 %14)
%16 = add nsw i32 %12, %15
%17 = load i32, i32* %2
%18 = mul nsw i32 5, %17
%19 = call i32 @lookup(i32 %18)
%20 = add nsw i32 %16, %19
%21 = load i32, i32* %2
%22 = mul nsw i32 6, %21
%23 = call i32 @lookup(i32 %22)
%24 = add nsw i32 %20, %23
%25 = load i32, i32* %2
%26 = mul nsw i32 7, %25
%27 = call i32 @lookup(i32 %26)
%28 = add nsw i32 %24, %27
%29 = load i32, i32* %2
%30 = mul nsw i32 8, %29
%31 = call i32 @lookup(i32 %30)
%32 = add nsw i32 %28, %31
%33 = load i32, i32* %2
%34 = mul nsw i32 9, %33
%35 = call i32 @lookup(i32 %34)
%36 = add nsw i32 %32, %35
ret i32 %36
}

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