#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 */
int /*<<< orphan*/ debug_print_int(char *, unsigned long);
int /*<<< orphan*/ early_puts(char *);
unsigned long virtio_extract_length(unsigned long rec_list1,
                                    unsigned long rec_list2) {
  unsigned long retval;
  early_puts("_extract_length\n");
  debug_print_int("rec_list1", rec_list1);
  debug_print_int("rec_list2", rec_list2);
  retval = (((rec_list2 >> 32) + 1) & 0xffff) * (rec_list2 >> 48);
  debug_print_int("length", retval);
  return retval;
}


x86 assembly (clang, -O0):
<virtio_extract_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec9(%rip),%rdi
call   1030 <early_puts@plt>
mov    -0x8(%rbp),%rsi
lea    0xeca(%rip),%rdi
call   1040 <debug_print_int@plt>
mov    -0x10(%rbp),%rsi
lea    0xec4(%rip),%rdi
call   1040 <debug_print_int@plt>
mov    -0x10(%rbp),%rax
shr    $0x20,%rax
add    $0x1,%rax
and    $0xffff,%rax
mov    -0x10(%rbp),%rcx
shr    $0x30,%rcx
imul   %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1040 <debug_print_int@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<virtio_extract_length>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xecf(%rip),%rdi
call   1030 <early_puts@plt>
lea    0xed4(%rip),%rdi
mov    %r14,%rsi
call   1040 <debug_print_int@plt>
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
call   1040 <debug_print_int@plt>
mov    %rbx,%rax
shr    $0x20,%rax
add    $0x1,%eax
movzwl %ax,%eax
shr    $0x30,%rbx
imul   %rax,%rbx
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <debug_print_int@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"_extract_length\0A\00"
@.str.1 = [10 x i8] c"rec_list1\00"
@.str.2 = [10 x i8] c"rec_list2\00"
@.str.3 = [7 x i8] c"length\00"
define i64 @virtio_extract_length(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = call i32 @early_puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* %3
%8 = call i32 @debug_print_int(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = load i64, i64* %4
%10 = call i32 @debug_print_int(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %4
%12 = lshr i64 %11, 32
%13 = add i64 %12, 1
%14 = and i64 %13, 65535
%15 = load i64, i64* %4
%16 = lshr i64 %15, 48
%17 = mul i64 %14, %16
store i64 %17, i64* %5
%18 = load i64, i64* %5
%19 = call i32 @debug_print_int(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %18)
%20 = load i64, i64* %5
ret i64 %20
}

LLVM IR (-O2):
@.str = [17 x i8] c"_extract_length\0A\00"
@.str.1 = [10 x i8] c"rec_list1\00"
@.str.2 = [10 x i8] c"rec_list2\00"
@.str.3 = [7 x i8] c"length\00"
define i64 @virtio_extract_length(i64 %0, i64 %1) {
%3 = tail call i32 @early_puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @debug_print_int(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %0)
%5 = tail call i32 @debug_print_int(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 %1)
%6 = lshr i64 %1, 32
%7 = add nuw nsw i64 %6, 1
%8 = and i64 %7, 65535
%9 = lshr i64 %1, 48
%10 = mul nuw nsw i64 %8, %9
%11 = tail call i32 @debug_print_int(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %10)
ret i64 %10
}