#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*/ cput_hex_byte(int /*<<< orphan*/);
int /*<<< orphan*/ tty_putc(char);
void cput_hex_block(char *block, int n) {
  int i = 0;
  while (n) {
    cput_hex_byte(*block++);
    if (--n == 0)
      break;
    i++;
    if ((i & 7) == 0)
      tty_putc(' ');
    else
      tty_putc(':');
  }
}


x86 assembly (clang, -O0):
<cput_hex_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a4 <cput_hex_block+0x84>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <cput_hex_byte@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    116e <cput_hex_block+0x4e>
jmp    11a4 <cput_hex_block+0x84>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1195 <cput_hex_block+0x75>
mov    $0x20,%edi
call   1040 <tty_putc@plt>
jmp    119f <cput_hex_block+0x7f>
mov    $0x3a,%edi
call   1040 <tty_putc@plt>
jmp    1136 <cput_hex_block+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cput_hex_block>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1173 <cput_hex_block+0x53>
mov    %esi,%ebp
mov    %rdi,%r14
movsbl (%rdi),%edi
call   1030 <cput_hex_byte@plt>
cmp    $0x1,%ebp
je     1173 <cput_hex_block+0x53>
mov    %ebp,%ebp
mov    $0x1,%ebx
mov    $0x20,%r15d
nopw   0x0(%rax,%rax,1)
test   $0x7,%bl
mov    $0x3a,%edi
cmove  %r15d,%edi
call   1040 <tty_putc@plt>
movsbl (%r14,%rbx,1),%edi
call   1030 <cput_hex_byte@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1150 <cput_hex_block+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cput_hex_block(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %29, %2
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %30
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
%12 = load i8, i8* %10
%13 = sext i8 %12 to i32
%14 = call i32 @cput_hex_byte(i32 %13)
%15 = load i32, i32* %4
%16 = add nsw i32 %15, -1
store i32 %16, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %9
br label %30
19: ; preds = %9
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = and i32 %22, 7
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @tty_putc(i8 signext 32)
br label %29
27: ; preds = %19
%28 = call i32 @tty_putc(i8 signext 58)
br label %29
29: ; preds = %27, %25
br label %6
30: ; preds = %18, %6
ret void
}

LLVM IR (-O2):
define void @cput_hex_block(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
%7 = tail call i32 @cput_hex_byte(i32 %6)
%8 = add nsw i32 %1, -1
%9 = icmp eq i32 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %4, %10
%11 = phi i32 [ %23, %10 ], [ %8, %4 ]
%12 = phi i8* [ %14, %10 ], [ %0, %4 ]
%13 = phi i32 [ %15, %10 ], [ 0, %4 ]
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = add nuw nsw i32 %13, 1
%16 = and i32 %15, 7
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8 32, i8 58
%19 = tail call i32 @tty_putc(i8 signext %18)
%20 = load i8, i8* %14
%21 = sext i8 %20 to i32
%22 = tail call i32 @cput_hex_byte(i32 %21)
%23 = add nsw i32 %11, -1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %10
25: ; preds = %10, %4, %2
ret void
}