#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void fprint_octet_string(FILE *f, unsigned char *p, unsigned char *e) {
  fprintf(f, "'");
  while (p < e)
    fprintf(f, "%02X", *p++);
  fprintf(f, "'X");
}


x86 assembly (clang, -O0):
<fprint_octet_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    116d <fprint_octet_string+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edx
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1136 <fprint_octet_string+0x26>
mov    -0x8(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_octet_string>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x27,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
cmp    %r13,%r15
jae    117b <fprint_octet_string+0x4b>
sub    %r15,%r13
lea    0xea2(%rip),%r12
xor    %ebx,%ebx
movzbl (%r15,%rbx,1),%edx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <fprint_octet_string+0x30>
lea    0xe83(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"'\00"
@.str.1 = [5 x i8] c"%02X\00"
@.str.2 = [3 x i8] c"'X\00"
define void @fprint_octet_string(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32*, i32** %4
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %13, %3
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i32*, i32** %4
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %5
%17 = load i8, i8* %15
%18 = zext i8 %17 to i32
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %9
20: ; preds = %9
%21 = load i32*, i32** %4
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%02X\00"
@.str.2 = [3 x i8] c"'X\00"
define void @fprint_octet_string(i32* nocapture %0, i8* %1, i8* readnone %2) {
%4 = tail call i32 @fputc(i32 39, i32* %0)
%5 = icmp ult i8* %1, %2
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = ptrtoint i8* %2 to i64
%8 = ptrtoint i8* %1 to i64
%9 = sub i64 %7, %8
%10 = getelementptr i8, i8* %1, i64 %9
br label %11
11: ; preds = %6, %11
%12 = phi i8* [ %13, %11 ], [ %1, %6 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %12
%15 = zext i8 %14 to i32
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = icmp eq i8* %13, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %3
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %0)
ret void
}