void pblkl(void *a, int w, int h, int s) {
  unsigned *p = a;
  int x, y;
  printf("%08x\n", p);
  for (y = 0; y < h; y++) {
    for (x = 0; x < w; x++)
      printf("%4d ", *p++);
    printf("\n");
    if (s)
      p += (s - w);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<pblkl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d5 <pblkl+0xc5>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1192 <pblkl+0x82>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1159 <pblkl+0x49>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11c2 <pblkl+0xb2>
mov    -0x14(%rbp),%ecx
sub    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    11c7 <pblkl+0xb7>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1146 <pblkl+0x36>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pblkl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xec3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    11b8 <pblkl+0x98>
mov    %r15d,%eax
sub    %r14d,%eax
test   %r15d,%r15d
cmove  %r15d,%eax
movslq %eax,%r12
lea    0xea0(%rip),%rbp
xor    %r13d,%r13d
jmp    1189 <pblkl+0x69>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%rbx,%r12,4),%rbx
add    $0x1,%r13d
cmp    0x4(%rsp),%r13d
je     11b8 <pblkl+0x98>
test   %r14d,%r14d
jle    1170 <pblkl+0x50>
mov    %r14d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%esi
add    $0x4,%rbx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%r15d
jne    11a0 <pblkl+0x80>
jmp    1170 <pblkl+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"%08x\0A\00"
@.str.1 = [5 x i8] c"%4d \00"
define void @pblkl(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = bitcast i8* %0 to i32*
%9 = icmp sgt i32 %1, 0
%10 = icmp eq i32 %3, 0
%11 = sub nsw i32 %3, %1
%12 = select i1 %10, i32 0, i32 %11
%13 = sext i32 %12 to i64
br label %14
14: ; preds = %7, %25
%15 = phi i32 [ 0, %7 ], [ %29, %25 ]
%16 = phi i32* [ %8, %7 ], [ %28, %25 ]
br i1 %9, label %17, label %25
17: ; preds = %14, %17
%18 = phi i32 [ %23, %17 ], [ 0, %14 ]
%19 = phi i32* [ %20, %17 ], [ %16, %14 ]
%20 = getelementptr inbounds i32, i32* %19, i64 1
%21 = load i32, i32* %19
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i32 %18, 1
%24 = icmp eq i32 %23, %1
br i1 %24, label %25, label %17
25: ; preds = %17, %14
%26 = phi i32* [ %16, %14 ], [ %20, %17 ]
%27 = tail call i32 @putchar(i32 10)
%28 = getelementptr i32, i32* %26, i64 %13
%29 = add nuw nsw i32 %15, 1
%30 = icmp eq i32 %29, %2
br i1 %30, label %31, label %14
31: ; preds = %25, %4
%32 = tail call i32 @putchar(i32 10)
ret void
}