#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 printc(char *ch, int rn, void *buf) {
  int i;
  unsigned char *pbuf;
  pbuf = (unsigned char *)buf;
  printf("\n");
  for (i = 0; i < rn; i++) {
    if ((i % 8) == 0 && i != 0)
      printf("  #%d \n", i);
    printf("%02X ", (*pbuf & 0xff));
    pbuf++;
  }
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<printc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b0 <printc+0xa0>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117b <printc+0x6b>
cmpl   $0x0,-0x1c(%rbp)
je     117b <printc+0x6b>
mov    -0x1c(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movzbl (%rax),%esi
and    $0xff,%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <printc+0x30>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %esi,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
jle    11a1 <printc+0x71>
mov    %ebx,%r13d
lea    0xeaa(%rip),%r14
lea    0xeab(%rip),%r15
xor    %ebx,%ebx
jmp    1188 <printc+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r13d
je     11a1 <printc+0x71>
test   %ebx,%ebx
je     1170 <printc+0x40>
mov    %ebx,%eax
and    $0x7,%eax
jne    1170 <printc+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1170 <printc+0x40>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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