#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 /*<<< orphan*/ bar(int *);
int /*<<< orphan*/ foo(char *, int);
void foo3() {
  const int kIterations = 10;
  int results[kIterations];
  int i;
  bar(results);
  for (i = 0; i < kIterations; i++)
    foo("%d ", results[i]);
}


x86 assembly (clang, -O0):
<foo3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0xa,-0x4(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <bar@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1172 <foo3+0x52>
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xea1(%rip),%rdi
call   1040 <foo@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1146 <foo3+0x26>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo3>:
push   %rbx
sub    $0x30,%rsp
mov    %rsp,%rdi
call   1030 <bar@plt>
mov    (%rsp),%esi
lea    0xec9(%rip),%rbx
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
call   1040 <foo@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define void @foo3() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 10, i32* %1
%4 = call i8* @llvm.stacksave()
store i8* %4, i8** %2
%5 = alloca i32, i64 10
%6 = call i32 @bar(i32* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %5, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %7
19: ; preds = %7
%20 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @foo3() {
%1 = alloca [10 x i32]
%2 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%3 = call i32 @bar(i32* %2)
%4 = load i32, i32* %2
%5 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%7 = load i32, i32* %6
%8 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%10 = load i32, i32* %9
%11 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%13 = load i32, i32* %12
%14 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%16 = load i32, i32* %15
%17 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%19 = load i32, i32* %18
%20 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%22 = load i32, i32* %21
%23 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%25 = load i32, i32* %24
%26 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%28 = load i32, i32* %27
%29 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%31 = load i32, i32* %30
%32 = call i32 @foo(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
ret void
}