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

/* Variables and functions */
int /*<<< orphan*/ fprint_octet_string(int /*<<< orphan*/ *, unsigned char *,
                                       unsigned char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long long);
scalar_t__ unpack_unsigned(unsigned char **, unsigned char *,
                           unsigned long long *);
void fprint_unsigned(FILE *f, unsigned char *p, unsigned char *e) {
  unsigned long long value;
  if (p + sizeof(value) < e || unpack_unsigned(&p, e, &value)) {
    fprint_octet_string(f, p, e);
    return;
  }
  fprintf(f, "%llu", value);
}


x86 assembly (clang, -O0):
<fprint_unsigned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
cmp    -0x18(%rbp),%rax
jb     1171 <fprint_unsigned+0x41>
mov    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
call   1040 <unpack_unsigned@plt>
cmp    $0x0,%rax
je     1187 <fprint_unsigned+0x57>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <fprint_octet_string@plt>
jmp    119b <fprint_unsigned+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe6a(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_unsigned>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsi,0x8(%rsp)
lea    0x8(%rsi),%rax
cmp    %rdx,%rax
jb     1167 <fprint_unsigned+0x37>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <unpack_unsigned@plt>
test   %rax,%rax
je     1174 <fprint_unsigned+0x44>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <fprint_octet_string@plt>
jmp    1188 <fprint_unsigned+0x58>
mov    0x10(%rsp),%rdx
lea    0xe80(%rip),%rsi
mov    %r14,%rdi
call   1030 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

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