#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_big_endian_integer(unsigned long long value, int num_bits,
                                    struct EncodedData *result) {
  if (num_bits > 32) {
    num_bits -= 32;
    unsigned int upper = value >> num_bits;
    encode_big_endian_integer(upper, 32, result);
    value -= ((unsigned long long)upper) << num_bits;
  }
  encode_big_endian_integer(value, num_bits, result);
}


x86 assembly (clang, -O0):
<encode_long_big_endian_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x20,-0xc(%rbp)
jle    116d <encode_long_big_endian_integer+0x5d>
mov    -0xc(%rbp),%eax
sub    $0x20,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shr    %cl,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%edi
mov    -0x18(%rbp),%rdx
mov    $0x20,%esi
call   1030 <encode_big_endian_integer@plt>
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%rax
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <encode_big_endian_integer@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_long_big_endian_integer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
cmp    $0x21,%esi
jl     1149 <encode_long_big_endian_integer+0x39>
add    $0xffffffe0,%ebp
mov    %r15,%rax
mov    %ebp,%ecx
shr    %cl,%rax
mov    %eax,%ebx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %r14,%rdx
call   1030 <encode_big_endian_integer@plt>
mov    %ebp,%ecx
shl    %cl,%rbx
sub    %rbx,%r15
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <encode_big_endian_integer@plt>

LLVM IR (-O0):
%struct.EncodedData = type { i32 }
define void @encode_long_big_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
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 32
br i1 %9, label %10, label %29
10: ; preds = %3
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 32
store i32 %12, i32* %5
%13 = load i64, i64* %4
%14 = load i32, i32* %5
%15 = zext i32 %14 to i64
%16 = lshr i64 %13, %15
%17 = trunc i64 %16 to i32
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = zext i32 %18 to i64
%20 = load %struct.EncodedData*, %struct.EncodedData** %6
%21 = call i32 @encode_big_endian_integer(i64 %19, i32 32, %struct.EncodedData* %20)
%22 = load i32, i32* %7
%23 = zext i32 %22 to i64
%24 = load i32, i32* %5
%25 = zext i32 %24 to i64
%26 = shl i64 %23, %25
%27 = load i64, i64* %4
%28 = sub i64 %27, %26
store i64 %28, i64* %4
br label %29
29: ; preds = %10, %3
%30 = load i64, i64* %4
%31 = load i32, i32* %5
%32 = load %struct.EncodedData*, %struct.EncodedData** %6
%33 = call i32 @encode_big_endian_integer(i64 %30, i32 %31, %struct.EncodedData* %32)
ret void
}

LLVM IR (-O2):
%struct.EncodedData = type { i32 }
define void @encode_long_big_endian_integer(i64 %0, i32 %1, %struct.EncodedData* %2) {
%4 = icmp sgt i32 %1, 32
br i1 %4, label %5, label %13
5: ; preds = %3
%6 = add nsw i32 %1, -32
%7 = zext i32 %6 to i64
%8 = lshr i64 %0, %7
%9 = and i64 %8, 4294967295
%10 = tail call i32 @encode_big_endian_integer(i64 %9, i32 32, %struct.EncodedData* %2)
%11 = shl i64 %9, %7
%12 = sub i64 %0, %11
br label %13
13: ; preds = %5, %3
%14 = phi i32 [ %6, %5 ], [ %1, %3 ]
%15 = phi i64 [ %12, %5 ], [ %0, %3 ]
%16 = tail call i32 @encode_big_endian_integer(i64 %15, i32 %14, %struct.EncodedData* %2)
ret void
}