#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 *, unsigned char, char *);
void show_utf8_bytes(unsigned char b[], unsigned char len) {
  unsigned char d;
  for (d = 0; d < len; d++)
    printf("%02x%s", b[d], d < len - 1 ? " " : "");
}


x86 assembly (clang, -O0):
<show_utf8_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movb   $0x0,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
movzbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jge    117c <show_utf8_bytes+0x6c>
mov    -0x8(%rbp),%rax
movzbl -0xa(%rbp),%ecx
mov    (%rax,%rcx,1),%al
movzbl -0xa(%rbp),%esi
movzbl -0x9(%rbp),%edi
sub    $0x1,%edi
lea    0xeb5(%rip),%rdx
lea    0xead(%rip),%rcx
cmp    %edi,%esi
cmovl  %rcx,%rdx
lea    0xe99(%rip),%rdi
movzbl %al,%esi
call   1030 <printf@plt>
mov    -0xa(%rbp),%al
add    $0x1,%al
mov    %al,-0xa(%rbp)
jmp    1126 <show_utf8_bytes+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_utf8_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1167 <show_utf8_bytes+0x57>
mov    %rdi,%r15
movzbl %sil,%r12d
mov    %r12d,%r13d
add    $0xffffffff,%r13d
xor    %ebx,%ebx
lea    0xed2(%rip),%rbp
lea    0xec3(%rip),%r14
nopl   (%rax)
movzbl (%r15,%rbx,1),%esi
cmp    %r13,%rbx
mov    %rbp,%rdx
lea    0xeb5(%rip),%rax
cmovb  %rax,%rdx
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <show_utf8_bytes+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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