#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, int);
void f2(uint32_t (*m)[3], int n) {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      printf("m[%d][%d]:%d\n", i, j, m[i][j]);
    }
  }
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118c <f2+0x7c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1179 <f2+0x69>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <f2+0x29>
jmp    117e <f2+0x6e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <f2+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1172 <f2+0x62>
mov    %rdi,%r14
mov    %esi,%r12d
add    $0x8,%r14
xor    %ebx,%ebx
lea    0xed1(%rip),%r15
nop
mov    -0x8(%r14),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <printf@plt>
mov    -0x4(%r14),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    (%r14),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
call   1030 <printf@plt>
add    $0x1,%rbx
add    $0xc,%r14
cmp    %rbx,%r12
jne    1130 <f2+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"m[%d][%d]:%d\0A\00"
define void @f2([3 x i32]* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %18, %6 ]
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 %7, i64 0
%9 = load i32, i32* %8
%10 = trunc i64 %7 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10, i32 0, i32 %9)
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 %7, i64 1
%13 = load i32, i32* %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10, i32 1, i32 %13)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 %7, i64 2
%16 = load i32, i32* %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10, i32 2, i32 %16)
%18 = add nuw nsw i64 %7, 1
%19 = icmp eq i64 %18, %5
br i1 %19, label %20, label %6
20: ; preds = %6, %2
ret void
}