#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 size_t uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_digest(uint8_t length, uint8_t *digest) {
  uint8_t i;
  for (i = 0; i < length; i++) {
    printf("%02x ", digest[i]);
    if (15 == i % 16) {
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<print_digest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    118a <print_digest+0x7a>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rcx
and    $0xf,%rcx
mov    $0xf,%eax
cmp    %rcx,%rax
jne    1174 <print_digest+0x64>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1179 <print_digest+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <print_digest+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_digest>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     116b <print_digest+0x4b>
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xec6(%rip),%r15
xor    %ebx,%ebx
jmp    1149 <print_digest+0x29>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r12
je     116b <print_digest+0x4b>
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1140 <print_digest+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1140 <print_digest+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%02x \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_digest(i64 %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i64
store i64 %0, i64* %3
store i64* %1, i64** %4
store i64 0, i64* %5
br label %6
6: ; preds = %22, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %3
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %25
10: ; preds = %6
%11 = load i64*, i64** %4
%12 = load i64, i64* %5
%13 = getelementptr inbounds i64, i64* %11, i64 %12
%14 = load i64, i64* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %14)
%16 = load i64, i64* %5
%17 = urem i64 %16, 16
%18 = icmp eq i64 15, %17
br i1 %18, label %19, label %21
19: ; preds = %10
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %10
br label %22
22: ; preds = %21
%23 = load i64, i64* %5
%24 = add i64 %23, 1
store i64 %24, i64* %5
br label %6
25: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%02x \00"
define void @print_digest(i64 %0, i64* nocapture %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %13
%5 = phi i64 [ %14, %13 ], [ 0, %2 ]
%6 = getelementptr inbounds i64, i64* %1, i64 %5
%7 = load i64, i64* %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = and i64 %5, 15
%10 = icmp eq i64 %9, 15
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @putchar(i32 10)
br label %13
13: ; preds = %4, %11
%14 = add nuw i64 %5, 1
%15 = icmp eq i64 %14, %0
br i1 %15, label %16, label %4
16: ; preds = %13, %2
ret void
}