#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*/ extractdate(short);
int /*<<< orphan*/ extractmonth(short);
int /*<<< orphan*/ extractyear(short);
int /*<<< orphan*/ printf(char *, short, ...);
short todate(int, int, int);
int main() {
  short int x;
  int date = 1, month = 04, year = 17;
  x = todate(month, date, year);
  printf("%x \n", x);
  printf("%u-%u-%u \n", ((x & 0xf000) >> 12), (x & 0x0f80) >> 7, (x & 0x007f));
  extractdate(x);
  extractmonth(x);
  extractyear(x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
movl   $0x11,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <todate@plt>
mov    %ax,-0x6(%rbp)
lea    0xe73(%rip),%rdi
movswl -0x6(%rbp),%esi
mov    $0x0,%al
call   1050 <printf@plt>
movswl -0x6(%rbp),%eax
and    $0xf000,%eax
sar    $0xc,%eax
movswl -0x6(%rbp),%edx
and    $0xf80,%edx
sar    $0x7,%edx
movswl -0x6(%rbp),%ecx
and    $0x7f,%ecx
lea    0xe46(%rip),%rdi
movswl %ax,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movswl -0x6(%rbp),%edi
call   1060 <extractdate@plt>
movswl -0x6(%rbp),%edi
call   1070 <extractmonth@plt>
movswl -0x6(%rbp),%edi
call   1040 <extractyear@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
mov    $0x1,%esi
mov    $0x11,%edx
call   1030 <todate@plt>
movswl %ax,%ebx
lea    0xe91(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movzwl %bx,%ecx
mov    %ecx,%esi
shr    $0xc,%esi
mov    %ecx,%edx
shr    $0x7,%edx
and    $0x1f,%edx
and    $0x7f,%ecx
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <extractdate@plt>
mov    %ebx,%edi
call   1070 <extractmonth@plt>
mov    %ebx,%edi
call   1040 <extractyear@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%x \0A\00"
@.str.1 = [11 x i8] c"%u-%u-%u \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
store i32 4, i32* %4
store i32 17, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %5
%9 = call signext i16 @todate(i32 %6, i32 %7, i32 %8)
store i16 %9, i16* %2
%10 = load i16, i16* %2
%11 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %10)
%12 = load i16, i16* %2
%13 = sext i16 %12 to i32
%14 = and i32 %13, 61440
%15 = ashr i32 %14, 12
%16 = trunc i32 %15 to i16
%17 = load i16, i16* %2
%18 = sext i16 %17 to i32
%19 = and i32 %18, 3968
%20 = ashr i32 %19, 7
%21 = load i16, i16* %2
%22 = sext i16 %21 to i32
%23 = and i32 %22, 127
%24 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i16 signext %16, i32 %20, i32 %23)
%25 = load i16, i16* %2
%26 = call i32 @extractdate(i16 signext %25)
%27 = load i16, i16* %2
%28 = call i32 @extractmonth(i16 signext %27)
%29 = load i16, i16* %2
%30 = call i32 @extractyear(i16 signext %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%x \0A\00"
@.str.1 = [11 x i8] c"%u-%u-%u \0A\00"
define i32 @main() {
%1 = tail call signext i16 @todate(i32 4, i32 1, i32 17)
%2 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 signext %1)
%3 = zext i16 %1 to i32
%4 = lshr i16 %1, 12
%5 = lshr i32 %3, 7
%6 = and i32 %5, 31
%7 = and i32 %3, 127
%8 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i16 signext %4, i32 %6, i32 %7)
%9 = tail call i32 @extractdate(i16 signext %1)
%10 = tail call i32 @extractmonth(i16 signext %1)
%11 = tail call i32 @extractyear(i16 signext %1)
ret i32 0
}