#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 foo(int);
int main() {
  int res;
  int c[100][200];
  int a;
  int x;
  for (a = 1; a < 50; a++) {
    c[a + 1][a] = 2;
    res += c[a][a];
  }
  return res + foo(c[12][13]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x13894(%rbp)
cmpl   $0x32,-0x13894(%rbp)
jge    11a0 <main+0x90>
mov    -0x13894(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    -0x13890(%rbp),%rax
imul   $0x320,%rcx,%rcx
add    %rcx,%rax
movslq -0x13894(%rbp),%rcx
movl   $0x2,(%rax,%rcx,4)
movslq -0x13894(%rbp),%rcx
lea    -0x13890(%rbp),%rax
imul   $0x320,%rcx,%rcx
add    %rcx,%rax
movslq -0x13894(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x13894(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13894(%rbp)
jmp    112c <main+0x1c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1389c(%rbp)
mov    -0x112dc(%rbp),%edi
call   1030 <foo@plt>
mov    %eax,%ecx
mov    -0x1389c(%rbp),%eax
add    %ecx,%eax
add    $0x138a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x13880,%rsp
lea    0x324(%rsp),%rax
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movl   $0x2,0x320(%rax)
add    (%rax),%ebx
cmp    $0x32,%rcx
je     115e <main+0x4e>
movl   $0x2,0x644(%rax)
add    0x324(%rax),%ebx
add    $0x648,%rax
add    $0x2,%rcx
jmp    1130 <main+0x20>
call   1030 <foo@plt>
add    %ebx,%eax
add    $0x13880,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x [200 x i32]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
br label %6
6: ; preds = %26, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 50
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %3, i64 0, i64 %12
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [200 x i32], [200 x i32]* %13, i64 0, i64 %15
store i32 2, i32* %16
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %3, i64 0, i64 %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [200 x i32], [200 x i32]* %19, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = load i32, i32* %2
%25 = add nsw i32 %24, %23
store i32 %25, i32* %2
br label %26
26: ; preds = %9
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %6
29: ; preds = %6
%30 = load i32, i32* %2
%31 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %3, i64 0, i64 12
%32 = getelementptr inbounds [200 x i32], [200 x i32]* %31, i64 0, i64 13
%33 = load i32, i32* %32
%34 = call i32 @foo(i32 %33)
%35 = add nsw i32 %30, %34
ret i32 %35
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [100 x [200 x i32]]
%2 = bitcast [100 x [200 x i32]]* %1 to i8*
br label %3
3: ; preds = %12, %0
%4 = phi i64 [ 1, %0 ], [ %13, %12 ]
%5 = phi i32 [ undef, %0 ], [ %17, %12 ]
%6 = add nuw nsw i64 %4, 1
%7 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %1, i64 0, i64 %6, i64 %4
store i32 2, i32* %7
%8 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %1, i64 0, i64 %4, i64 %4
%9 = load i32, i32* %8
%10 = add nsw i32 %9, %5
%11 = icmp eq i64 %6, 50
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = add nuw nsw i64 %4, 2
%14 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %1, i64 0, i64 %13, i64 %6
store i32 2, i32* %14
%15 = getelementptr inbounds [100 x [200 x i32]], [100 x [200 x i32]]* %1, i64 0, i64 %6, i64 %6
%16 = load i32, i32* %15
%17 = add nsw i32 %16, %10
br label %3
18: ; preds = %3
%19 = tail call i32 @foo(i32 undef)
%20 = add nsw i32 %19, %10
ret i32 %20
}