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

/* Variables and functions */
uint16_t pack_date(int day, int month, int year) {
  uint16_t pack = 0;
  pack |= ((day & 0x001f) << 11);
  pack |= ((month & 0x000f) << 7);
  if ((year >= 1900) && (year <= 1999))
    year %= 100;
  else if ((year >= 2000) && (year <= 2026)) {
    year %= 100;
    year += 100;
  } else
    year = 127;
  pack |= year;
  return pack;
}


x86 assembly (clang, -O0):
<pack_date>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1f,%eax
shl    $0xb,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
shl    $0x7,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x76c,-0xc(%rbp)
jl     115f <pack_date+0x5f>
cmpl   $0x7cf,-0xc(%rbp)
jg     115f <pack_date+0x5f>
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
jmp    11a1 <pack_date+0xa1>
cmpl   $0x7d0,-0xc(%rbp)
jl     1195 <pack_date+0x95>
cmpl   $0x7ea,-0xc(%rbp)
jg     1195 <pack_date+0x95>
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0xc(%rbp)
jmp    119c <pack_date+0x9c>
movl   $0x7f,-0xc(%rbp)
jmp    11a1 <pack_date+0xa1>
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack_date>:
mov    %esi,%eax
lea    -0x76c(%rdx),%ecx
cmp    $0x63,%ecx
ja     1125 <pack_date+0x25>
movzwl %dx,%ecx
shr    $0x2,%ecx
imul   $0x147b,%ecx,%ecx
shr    $0x11,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%edx
mov    %edx,%ecx
jmp    114d <pack_date+0x4d>
lea    -0x7d0(%rdx),%esi
mov    $0x7f,%cx
cmp    $0x1a,%esi
ja     114d <pack_date+0x4d>
movzwl %dx,%ecx
shr    $0x2,%ecx
imul   $0x147b,%ecx,%ecx
shr    $0x11,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %edx,%ecx
add    $0x64,%ecx
movzwl %cx,%ecx
shl    $0xb,%edi
movzwl %di,%edx
and    $0xf,%eax
shl    $0x7,%eax
or     %edx,%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @pack_date(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
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = and i32 %8, 31
%10 = shl i32 %9, 11
%11 = load i32, i32* %7
%12 = or i32 %11, %10
store i32 %12, i32* %7
%13 = load i32, i32* %5
%14 = and i32 %13, 15
%15 = shl i32 %14, 7
%16 = load i32, i32* %7
%17 = or i32 %16, %15
store i32 %17, i32* %7
%18 = load i32, i32* %6
%19 = icmp sge i32 %18, 1900
br i1 %19, label %20, label %26
20: ; preds = %3
%21 = load i32, i32* %6
%22 = icmp sle i32 %21, 1999
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %6
%25 = srem i32 %24, 100
store i32 %25, i32* %6
br label %39
26: ; preds = %20, %3
%27 = load i32, i32* %6
%28 = icmp sge i32 %27, 2000
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32, i32* %6
%31 = icmp sle i32 %30, 2026
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i32, i32* %6
%34 = srem i32 %33, 100
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 100
store i32 %36, i32* %6
br label %38
37: ; preds = %29, %26
store i32 127, i32* %6
br label %38
38: ; preds = %37, %32
br label %39
39: ; preds = %38, %23
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = or i32 %41, %40
store i32 %42, i32* %7
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
define i32 @pack_date(i32 %0, i32 %1, i32 %2) {
%4 = add i32 %2, -1900
%5 = icmp ult i32 %4, 100
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = trunc i32 %2 to i16
%8 = urem i16 %7, 100
br label %16
9: ; preds = %3
%10 = add i32 %2, -2000
%11 = icmp ult i32 %10, 27
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = trunc i32 %2 to i16
%14 = urem i16 %13, 100
%15 = add nuw nsw i16 %14, 100
br label %16
16: ; preds = %9, %12, %6
%17 = phi i16 [ %8, %6 ], [ %15, %12 ], [ 127, %9 ]
%18 = zext i16 %17 to i32
%19 = shl i32 %0, 11
%20 = and i32 %19, 63488
%21 = shl i32 %1, 7
%22 = and i32 %21, 1920
%23 = or i32 %22, %20
%24 = or i32 %23, %18
ret i32 %24
}