#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 *, int);
void test_3() {
  int arr[2][2] = {1, 1};
  int i, ret = 0;
  for (i = 0; i < 2; i++) {
    do {
      int i;
      for (i = 0; i < 2; i++) {
        ret += arr[i][i];
      }
    } while (0);
  }
  printf("%d\n", ret);
}


x86 assembly (clang, -O0):
<test_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    119e <test_3+0x8e>
jmp    114b <test_3+0x3b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1186 <test_3+0x76>
movslq -0x1c(%rbp),%rcx
lea    -0x10(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <test_3+0x42>
jmp    118b <test_3+0x7b>
jmp    1190 <test_3+0x80>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <test_3+0x2c>
mov    -0x18(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_3>:
lea    0xee9(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.test_3.arr = [2 x [2 x i32]] [[2 x i32] [i32 1, i32 1], [2 x i32] zeroinitializer]
@.str = [4 x i8] c"%d\0A\00"
define void @test_3() {
%1 = alloca [2 x [2 x i32]]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [2 x [2 x i32]]* %1 to i8*
store i32 0, i32* %3
store i32 0, i32* %2
br label %6
6: ; preds = %29, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %32
9: ; preds = %6
br label %10
10: ; preds = %9
store i32 0, i32* %4
br label %11
11: ; preds = %24, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %1, i64 0, i64 %16
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, %21
store i32 %23, i32* %3
br label %24
24: ; preds = %14
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %11
27: ; preds = %11
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %6
32: ; preds = %6
%33 = load i32, i32* %3
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @test_3() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
ret void
}