#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 */
struct EncodedData {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ encode_big_endian_integer(unsigned long long, int,
                                             struct EncodedData *);
void encode_long_little_endian_integer(unsigned long long value, int num_bits,
                                       struct EncodedData *result) {
  int i;
  for (i = 0; i < num_bits / 8; ++i) {
    encode_big_endian_integer(value & 0xFF, 8, result);
    value >>= 8;
  }
}


x86 assembly (clang, -O0):
<encode_long_little_endian_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    117b <encode_long_little_endian_integer+0x6b>
mov    -0x8(%rbp),%rdi
and    $0xff,%rdi
mov    -0x18(%rbp),%rdx
mov    $0x8,%esi
call   1030 <encode_big_endian_integer@plt>
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <encode_long_little_endian_integer+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_long_little_endian_integer>:
push   %rbp
push   %r14
push   %rbx
lea    0x7(%rsi),%ebp
test   %esi,%esi
cmovns %esi,%ebp
cmp    $0x8,%esi
jl     1149 <encode_long_little_endian_integer+0x39>
mov    %rdx,%r14
mov    %rdi,%rbx
sar    $0x3,%ebp
nopw   0x0(%rax,%rax,1)
movzbl %bl,%edi
mov    $0x8,%esi
mov    %r14,%rdx
call   1030 <encode_big_endian_integer@plt>
shr    $0x8,%rbx
add    $0xffffffff,%ebp
jne    1130 <encode_long_little_endian_integer+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.EncodedData = type { i32 }
define void @encode_long_little_endian_integer(i64 %0, i32 %1, %struct.EncodedData* %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca %struct.EncodedData*
%7 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
store %struct.EncodedData* %2, %struct.EncodedData** %6
store i32 0, i32* %7
br label %8
8: ; preds = %20, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = sdiv i32 %10, 8
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i64, i64* %4
%15 = and i64 %14, 255
%16 = load %struct.EncodedData*, %struct.EncodedData** %6
%17 = call i32 @encode_big_endian_integer(i64 %15, i32 8, %struct.EncodedData* %16)
%18 = load i64, i64* %4
%19 = lshr i64 %18, 8
store i64 %19, i64* %4
br label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %8
23: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.EncodedData = type { i32 }
define void @encode_long_little_endian_integer(i64 %0, i32 %1, %struct.EncodedData* %2) {
%4 = sdiv i32 %1, 8
%5 = icmp sgt i32 %1, 7
br i1 %5, label %6, label %14
6: ; preds = %3, %6
%7 = phi i32 [ %12, %6 ], [ 0, %3 ]
%8 = phi i64 [ %11, %6 ], [ %0, %3 ]
%9 = and i64 %8, 255
%10 = tail call i32 @encode_big_endian_integer(i64 %9, i32 8, %struct.EncodedData* %2)
%11 = lshr i64 %8, 8
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, %4
br i1 %13, label %14, label %6
14: ; preds = %6, %3
ret void
}