#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 */
char *bin(unsigned int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int *str2IntArr(char *);
void main() {
  int i;
  unsigned int fullDate = 20160222;
  unsigned int date, month, year, temp;
  temp = fullDate;
  char *fullDateAsString = (char *)malloc(sizeof(char) * 100);
  if (!fullDateAsString) {
    return;
  }
  date = temp % 100;
  temp /= 100;
  month = temp % 100;
  temp /= 100;
  year = temp;
  sprintf(fullDateAsString, "%s%s%s", bin(year, 0), bin(month, 1),
          bin(date, 2));
  printf("%s\n", fullDateAsString);
  int *res = (int *)malloc(sizeof(int) * 21);
  if (!res) {
    return;
  }
  res = str2IntArr(fullDateAsString);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x1339ede,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1183 <main+0x33>
jmp    124f <main+0xff>
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1040 <bin@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1040 <bin@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1040 <bin@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %rax,%r8
lea    0xdf1(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x20(%rbp),%rsi
lea    0xde8(%rip),%rdi
call   1050 <printf@plt>
mov    $0x54,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1242 <main+0xf2>
jmp    124f <main+0xff>
mov    -0x20(%rbp),%rdi
call   1030 <str2IntArr@plt>
mov    %rax,-0x28(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x64,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11da <main+0x8a>
mov    %rax,%rbx
mov    $0x7e0,%edi
xor    %esi,%esi
call   1040 <bin@plt>
mov    %rax,%r14
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <bin@plt>
mov    %rax,%r15
mov    $0x16,%edi
mov    $0x2,%esi
call   1040 <bin@plt>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rax,%r8
call   1070 <sprintf@plt>
lea    0xe51(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x54,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11da <main+0x8a>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <str2IntArr@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i32 20160222, i32* %2
%9 = load i32, i32* %2
store i32 %9, i32* %6
%10 = call i64 @malloc(i32 100)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %0
br label %43
15: ; preds = %0
%16 = load i32, i32* %6
%17 = urem i32 %16, 100
store i32 %17, i32* %3
%18 = load i32, i32* %6
%19 = udiv i32 %18, 100
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = urem i32 %20, 100
store i32 %21, i32* %4
%22 = load i32, i32* %6
%23 = udiv i32 %22, 100
store i32 %23, i32* %6
%24 = load i32, i32* %6
store i32 %24, i32* %5
%25 = load i8*, i8** %7
%26 = load i32, i32* %5
%27 = call i8* @bin(i32 %26, i32 0)
%28 = load i32, i32* %4
%29 = call i8* @bin(i32 %28, i32 1)
%30 = load i32, i32* %3
%31 = call i8* @bin(i32 %30, i32 2)
%32 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %29, i8* %31)
%33 = load i8*, i8** %7
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = call i64 @malloc(i32 84)
%36 = inttoptr i64 %35 to i32*
store i32* %36, i32** %8
%37 = load i32*, i32** %8
%38 = icmp ne i32* %37, null
br i1 %38, label %40, label %39
39: ; preds = %15
br label %43
40: ; preds = %15
%41 = load i8*, i8** %7
%42 = call i32* @str2IntArr(i8* %41)
store i32* %42, i32** %8
br label %43
43: ; preds = %40, %39, %14
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = tail call i64 @malloc(i32 100)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %0
%5 = tail call i8* @bin(i32 2016, i32 0)
%6 = tail call i8* @bin(i32 2, i32 1)
%7 = tail call i8* @bin(i32 22, i32 2)
%8 = tail call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6, i8* %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = tail call i64 @malloc(i32 84)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = tail call i32* @str2IntArr(i8* %2)
br label %14
14: ; preds = %12, %4, %0
ret void
}