#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 *, long long);
scalar_t__ unpack_integer(unsigned char *, unsigned char *, long long *);
void fprint_integer(FILE *f, unsigned char *p, unsigned char *e) {
  long long value;
  if (p + sizeof(value) < e || unpack_integer(p, e, &value)) {
    fprint_octet_string(f, p, e);
    return;
  }
  fprintf(f, "%lld", value);
}


x86 assembly (clang, -O0):
<fprint_integer>:
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_integer+0x41>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <unpack_integer@plt>
cmp    $0x0,%rax
je     1187 <fprint_integer+0x57>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <fprint_octet_string@plt>
jmp    119b <fprint_integer+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_integer>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rsi),%rax
cmp    %rdx,%rax
jb     1160 <fprint_integer+0x30>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <unpack_integer@plt>
test   %rax,%rax
je     1170 <fprint_integer+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <fprint_octet_string@plt>
jmp    1184 <fprint_integer+0x54>
mov    0x8(%rsp),%rdx
lea    0xe84(%rip),%rsi
mov    %r14,%rdi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
define void @fprint_integer(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 %17, label %12
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i64 @unpack_integer(i8* %13, i8* %14, i64* %7)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12, %3
%18 = load i32*, i32** %4
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 @fprint_octet_string(i32* %18, i8* %19, i8* %20)
br label %26
22: ; preds = %12
%23 = load i32*, i32** %4
%24 = load i64, i64* %7
%25 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %22, %17
ret void
}

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