#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*/ printf(char *, ...);
void foo(long iter) {
  int i, j, k = 0;
  int a[256], b[256], c[256];
  printf("Running foo\n");
  printf("iterations = %lu \n", (iter * iter));
  printf(" math = a[i] = b[i] + c[i]\n");
  for (j = 0; j < iter; j++)
    for (j = 0; j < iter; j++)
      for (i = 0; i < 256; i++)
        a[i] = b[i] + c[i];
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
imul   -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11ec <foo+0xdc>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11d9 <foo+0xc9>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    11c6 <foo+0xb6>
movslq -0xc(%rbp),%rax
mov    -0x820(%rbp,%rax,4),%ecx
movslq -0xc(%rbp),%rax
add    -0xc20(%rbp,%rax,4),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x420(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118a <foo+0x7a>
jmp    11cb <foo+0xbb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1175 <foo+0x65>
jmp    11de <foo+0xce>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1160 <foo+0x50>
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
mov    %rdi,%rbx
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
imul   %rbx,%rbx
lea    0xec5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Running foo\0A\00"
@.str.1 = [19 x i8] c"iterations = %lu \0A\00"
@.str.2 = [28 x i8] c" math = a[i] = b[i] + c[i]\0A\00"
define void @foo(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i32]
%7 = alloca [256 x i32]
%8 = alloca [256 x i32]
store i64 %0, i64* %2
store i32 0, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %2
%11 = load i64, i64* %2
%12 = mul nsw i64 %10, %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %15
15: ; preds = %51, %1
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = load i64, i64* %2
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %54
20: ; preds = %15
store i32 0, i32* %4
br label %21
21: ; preds = %47, %20
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = load i64, i64* %2
%25 = icmp slt i64 %23, %24
br i1 %25, label %26, label %50
26: ; preds = %21
store i32 0, i32* %3
br label %27
27: ; preds = %43, %26
%28 = load i32, i32* %3
%29 = icmp slt i32 %28, 256
br i1 %29, label %30, label %46
30: ; preds = %27
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = add nsw i32 %34, %38
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %41
store i32 %39, i32* %42
br label %43
43: ; preds = %30
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %27
46: ; preds = %27
br label %47
47: ; preds = %46
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %21
50: ; preds = %21
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %15
54: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"iterations = %lu \0A\00"
@str = [12 x i8] c"Running foo\00"
@str.3 = [27 x i8] c" math = a[i] = b[i] + c[i]\00"
define void @foo(i64 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%3 = mul nsw i64 %0, %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.3, i64 0, i64 0))
ret void
}