#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 */
typedef int uint64_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void create_descriptor(uint32_t base, uint32_t limit, uint16_t flag) {
  uint64_t descriptor;
  descriptor = limit & 0x000F0000;
  descriptor |= (flag << 8) & 0x00F0FF00;
  descriptor |= (base >> 16) & 0x000000FF;
  descriptor |= base & 0xFF000000;
  descriptor <<= 32;
  descriptor |= base << 16;
  descriptor |= limit & 0x0000FFFF;
  printf("0x%.16llX\n", descriptor);
}


x86 assembly (clang, -O0):
<create_descriptor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf0000,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
and    $0xf0ff00,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff000000,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x10,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_descriptor>:
lea    0xee9(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"0x%.16llX\0A\00"
define void @create_descriptor(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = and i32 %8, 983040
store i32 %9, i32* %7
%10 = load i32, i32* %6
%11 = shl i32 %10, 8
%12 = and i32 %11, 15793920
%13 = load i32, i32* %7
%14 = or i32 %13, %12
store i32 %14, i32* %7
%15 = load i32, i32* %4
%16 = ashr i32 %15, 16
%17 = and i32 %16, 255
%18 = load i32, i32* %7
%19 = or i32 %18, %17
store i32 %19, i32* %7
%20 = load i32, i32* %4
%21 = and i32 %20, -16777216
%22 = load i32, i32* %7
%23 = or i32 %22, %21
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = shl i32 %24, 32
store i32 %25, i32* %7
%26 = load i32, i32* %4
%27 = shl i32 %26, 16
%28 = load i32, i32* %7
%29 = or i32 %28, %27
store i32 %29, i32* %7
%30 = load i32, i32* %5
%31 = and i32 %30, 65535
%32 = load i32, i32* %7
%33 = or i32 %32, %31
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %34)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"0x%.16llX\0A\00"
define void @create_descriptor(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 poison)
ret void
}