#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 countlength(unsigned long);
int /*<<< orphan*/ myitoaa(unsigned long, char *);
int mystrlen(char *);
int /*<<< orphan*/ write(int, char *, int);
void getdate(unsigned long date) {
  int len = countlength(date);
  char top[len + 1];
  myitoaa(date, top);
  if (len == 1) {
    write(1, " ", 1);
  }
  write(1, top, mystrlen(top));
  write(1, " ", 1);
}


x86 assembly (clang, -O0):
<getdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <countlength@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <myitoaa@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11a7 <getdate+0x67>
mov    $0x1,%edx
lea    0xe60(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x28(%rbp),%rdi
call   1050 <mystrlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe34(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getdate>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <countlength@plt>
mov    %eax,%r15d
lea    0x1(%r15),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <myitoaa@plt>
cmp    $0x1,%r15d
jne    1191 <getdate+0x51>
lea    0xe7e(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %rbx,%rdi
call   1050 <mystrlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe51(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @getdate(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = call i32 @countlength(i64 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = load i64, i64* %2
%14 = call i32 @myitoaa(i64 %13, i8* %12)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %19
19: ; preds = %17, %1
%20 = call i32 @mystrlen(i8* %12)
%21 = call i32 @write(i32 1, i8* %12, i32 %20)
%22 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%23 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @getdate(i64 %0) {
%2 = tail call i32 @countlength(i64 %0)
%3 = add nsw i32 %2, 1
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @myitoaa(i64 %0, i8* %5)
%7 = icmp eq i32 %2, 1
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %10
10: ; preds = %8, %1
%11 = call i32 @mystrlen(i8* %5)
%12 = call i32 @write(i32 1, i8* %5, i32 %11)
%13 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
ret void
}