#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 toto() {
  int i, j, k;
  int a[100][100];
  int b[100];
  int N = foo();
  for (i = 0; i < 2 * N + 100; i++)
    for (j = 0; j < 200; j++)
      a[j][i] = a[j + 1][10] + 2;
  return a[3][5] + b[1];
}


x86 assembly (clang, -O0):
<toto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9df0,%rsp
mov    $0x0,%al
call   1030 <foo@plt>
mov    %eax,-0x9de4(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x9de4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x64,%ecx
cmp    %ecx,%eax
jge    11b7 <toto+0xa7>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc8,-0x8(%rbp)
jge    11a4 <toto+0x94>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
mov    0x28(%rax),%edx
add    $0x2,%edx
movslq -0x8(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <toto+0x3d>
jmp    11a9 <toto+0x99>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <toto+0x1f>
mov    -0x978c(%rbp),%eax
add    -0x9ddc(%rbp),%eax
add    $0x9df0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toto>:
push   %rbx
sub    $0x9c40,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <foo@plt>
cmp    $0xffffffcf,%eax
jl     118b <toto+0x7b>
add    %eax,%eax
add    $0x63,%eax
test   %eax,%eax
cmovle %ebx,%eax
add    $0x1,%eax
mov    %rsp,%rcx
cs nopw 0x0(%rax,%rax,1)
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x1b8(%rsp,%rdx,1),%esi
add    $0x2,%esi
mov    %esi,(%rcx,%rdx,1)
mov    0x348(%rsp,%rdx,1),%esi
add    $0x2,%esi
mov    %esi,0x190(%rcx,%rdx,1)
add    $0x320,%rdx
cmp    $0x13880,%rdx
jne    1150 <toto+0x40>
add    $0x1,%rbx
add    $0x4,%rcx
cmp    %rax,%rbx
jne    1140 <toto+0x30>
add    $0x9c40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @toto() {
%1 = alloca [100 x [100 x i32]]
%2 = bitcast [100 x [100 x i32]]* %1 to i8*
%3 = tail call i32 (...) @foo()
%4 = icmp sgt i32 %3, -50
br i1 %4, label %5, label %29
5: ; preds = %0
%6 = shl i32 %3, 1
%7 = add i32 %6, 99
%8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
%9 = add nuw i32 %8, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %5, %26
%12 = phi i64 [ 0, %5 ], [ %27, %26 ]
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %20, %13 ]
%15 = or i64 %14, 1
%16 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %15, i64 10
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 2
%19 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %14, i64 %12
store i32 %18, i32* %19
%20 = add nuw nsw i64 %14, 2
%21 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %20, i64 10
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 2
%24 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %15, i64 %12
store i32 %23, i32* %24
%25 = icmp eq i64 %20, 200
br i1 %25, label %26, label %13
26: ; preds = %13
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %11
29: ; preds = %26, %0
ret i32 undef
}