#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 bar(int *a, int m, int n) {
  int i, j;
  printf("C:");
  printf("m=%d, n=%d\n", m, n);
  for (i = 0; i < m; ++i) {
    printf("Row %d:\n", i + 1);
    for (j = 0; j < n; ++j)
      printf("a(i=%d,j=%d)=%d\n", i, j, a[n * i + j]);
  }
  if (m * n)
    a[0] = 7777;
}


x86 assembly (clang, -O0):
<bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c7 <bar+0xb7>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b4 <bar+0xa4>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <bar+0x62>
jmp    11b9 <bar+0xa9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <bar+0x3b>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    $0x0,%eax
je     11e1 <bar+0xd1>
mov    -0x8(%rbp),%rax
movl   $0x1e61,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,0x10(%rsp)
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,0x8(%rsp)
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
jle    11ce <bar+0xbe>
mov    0x8(%rsp),%eax
movslq %eax,%rcx
mov    0xc(%rsp),%edx
mov    %rdx,0x18(%rsp)
mov    %eax,%r13d
shl    $0x2,%rcx
mov    %rcx,0x20(%rsp)
lea    0xea2(%rip),%rbx
mov    0x10(%rsp),%r12
xor    %r14d,%r14d
jmp    118c <bar+0x7c>
add    0x20(%rsp),%r12
cmp    0x18(%rsp),%r14
je     11ce <bar+0xbe>
mov    %r14,%rbp
add    $0x1,%r14
lea    0xe75(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1180 <bar+0x70>
xor    %r15d,%r15d
xchg   %ax,%ax
mov    (%r12,%r15,4),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r13
jne    11b0 <bar+0xa0>
jmp    1180 <bar+0x70>
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
test   %eax,%eax
je     11e6 <bar+0xd6>
mov    0x10(%rsp),%rax
movl   $0x1e61,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"C:\00"
@.str.1 = [12 x i8] c"m=%d, n=%d\0A\00"
@.str.2 = [9 x i8] c"Row %d:\0A\00"
@.str.3 = [17 x i8] c"a(i=%d,j=%d)=%d\0A\00"
define void @bar(i32* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %31
7: ; preds = %3
%8 = icmp sgt i32 %2, 0
%9 = sext i32 %2 to i64
%10 = zext i32 %1 to i64
%11 = zext i32 %2 to i64
br label %14
12: ; preds = %22, %14
%13 = icmp eq i64 %16, %10
br i1 %13, label %31, label %14
14: ; preds = %7, %12
%15 = phi i64 [ 0, %7 ], [ %16, %12 ]
%16 = add nuw nsw i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br i1 %8, label %19, label %12
19: ; preds = %14
%20 = mul nsw i64 %15, %9
%21 = trunc i64 %15 to i32
br label %22
22: ; preds = %19, %22
%23 = phi i64 [ 0, %19 ], [ %29, %22 ]
%24 = add nsw i64 %23, %20
%25 = getelementptr inbounds i32, i32* %0, i64 %24
%26 = load i32, i32* %25
%27 = trunc i64 %23 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %27, i32 %26)
%29 = add nuw nsw i64 %23, 1
%30 = icmp eq i64 %29, %11
br i1 %30, label %12, label %22
31: ; preds = %12, %3
%32 = mul nsw i32 %2, %1
%33 = icmp eq i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31
store i32 7777, i32* %0
br label %35
35: ; preds = %34, %31
ret void
}