#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 *, ...);
void print_vera_hex_string(char *cname, char *buf, int len) {
  int i;
  if (len == 0) {
    printf("<empty string>");
    return;
  }
  for (i = 0; i < len; i++) {
    if (i < len - 1)
      printf("%s[%d]='h%02x, ", cname, i, *((unsigned char *)buf + i));
    else
      printf("%s[%d]='h%02x", cname, i, *((unsigned char *)buf + i));
    if ((i & 0x3) == 3)
      printf("\n");
  }
  if ((i & 0xf) != 1)
    printf("\n");
}


x86 assembly (clang, -O0):
<print_vera_hex_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1140 <print_vera_hex_string+0x30>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f8 <print_vera_hex_string+0xe8>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11db <print_vera_hex_string+0xcb>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    118a <print_vera_hex_string+0x7a>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <print_vera_hex_string+0x9b>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    11c8 <print_vera_hex_string+0xb8>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <print_vera_hex_string+0xbd>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <print_vera_hex_string+0x37>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0x1,%eax
je     11f8 <print_vera_hex_string+0xe8>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_vera_hex_string>:
test   %edx,%edx
je     118f <print_vera_hex_string+0x6f>
jle    11b9 <print_vera_hex_string+0x99>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
lea    -0x1(%rdx),%r13d
mov    %rdx,(%rsp)
mov    %edx,%ebp
lea    0xed3(%rip),%r14
xor    %ebx,%ebx
jmp    1159 <print_vera_hex_string+0x39>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     119d <print_vera_hex_string+0x7d>
cmp    %r13,%rbx
movzbl (%r15,%rbx,1),%ecx
mov    %r14,%rdi
lea    0xea4(%rip),%rax
cmovb  %rax,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0x3,%al
jne    1150 <print_vera_hex_string+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <print_vera_hex_string+0x30>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
mov    (%rsp),%rax
and    $0xf,%eax
cmp    $0x1,%eax
lea    0x8(%rsp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jne    11b9 <print_vera_hex_string+0x99>
ret
mov    $0xa,%edi
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [15 x i8] c"<empty string>\00"
@.str.1 = [16 x i8] c"%s[%d]='h%02x, \00"
@.str.2 = [14 x i8] c"%s[%d]='h%02x\00"
define void @print_vera_hex_string(i8* %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %32
7: ; preds = %5
%8 = add nsw i32 %2, -1
%9 = zext i32 %8 to i64
%10 = zext i32 %2 to i64
br label %13
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %34
13: ; preds = %7, %26
%14 = phi i64 [ 0, %7 ], [ %27, %26 ]
%15 = icmp ult i64 %14, %9
%16 = getelementptr inbounds i8, i8* %1, i64 %14
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = trunc i64 %14 to i32
%20 = select i1 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %20, i8* %0, i32 %19, i32 %18)
%22 = and i32 %19, 3
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %26
24: ; preds = %13
%25 = tail call i32 @putchar(i32 10)
br label %26
26: ; preds = %13, %24
%27 = add nuw nsw i64 %14, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %13
29: ; preds = %26
%30 = and i32 %2, 15
%31 = icmp eq i32 %30, 1
br i1 %31, label %34, label %32
32: ; preds = %5, %29
%33 = tail call i32 @putchar(i32 10)
br label %34
34: ; preds = %29, %32, %11
ret void
}