#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("%s length %d\n", ch, rn);
  for (i = 0; i < rn; i++) {
    if ((i % 8) == 0 && i != 0)
      printf("  #%d \n", i);
    printf("%02X ", (*pbuf & 0xff));
    pbuf++;
  }
  printf("\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)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <printc+0xa7>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1182 <printc+0x72>
cmpl   $0x0,-0x1c(%rbp)
je     1182 <printc+0x72>
mov    -0x1c(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movzbl (%rax),%esi
and    $0xff,%esi
lea    0xe80(%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    1147 <printc+0x37>
lea    0xe56(%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    %rdi,%rsi
lea    0xec8(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    1191 <printc+0x71>
mov    %ebx,%r13d
lea    0xebf(%rip),%r14
lea    0xec0(%rip),%r15
xor    %ebx,%ebx
jmp    1178 <printc+0x58>
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r13d
je     1191 <printc+0x71>
test   %ebx,%ebx
je     1160 <printc+0x40>
mov    %ebx,%eax
and    $0x7,%eax
jne    1160 <printc+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <printc+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"%s length %d\0A\00"
@.str.1 = [8 x i8] c" #%d \0A\00"
@.str.2 = [6 x i8] c"%02X \00"
define i32 @printc(i8* %0, i32 %1, i8* nocapture %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%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 @putchar(i32 10)
ret i32 0
}