#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_char(unsigned char *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("%02X ", *p++);
      i++;
    }
    printf("\n");
  }
  puts("");
}


x86 assembly (clang, -O0):
<print_char>:
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    11d9 <print_char+0xb9>
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_char+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_char+0x6f>
jmp    11c6 <print_char+0xa6>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%esi
lea    0xe64(%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_char+0x44>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    113d <print_char+0x1d>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11b6 <print_char+0x96>
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xec1(%rip),%rbp
lea    0xec6(%rip),%r12
xor    %r13d,%r13d
jmp    116c <print_char+0x4c>
nopl   0x0(%rax,%rax,1)
add    %ebp,%r13d
add    %rbp,%r14
lea    0xea3(%rip),%rbp
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %ebx,%r13d
jge    11b6 <print_char+0x96>
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%r13d
jge    115d <print_char+0x3d>
mov    %r13d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movzbl (%r14,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x1,%rbp
cmp    $0xe,%eax
ja     1150 <print_char+0x30>
add    %r15d,%eax
add    $0x1,%eax
cmp    %ebx,%eax
jl     1190 <print_char+0x70>
jmp    1150 <print_char+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 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define void @print_char(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 16, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %36, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %38
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 = %33, %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 %36
25: ; preds = %23
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
%28 = load i8, i8* %26
%29 = zext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %33
33: ; preds = %25
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %16
36: ; preds = %23
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %8
38: ; preds = %8
%39 = 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 = [6 x i8] c"%02X \00"
define void @print_char(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %27
4: ; preds = %2, %22
%5 = phi i32 [ %24, %22 ], [ 0, %2 ]
%6 = phi i8* [ %23, %22 ], [ %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 %22
9: ; preds = %4, %9
%10 = phi i32 [ %18, %9 ], [ 0, %4 ]
%11 = phi i32 [ %17, %9 ], [ %5, %4 ]
%12 = phi i8* [ %13, %9 ], [ %6, %4 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %12
%15 = zext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nsw i32 %11, 1
%18 = add nuw nsw i32 %10, 1
%19 = icmp ult i32 %10, 15
%20 = icmp slt i32 %17, %1
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %9, label %22
22: ; preds = %9, %4
%23 = phi i8* [ %6, %4 ], [ %13, %9 ]
%24 = phi i32 [ %5, %4 ], [ %17, %9 ]
%25 = tail call i32 @putchar(i32 10)
%26 = icmp slt i32 %24, %1
br i1 %26, label %4, label %27
27: ; preds = %22, %2
%28 = tail call i32 @putchar(i32 10)
ret void
}