#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, int *);
void imprime_direccion(int *puntero, int rows, int cols) {
  int total = rows * cols;
  for (int i = 0; i < total; i++) {
    i += 1;
    printf("&p[%d]: %p \n", i, puntero + i);
  }
}


x86 assembly (clang, -O0):
<imprime_direccion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1174 <imprime_direccion+0x64>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <imprime_direccion+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprime_direccion>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
imul   %edx,%r15d
test   %r15d,%r15d
jle    115e <imprime_direccion+0x4e>
mov    %rdi,%rbx
add    $0x4,%rbx
mov    $0x1,%ebp
lea    0xeca(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
add    $0x8,%rbx
lea    0x2(%rbp),%eax
add    $0x1,%ebp
cmp    %ebp,%r15d
mov    %eax,%ebp
jg     1140 <imprime_direccion+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"&p[%d]: %p \0A\00"
define void @imprime_direccion(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 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = mul nsw i32 %9, %10
store i32 %11, i32* %7
store i32 0, i32* %8
br label %12
12: ; preds = %25, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* %8
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = load i32*, i32** %4
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19, i32* %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %12
28: ; preds = %12
ret void
}

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