#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 */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_block_hex(uint8_t *buf) {
  int j, k;
  uint8_t *bufptr8;
  uint32_t tempintchar;
  bufptr8 = buf;
  for (j = 0; j < 8; j++) {
    printf("       ");
    for (k = 0; k < 19; k++) {
      if ((k % 5) == 4) {
        printf(" ");
      } else {
        tempintchar = *bufptr8;
        printf("%.2X", tempintchar);
        bufptr8++;
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_block_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11d0 <print_block_hex+0xc0>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x13,-0x10(%rbp)
jge    11b4 <print_block_hex+0xa4>
mov    -0x10(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x4,%edx
jne    117b <print_block_hex+0x6b>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a1 <print_block_hex+0x91>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    11a6 <print_block_hex+0x96>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114a <print_block_hex+0x3a>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112b <print_block_hex+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_block_hex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
lea    0xecb(%rip),%r14
lea    0xecc(%rip),%r15
xor    %r12d,%r12d
jmp    1164 <print_block_hex+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    $0x8,%r12d
je     11c2 <print_block_hex+0xa2>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    119e <print_block_hex+0x7e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x4,%r13
add    $0xffffffff,%ebx
add    $0x1,%bpl
cmp    $0xffffffed,%ebx
je     1150 <print_block_hex+0x30>
movzbl %bpl,%eax
imul   $0xcd,%eax,%eax
shr    $0xa,%eax
lea    (%rax,%rax,4),%eax
mov    $0xfc,%cl
sub    %al,%cl
cmp    %bl,%cl
jne    1180 <print_block_hex+0x60>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1192 <print_block_hex+0x72>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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