#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 */

/* Variables and functions */
unsigned int mp_getbits(unsigned char const *, unsigned int, unsigned char);
unsigned int mp_getbits16(const unsigned char *buffer, unsigned int from,
                          unsigned char len) {
  if (len > 8)
    return (mp_getbits(buffer, from, len - 8) << 8) |
           mp_getbits(buffer, from + len - 8, 8);
  else
    return mp_getbits(buffer, from, len);
}


x86 assembly (clang, -O0):
<mp_getbits16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
cmp    $0x8,%eax
jle    1176 <mp_getbits16+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movzbl -0x15(%rbp),%eax
sub    $0x8,%eax
movzbl %al,%edx
call   1030 <mp_getbits@plt>
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movzbl -0x15(%rbp),%eax
add    %eax,%esi
sub    $0x8,%esi
mov    $0x8,%edx
call   1030 <mp_getbits@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <mp_getbits16+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movzbl -0x15(%rbp),%edx
call   1030 <mp_getbits@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_getbits16>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
cmp    $0x9,%dl
jb     115b <mp_getbits16+0x4b>
movzbl %dl,%r15d
add    $0xf8,%dl
movzbl %dl,%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <mp_getbits@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
lea    (%rbx,%r15,1),%esi
add    $0xfffffff8,%esi
mov    %r14,%rdi
mov    $0x8,%edx
call   1030 <mp_getbits@plt>
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movzbl %dl,%edx
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mp_getbits@plt>

LLVM IR (-O0):
define i32 @mp_getbits16(i8* %0, i32 %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8 %2, i8* %7
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = icmp sgt i32 %9, 8
br i1 %10, label %11, label %28
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = load i8, i8* %7
%15 = zext i8 %14 to i32
%16 = sub nsw i32 %15, 8
%17 = trunc i32 %16 to i8
%18 = call i32 @mp_getbits(i8* %12, i32 %13, i8 zeroext %17)
%19 = shl i32 %18, 8
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = load i8, i8* %7
%23 = zext i8 %22 to i32
%24 = add i32 %21, %23
%25 = sub i32 %24, 8
%26 = call i32 @mp_getbits(i8* %20, i32 %25, i8 zeroext 8)
%27 = or i32 %19, %26
store i32 %27, i32* %4
br label %33
28: ; preds = %3
%29 = load i8*, i8** %5
%30 = load i32, i32* %6
%31 = load i8, i8* %7
%32 = call i32 @mp_getbits(i8* %29, i32 %30, i8 zeroext %31)
store i32 %32, i32* %4
br label %33
33: ; preds = %28, %11
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @mp_getbits16(i8* %0, i32 %1, i8 zeroext %2) {
%4 = icmp ugt i8 %2, 8
br i1 %4, label %5, label %14
5: ; preds = %3
%6 = zext i8 %2 to i32
%7 = add i8 %2, -8
%8 = tail call i32 @mp_getbits(i8* %0, i32 %1, i8 zeroext %7)
%9 = shl i32 %8, 8
%10 = add i32 %1, -8
%11 = add i32 %10, %6
%12 = tail call i32 @mp_getbits(i8* %0, i32 %11, i8 zeroext 8)
%13 = or i32 %9, %12
br label %16
14: ; preds = %3
%15 = tail call i32 @mp_getbits(i8* %0, i32 %1, i8 zeroext %2)
br label %16
16: ; preds = %14, %5
%17 = phi i32 [ %13, %5 ], [ %15, %14 ]
ret i32 %17
}