#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 int, int,
                                             struct EncodedData *);
int encode_little_endian_integer(unsigned int value, unsigned int num_bits,
                                 struct EncodedData *result) {
  unsigned int i;
  for (i = 0; i < num_bits / 8; ++i) {
    encode_big_endian_integer(value & 0xFF, 8, result);
    value >>= 8;
  }
  return value == 0;
}


x86 assembly (clang, -O0):
<encode_little_endian_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x3,%ecx
cmp    %ecx,%eax
jae    1168 <encode_little_endian_integer+0x58>
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rdx
mov    $0x8,%esi
call   1030 <encode_big_endian_integer@plt>
mov    -0x4(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <encode_little_endian_integer+0x19>
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_little_endian_integer>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
cmp    $0x8,%esi
jb     1148 <encode_little_endian_integer+0x38>
mov    %rdx,%r14
mov    %esi,%ebp
shr    $0x3,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl %bl,%edi
mov    $0x8,%esi
mov    %r14,%rdx
call   1030 <encode_big_endian_integer@plt>
shr    $0x8,%ebx
add    $0xffffffff,%ebp
jne    1130 <encode_little_endian_integer+0x20>
xor    %eax,%eax
test   %ebx,%ebx
sete   %al
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.EncodedData = type { i32 }
define i32 @encode_little_endian_integer(i32 %0, i32 %1, %struct.EncodedData* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.EncodedData*
%7 = alloca i32
store i32 %0, i32* %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 = udiv i32 %10, 8
%12 = icmp ult i32 %9, %11
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i32, i32* %4
%15 = and i32 %14, 255
%16 = load %struct.EncodedData*, %struct.EncodedData** %6
%17 = call i32 @encode_big_endian_integer(i32 %15, i32 8, %struct.EncodedData* %16)
%18 = load i32, i32* %4
%19 = lshr i32 %18, 8
store i32 %19, i32* %4
br label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add i32 %21, 1
store i32 %22, i32* %7
br label %8
23: ; preds = %8
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
ret i32 %26
}

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