#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 /*<<< orphan*/ puts(char *);
void print_int(int *p, int n) {
  const int w = 16;
  int i = 0;
  while (i < n) {
    int j;
    printf("%04X(%5d):\t", i, i);
    for (j = 0; j < w && i < n; j++) {
      printf("%6d ", *p++);
      i++;
    }
    printf("\n");
  }
  puts("");
}


x86 assembly (clang, -O0):
<print_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x10,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d8 <print_int+0xb8>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jge    117f <print_int+0x5f>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118f <print_int+0x6f>
jmp    11c5 <print_int+0xa5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <print_int+0x44>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    113d <print_int+0x1d>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_int>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11a6 <print_int+0x86>
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xec4(%rip),%r14
lea    0xec9(%rip),%r15
xor    %r13d,%r13d
jmp    1162 <print_int+0x42>
nopl   0x0(%rax,%rax,1)
add    %eax,%r13d
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r12d,%r13d
jge    11a6 <print_int+0x86>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%r13d
jge    1153 <print_int+0x33>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rbx),%esi
add    $0x4,%rbx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbp),%eax
cmp    $0xe,%ebp
ja     1150 <print_int+0x30>
lea    0x1(%r13,%rbp,1),%ecx
mov    %eax,%ebp
cmp    %r12d,%ecx
jl     1180 <print_int+0x60>
jmp    1150 <print_int+0x30>
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 = [12 x i8] c"%04X(%5d):\09\00"
@.str.1 = [5 x i8] c"%6d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define void @print_int(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 16, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %35, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
store i32 0, i32* %7
br label %16
16: ; preds = %32, %12
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 16
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %25, label %35
25: ; preds = %23
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %3
%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)
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %32
32: ; preds = %25
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %16
35: ; preds = %23
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %8
37: ; preds = %8
%38 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%04X(%5d):\09\00"
@.str.1 = [5 x i8] c"%6d \00"
define void @print_int(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %26
4: ; preds = %2, %21
%5 = phi i32 [ %23, %21 ], [ 0, %2 ]
%6 = phi i32* [ %22, %21 ], [ %0, %2 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %5)
%8 = icmp slt i32 %5, %1
br i1 %8, label %9, label %21
9: ; preds = %4, %9
%10 = phi i32 [ %17, %9 ], [ 0, %4 ]
%11 = phi i32 [ %16, %9 ], [ %5, %4 ]
%12 = phi i32* [ %13, %9 ], [ %6, %4 ]
%13 = getelementptr inbounds i32, i32* %12, i64 1
%14 = load i32, i32* %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = add nsw i32 %11, 1
%17 = add nuw nsw i32 %10, 1
%18 = icmp ult i32 %10, 15
%19 = icmp slt i32 %16, %1
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %9, label %21
21: ; preds = %9, %4
%22 = phi i32* [ %6, %4 ], [ %13, %9 ]
%23 = phi i32 [ %5, %4 ], [ %16, %9 ]
%24 = tail call i32 @putchar(i32 10)
%25 = icmp slt i32 %23, %1
br i1 %25, label %4, label %26
26: ; preds = %21, %2
%27 = tail call i32 @putchar(i32 10)
ret void
}