#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  uint32_t div = 0;
  div = 0x0000;
  printf("div: 0x%x\n", (((div & 0xFF) << 2 | (div & 0xc000) >> 14) + 2));
  printf("should be: 0x4\n");
  printf("div: 0x%x\n", (((0x8000 & 0xFF) << 2 | (0x8000 & 0xc000) >> 14) + 2));
  printf("div: 0x%x\n", (((0x9500 & 0xFF) << 2 | (0x9500 & 0xc000) >> 14) + 2));
  printf("div: 0x%x\n", (((0x8f00 & 0xFF) << 2 | (0x8f00 & 0xc000) >> 14) + 2));
  printf("should be: 0xc\n");
  printf("div: 0x%x\n", (((0xc000 & 0xFF) << 2 | (0xc000 & 0xc000) >> 14) + 2));
  printf("div: 0x%x\n", (((0xcc00 & 0xFF) << 2 | (0xcc00 & 0xc000) >> 14) + 2));
  printf("should be: 0x45 + 2\n");
  printf("div: 0x%x\n", (((0x4011 & 0xFF) << 2 | (0x4011 & 0xc000) >> 14) + 2));
  printf("div: 0x%x\n", (((0x7f11 & 0xFF) << 2 | (0x7f11 & 0xc000) >> 14) + 2));
  printf("should be: 0x8000\n");
  printf("packed div: 0x%x\n",
         ((((0x0004 - 2) >> 2) & 0xFF) | ((0x0004 - 2) & 0x3) << 14));
  printf("should be: 0x8002\n");
  printf("packed div: 0x%x\n",
         ((((0x000c - 2) >> 2) & 0xFF) | ((0x000c - 2) & 0x3) << 14));
  printf("should be: 0x8030\n");
  printf("packed div: 0x%x\n",
         ((((0x00c4 - 2) >> 2) & 0xFF) | ((0x00c4 - 2) & 0x3) << 14));
  printf("should be: 0xc0c3\n");
  printf("packed div: 0x%x\n",
         ((((0x7f11 - 2) >> 2) & 0xFF) | ((0x7f11 - 2) & 0x3) << 14));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
and    $0xff,%esi
shl    $0x2,%esi
mov    -0x8(%rbp),%eax
and    $0xc000,%eax
sar    $0xe,%eax
or     %eax,%esi
add    $0x2,%esi
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
mov    $0x47,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x47,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0c(%rip),%rdi
mov    $0x8002,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdeb(%rip),%rdi
mov    $0x8030,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdca(%rip),%rdi
mov    $0xc0c3,%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xedf(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x47,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x47,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
lea    0xe29(%rip),%rbx
mov    %rbx,%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x8002,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x8030,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xc0c3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"div: 0x%x\0A\00"
@.str.1 = [16 x i8] c"should be: 0x4\0A\00"
@.str.2 = [16 x i8] c"should be: 0xc\0A\00"
@.str.3 = [21 x i8] c"should be: 0x45 + 2\0A\00"
@.str.4 = [19 x i8] c"should be: 0x8000\0A\00"
@.str.5 = [18 x i8] c"packed div: 0x%x\0A\00"
@.str.6 = [19 x i8] c"should be: 0x8002\0A\00"
@.str.7 = [19 x i8] c"should be: 0x8030\0A\00"
@.str.8 = [19 x i8] c"should be: 0xc0c3\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 255
%5 = shl i32 %4, 2
%6 = load i32, i32* %2
%7 = and i32 %6, 49152
%8 = ashr i32 %7, 14
%9 = or i32 %5, %8
%10 = add nsw i32 %9, 2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 71)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 71)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 32768)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 32770)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 32816)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 49347)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"div: 0x%x\0A\00"
@.str.5 = [18 x i8] c"packed div: 0x%x\0A\00"
@str = [15 x i8] c"should be: 0x4\00"
@str.9 = [15 x i8] c"should be: 0xc\00"
@str.10 = [20 x i8] c"should be: 0x45 + 2\00"
@str.11 = [18 x i8] c"should be: 0x8000\00"
@str.12 = [18 x i8] c"should be: 0x8002\00"
@str.13 = [18 x i8] c"should be: 0x8030\00"
@str.14 = [18 x i8] c"should be: 0xc0c3\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 2)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 71)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 71)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 32768)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 32770)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 32816)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.14, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 49347)
ret i32 0
}