#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*/ sprintf(char *, char *, unsigned char const);
void print_raw(char *buffer, const void *object, size_t size) {
  size_t i;
  for (i = 0; i < size; i++) {
    sprintf(&buffer[i * 2], "%02x", ((const unsigned char *)object)[i] & 0xff);
  }
  return;
}


x86 assembly (clang, -O0):
<print_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    117a <print_raw+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
lea    0xe9f(%rip),%rsi
movzbl %al,%edx
call   1030 <sprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <print_raw+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_raw>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdx,%rdx
je     114d <print_raw+0x3d>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
xor    %ebx,%ebx
lea    0xed0(%rip),%r12
movzbl (%r14,%rbx,1),%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <sprintf@plt>
add    $0x1,%rbx
add    $0x2,%r13
cmp    %rbx,%r15
jne    1130 <print_raw+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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