#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 *, char const);
void __print_message(const char *buf) {
  int i;
  for (i = 0; i < *buf; i++)
    printf("%02x", buf[i]);
  printf(" (length=%d)\n", *buf);
  return;
}


x86 assembly (clang, -O0):
<__print_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jge    115b <__print_message+0x4b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xebc(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <__print_message+0x13>
mov    -0x8(%rbp),%rax
lea    0xe9f(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__print_message>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
jle    115a <__print_message+0x4a>
mov    %rdi,%r15
movsbl %al,%esi
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    (%r15),%al
cmp    $0x2,%al
jl     115a <__print_message+0x4a>
mov    $0x1,%ebx
lea    0xec0(%rip),%r14
movsbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movsbq (%r15),%rax
cmp    %rax,%rbx
jl     1140 <__print_message+0x30>
movsbl %al,%esi
lea    0xea1(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [14 x i8] c" (length=%d)\0A\00"
define void @__print_message(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp sgt i8 %2, 0
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%6 = load i8, i8* %0
%7 = icmp sgt i8 %6, 1
br i1 %7, label %8, label %17
8: ; preds = %4, %8
%9 = phi i64 [ %13, %8 ], [ 1, %4 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%13 = add nuw nsw i64 %9, 1
%14 = load i8, i8* %0
%15 = sext i8 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %8, label %17
17: ; preds = %8, %4, %1
%18 = phi i8 [ %2, %1 ], [ %6, %4 ], [ %14, %8 ]
%19 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
ret void
}