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

/* Variables and functions */
int printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void printvec(const char *str, const uint8_t *vec, size_t len) {
  int i, n;
  n = printf("%s:", str);
  for (i = ((3 - n / 8) > (0)) ? (3 - n / 8) : (0); i > 0; i--)
    putchar('\t');
  if (len == 0)
    putchar('-');
  else
    for (i = 0; i < len; i++)
      printf("%02x", vec[i]);
  putchar('\n');
}


x86 assembly (clang, -O0):
<printvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x3,%eax
sub    %ecx,%eax
cmp    $0x0,%eax
jle    1182 <printvec+0x62>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x3,%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    118c <printvec+0x6c>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    118c <printvec+0x6c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11b4 <printvec+0x94>
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <printvec+0x72>
cmpq   $0x0,-0x18(%rbp)
jne    11ce <printvec+0xae>
mov    $0x2d,%edi
call   1030 <putchar@plt>
jmp    120f <printvec+0xef>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    120a <printvec+0xea>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d5 <printvec+0xb5>
jmp    120f <printvec+0xef>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printvec>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x17,%eax
jg     1172 <printvec+0x52>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x3,%ecx
mov    $0x4,%ebx
sub    %ecx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1160 <printvec+0x40>
test   %r12,%r12
je     1199 <printvec+0x79>
lea    0xe86(%rip),%r15
xor    %ebx,%ebx
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <printvec+0x60>
jmp    11a3 <printvec+0x83>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s:\00"
@.str.1 = [5 x i8] c"%02x\00"
define void @printvec(i8* %0, i32* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = sdiv i32 %11, 8
%13 = sub nsw i32 3, %12
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* %8
%17 = sdiv i32 %16, 8
%18 = sub nsw i32 3, %17
br label %20
19: ; preds = %3
br label %20
20: ; preds = %19, %15
%21 = phi i32 [ %18, %15 ], [ 0, %19 ]
store i32 %21, i32* %7
br label %22
22: ; preds = %27, %20
%23 = load i32, i32* %7
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = call i32 @putchar(i8 signext 9)
br label %27
27: ; preds = %25
%28 = load i32, i32* %7
%29 = add nsw i32 %28, -1
store i32 %29, i32* %7
br label %22
30: ; preds = %22
%31 = load i64, i64* %6
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @putchar(i8 signext 45)
br label %52
35: ; preds = %30
store i32 0, i32* %7
br label %36
36: ; preds = %48, %35
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = load i64, i64* %6
%40 = icmp ult i64 %38, %39
br i1 %40, label %41, label %51
41: ; preds = %36
%42 = load i32*, i32** %5
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %41
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %36
51: ; preds = %36
br label %52
52: ; preds = %51, %33
%53 = call i32 @putchar(i8 signext 10)
ret void
}

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