#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 /*<<< orphan*/ time_t;
struct tm {
  scalar_t__ tm_mday;
  scalar_t__ tm_mon;
  scalar_t__ tm_year;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *calendar(int year, int month, int day) {
  static char calbuff[4096];
  time_t time_val = (time_t)(0);
  struct tm *tmstruct = (struct tm *)NULL, *localtime();
  int yy = 0, mm = 0, dd = 0;
  int idd = 1, iday = 0, daynumber();
  char aval[64];
  static char *monthnames[] = {
      "?",    "January", "February",  "March",   "April",    "May",      "June",
      "July", "August",  "September", "October", "November", "December", "?"};
  static int modays[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
  time((time_t *)(&time_val));
  tmstruct = localtime((time_t *)(&time_val));
  yy = 1900 + (int)(tmstruct->tm_year);
  mm = 1 + (int)(tmstruct->tm_mon);
  dd = (int)(tmstruct->tm_mday);
  if (year < 1973 || year > 2099)
    year = yy;
  if (month < 1 || month > 12)
    month = mm;
  if (month == mm && year == yy && day == 0)
    day = dd;
  modays[2] = (year % 4 == 0 ? 29 : 28);
  strcpy(calbuff, "{\\begin{gather}");
  strcat(calbuff, "\\small\\text{");
  strcat(calbuff, monthnames[month]);
  strcat(calbuff, " }");
  sprintf(aval, "%d", year);
  strcat(calbuff, aval);
  strcat(calbuff, "\\\\");
  strcat(calbuff, "\\begin{array}{|c|c|c|c|c|c|c|CCCCCC} \\hline"
                  "\\tiny\\text{Sun} & \\tiny\\text{Mon} & \\tiny\\text{Tue} &"
                  "\\tiny\\text{Wed} & \\tiny\\text{Thu} & \\tiny\\text{Fri} &"
                  "\\tiny\\text{Sat} \\\\ \\hline ");
  for (idd = 1; idd <= modays[month]; idd++) {
    iday = 1 + (daynumber(year, month, idd) % 7);
    if (iday == 7)
      iday = 0;
    if (idd == 1)
      if (iday > 0) {
        strcpy(aval, "\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\");
        aval[3 * iday] = '\000';
        strcat(calbuff, aval);
      }
    sprintf(aval, "%d", idd);
    if (idd == day) {
      strcat(calbuff, "{\\fs{-1}\\left\\langle ");
      strcat(calbuff, aval);
      strcat(calbuff, "\\right\\rangle}");
    } else
      strcat(calbuff, aval);
    if (idd < modays[month]) {
      if (iday < 6)
        strcat(calbuff, "&");
      else
        strcat(calbuff, "\\\\ \\hline");
    }
  }
  strcat(calbuff, "\\\\ \\hline");
  strcat(calbuff, "\\end{array}\\end{gather}}");
  return (calbuff);
}


x86 assembly (clang, -O0):
<calendar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <time@plt>
lea    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
add    $0x76c,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x7b5,-0x4(%rbp)
jl     11fd <calendar+0x9d>
cmpl   $0x833,-0x4(%rbp)
jle    1203 <calendar+0xa3>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     1217 <calendar+0xb7>
cmpl   $0xc,-0x8(%rbp)
jle    121d <calendar+0xbd>
mov    -0x20(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1245 <calendar+0xe5>
mov    -0x4(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1245 <calendar+0xe5>
cmpl   $0x0,-0xc(%rbp)
jne    1245 <calendar+0xe5>
mov    -0x24(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    $0x1c,%eax
mov    $0x1d,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,0x2e72(%rip)
lea    0x2eb3(%rip),%rdi
lea    0xde4(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x2ea0(%rip),%rdi
lea    0xde1(%rip),%rsi
call   1070 <strcat@plt>
movslq -0x8(%rbp),%rcx
lea    0x2dc9(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0x2e7e(%rip),%rdi
call   1070 <strcat@plt>
lea    0x2e72(%rip),%rdi
lea    0xdc0(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdb0(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x70(%rbp),%rsi
lea    0x2e48(%rip),%rdi
call   1070 <strcat@plt>
lea    0x2e3c(%rip),%rdi
lea    0xd90(%rip),%rsi
call   1070 <strcat@plt>
lea    0x2e29(%rip),%rdi
lea    0xd80(%rip),%rsi
call   1070 <strcat@plt>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
movslq -0x8(%rbp),%rdx
lea    0x2db8(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jg     1462 <calendar+0x302>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    $0x0,%al
call   1060 <daynumber@plt>
mov    $0x7,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
cmpl   $0x7,-0x2c(%rbp)
jne    1350 <calendar+0x1f0>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    1394 <calendar+0x234>
cmpl   $0x0,-0x2c(%rbp)
jle    138f <calendar+0x22f>
lea    -0x70(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1040 <strcpy@plt>
imul   $0x3,-0x2c(%rbp),%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0x2d96(%rip),%rdi
call   1070 <strcat@plt>
jmp    1394 <calendar+0x234>
lea    -0x70(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xcd6(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    13ee <calendar+0x28e>
lea    0x2d66(%rip),%rdi
lea    0xd8a(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x70(%rbp),%rsi
lea    0x2d4f(%rip),%rdi
call   1070 <strcat@plt>
lea    0x2d43(%rip),%rdi
lea    0xd7d(%rip),%rsi
call   1070 <strcat@plt>
jmp    13fe <calendar+0x29e>
lea    -0x70(%rbp),%rsi
lea    0x2d27(%rip),%rdi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%eax
movslq -0x8(%rbp),%rdx
lea    0x2cc4(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jge    144f <calendar+0x2ef>
cmpl   $0x6,-0x2c(%rbp)
jge    1437 <calendar+0x2d7>
lea    0x2cfa(%rip),%rdi
lea    0xd43(%rip),%rsi
call   1070 <strcat@plt>
jmp    144a <calendar+0x2ea>
lea    0x2ce2(%rip),%rdi
lea    0xd2d(%rip),%rsi
call   1070 <strcat@plt>
jmp    144f <calendar+0x2ef>
jmp    1454 <calendar+0x2f4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    130a <calendar+0x1aa>
lea    0x2cb7(%rip),%rdi
lea    0xd02(%rip),%rsi
call   1070 <strcat@plt>
lea    0x2ca4(%rip),%rdi
lea    0xcf9(%rip),%rsi
call   1070 <strcat@plt>
lea    0x2c91(%rip),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calendar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1050 <time@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <localtime@plt>
mov    $0x76c,%ecx
add    0x10(%rax),%ecx
mov    0x8(%rax),%edx
add    $0x1,%edx
lea    -0x834(%rbx),%esi
cmp    $0xffffff81,%esi
cmovb  %ecx,%ebx
lea    -0xd(%rbp),%esi
cmp    $0xfffffff4,%esi
cmovb  %edx,%ebp
mov    %rbp,0x18(%rsp)
xor    %ebp,%edx
mov    %rbx,0x10(%rsp)
xor    %ebx,%ecx
mov    %r15d,0x8(%rsp)
or     %r15d,%edx
or     %ecx,%edx
jne    11d7 <calendar+0x77>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
mov    0x10(%rsp),%r14
test   $0x3,%r14b
sete   %al
or     $0x1c,%eax
mov    %eax,0x2e7a(%rip)
lea    0x2e6b(%rip),%r15
lea    0x2eb4(%rip),%rbx
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
movslq 0x18(%rsp),%rbp
lea    0xdda(%rip),%rax
movslq (%rax,%rbp,4),%rsi
add    %rax,%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe65(%rip),%rsi
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    %r14d,%edx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rbx
call   1070 <strcat@plt>
cmpl   $0x0,(%r15,%rbp,4)
jle    13d9 <calendar+0x279>
mov    %r15,%rax
addl   $0xffffffff,0x8(%rsp)
xor    %r14d,%r14d
jmp    12bc <calendar+0x15c>
nop
lea    0x2e09(%rip),%rdi
call   1070 <strcat@plt>
mov    %r12,%rax
mov    %r15d,%r14d
cmp    (%rax,%rbx,4),%r15d
jge    13d9 <calendar+0x279>
mov    %rax,%r12
lea    0x1(%r14),%r15d
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <daynumber@plt>
cltq
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    $0x0,%r13d
cmp    $0x7,%eax
je     130c <calendar+0x1ac>
mov    %eax,%r13d
test   %r14d,%r14d
jne    1345 <calendar+0x1e5>
test   %r13d,%r13d
jle    1345 <calendar+0x1e5>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
lea    0xe41(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r13d,%eax
lea    (%rax,%rax,2),%rax
movb   $0x0,0x20(%rsp,%rax,1)
lea    0x2d73(%rip),%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
lea    0xd5c(%rip),%rsi
mov    %r15d,%edx
call   1080 <sprintf@plt>
cmp    %r14d,0x8(%rsp)
jne    13a0 <calendar+0x240>
mov    %rbx,%r14
lea    0x2d43(%rip),%rbx
mov    %rbx,%rdi
lea    0xe0c(%rip),%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rbx
lea    0xe05(%rip),%rsi
jmp    13aa <calendar+0x24a>
cs nopw 0x0(%rax,%rax,1)
lea    0x2d09(%rip),%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %r12,%rax
cmp    (%r12,%rbx,4),%r15d
jge    12af <calendar+0x14f>
lea    0xde5(%rip),%rsi
cmp    $0x6,%r13d
jl     12a0 <calendar+0x140>
lea    0xdd6(%rip),%rsi
jmp    12a0 <calendar+0x140>
lea    0x2cd0(%rip),%rbx
lea    0xdc3(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xdbe(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i64, i64, i64 }
@calendar.calbuff = internal global [4096 x i8] zeroinitializer
@calendar.monthnames = internal global [14 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)]
@.str = [2 x i8] c"?\00"
@.str.1 = [8 x i8] c"January\00"
@.str.2 = [9 x i8] c"February\00"
@.str.3 = [6 x i8] c"March\00"
@.str.4 = [6 x i8] c"April\00"
@.str.5 = [4 x i8] c"May\00"
@.str.6 = [5 x i8] c"June\00"
@.str.7 = [5 x i8] c"July\00"
@.str.8 = [7 x i8] c"August\00"
@.str.9 = [10 x i8] c"September\00"
@.str.10 = [8 x i8] c"October\00"
@.str.11 = [9 x i8] c"November\00"
@.str.12 = [9 x i8] c"December\00"
@calendar.modays = internal global [14 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31, i32 0]
@.str.13 = [16 x i8] c"{\\begin{gather}\00"
@.str.14 = [13 x i8] c"\\small\\text{\00"
@.str.15 = [3 x i8] c" }\00"
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [3 x i8] c"\\\\\00"
@.str.18 = [176 x i8] c"\\begin{array}{|c|c|c|c|c|c|c|CCCCCC} \\hline\\tiny\\text{Sun} & \\tiny\\text{Mon} & \\tiny\\text{Tue} &\\tiny\\text{Wed} & \\tiny\\text{Thu} & \\tiny\\text{Fri} &\\tiny\\text{Sat} \\\\ \\hline \00"
@.str.19 = [29 x i8] c"\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\\00"
@.str.20 = [22 x i8] c"{\\fs{-1}\\left\\langle \00"
@.str.21 = [15 x i8] c"\\right\\rangle}\00"
@.str.22 = [2 x i8] c"&\00"
@.str.23 = [10 x i8] c"\\\\ \\hline\00"
@.str.24 = [25 x i8] c"\\end{array}\\end{gather}}\00"
define i8* @calendar(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.tm*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [64 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store %struct.tm* null, %struct.tm** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 1, i32* %12
store i32 0, i32* %13
%15 = call i32 @time(i32* %7)
%16 = call %struct.tm* (i32*, ...) bitcast (%struct.tm* (...)* @localtime to %struct.tm* (i32*, ...)*)(i32* %7)
store %struct.tm* %16, %struct.tm** %8
%17 = load %struct.tm*, %struct.tm** %8
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 2
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = add nsw i32 1900, %20
store i32 %21, i32* %9
%22 = load %struct.tm*, %struct.tm** %8
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = add nsw i32 1, %25
store i32 %26, i32* %10
%27 = load %struct.tm*, %struct.tm** %8
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 0
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i32
store i32 %30, i32* %11
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 1973
br i1 %32, label %36, label %33
33: ; preds = %3
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 2099
br i1 %35, label %36, label %38
36: ; preds = %33, %3
%37 = load i32, i32* %9
store i32 %37, i32* %4
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* %5
%40 = icmp slt i32 %39, 1
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* %5
%43 = icmp sgt i32 %42, 12
br i1 %43, label %44, label %46
44: ; preds = %41, %38
%45 = load i32, i32* %10
store i32 %45, i32* %5
br label %46
46: ; preds = %44, %41
%47 = load i32, i32* %5
%48 = load i32, i32* %10
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %59
50: ; preds = %46
%51 = load i32, i32* %4
%52 = load i32, i32* %9
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = load i32, i32* %6
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = load i32, i32* %11
store i32 %58, i32* %6
br label %59
59: ; preds = %57, %54, %50, %46
%60 = load i32, i32* %4
%61 = srem i32 %60, 4
%62 = icmp eq i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i32 29, i32 28
store i32 %64, i32* getelementptr inbounds ([14 x i32], [14 x i32]* @calendar.modays, i64 0, i64 2)
%65 = call i32 @strcpy(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
%66 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [14 x i8*], [14 x i8*]* @calendar.monthnames, i64 0, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %70)
%72 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%73 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%74 = load i32, i32* %4
%75 = call i32 @sprintf(i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%77 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %76)
%78 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%79 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.18, i64 0, i64 0))
store i32 1, i32* %12
br label %80
80: ; preds = %144, %59
%81 = load i32, i32* %12
%82 = load i32, i32* %5
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [14 x i32], [14 x i32]* @calendar.modays, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = icmp sle i32 %81, %85
br i1 %86, label %87, label %147
87: ; preds = %80
%88 = load i32, i32* %4
%89 = load i32, i32* %5
%90 = load i32, i32* %12
%91 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %88, i32 %89, i32 %90)
%92 = srem i32 %91, 7
%93 = add nsw i32 1, %92
store i32 %93, i32* %13
%94 = load i32, i32* %13
%95 = icmp eq i32 %94, 7
br i1 %95, label %96, label %97
96: ; preds = %87
store i32 0, i32* %13
br label %97
97: ; preds = %96, %87
%98 = load i32, i32* %12
%99 = icmp eq i32 %98, 1
br i1 %99, label %100, label %113
100: ; preds = %97
%101 = load i32, i32* %13
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %112
103: ; preds = %100
%104 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%105 = call i32 @strcpy(i8* %104, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0))
%106 = load i32, i32* %13
%107 = mul nsw i32 3, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 %108
store i8 0, i8* %109
%110 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%111 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %103, %100
br label %113
113: ; preds = %112, %97
%114 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%115 = load i32, i32* %12
%116 = call i32 @sprintf(i8* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %115)
%117 = load i32, i32* %12
%118 = load i32, i32* %6
%119 = icmp eq i32 %117, %118
br i1 %119, label %120, label %125
120: ; preds = %113
%121 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.20, i64 0, i64 0))
%122 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%123 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %122)
%124 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0))
br label %128
125: ; preds = %113
%126 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%127 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %126)
br label %128
128: ; preds = %125, %120
%129 = load i32, i32* %12
%130 = load i32, i32* %5
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [14 x i32], [14 x i32]* @calendar.modays, i64 0, i64 %131
%133 = load i32, i32* %132
%134 = icmp slt i32 %129, %133
br i1 %134, label %135, label %143
135: ; preds = %128
%136 = load i32, i32* %13
%137 = icmp slt i32 %136, 6
br i1 %137, label %138, label %140
138: ; preds = %135
%139 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i64 0, i64 0))
br label %142
140: ; preds = %135
%141 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.23, i64 0, i64 0))
br label %142
142: ; preds = %140, %138
br label %143
143: ; preds = %142, %128
br label %144
144: ; preds = %143
%145 = load i32, i32* %12
%146 = add nsw i32 %145, 1
store i32 %146, i32* %12
br label %80
147: ; preds = %80
%148 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.23, i64 0, i64 0))
%149 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.24, i64 0, i64 0))
ret i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i64, i64, i64 }
@calendar.calbuff = internal global [4096 x i8] zeroinitializer
@reltable.calendar = internal unnamed_addr constant [14 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.10 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.11 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.12 to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([14 x i32]* @reltable.calendar to i64)) to i32)]
@.str = [2 x i8] c"?\00"
@.str.1 = [8 x i8] c"January\00"
@.str.2 = [9 x i8] c"February\00"
@.str.3 = [6 x i8] c"March\00"
@.str.4 = [6 x i8] c"April\00"
@.str.5 = [4 x i8] c"May\00"
@.str.6 = [5 x i8] c"June\00"
@.str.7 = [5 x i8] c"July\00"
@.str.8 = [7 x i8] c"August\00"
@.str.9 = [10 x i8] c"September\00"
@.str.10 = [8 x i8] c"October\00"
@.str.11 = [9 x i8] c"November\00"
@.str.12 = [9 x i8] c"December\00"
@calendar.modays = internal unnamed_addr global [14 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31, i32 0]
@.str.13 = [16 x i8] c"{\\begin{gather}\00"
@.str.14 = [13 x i8] c"\\small\\text{\00"
@.str.15 = [3 x i8] c" }\00"
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [3 x i8] c"\\\\\00"
@.str.18 = [176 x i8] c"\\begin{array}{|c|c|c|c|c|c|c|CCCCCC} \\hline\\tiny\\text{Sun} & \\tiny\\text{Mon} & \\tiny\\text{Tue} &\\tiny\\text{Wed} & \\tiny\\text{Thu} & \\tiny\\text{Fri} &\\tiny\\text{Sat} \\\\ \\hline \00"
@.str.19 = [29 x i8] c"\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\ &\\\00"
@.str.20 = [22 x i8] c"{\\fs{-1}\\left\\langle \00"
@.str.21 = [15 x i8] c"\\right\\rangle}\00"
@.str.22 = [2 x i8] c"&\00"
@.str.23 = [10 x i8] c"\\\\ \\hline\00"
@.str.24 = [25 x i8] c"\\end{array}\\end{gather}}\00"
define i8* @calendar(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca [64 x i8]
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = call i32 @time(i32* %4)
%9 = call %struct.tm* (i32*, ...) bitcast (%struct.tm* (...)* @localtime to %struct.tm* (i32*, ...)*)(i32* %4)
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 2
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = add nsw i32 %12, 1900
%14 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%15 = load i64, i64* %14
%16 = trunc i64 %15 to i32
%17 = add nsw i32 %16, 1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = add i32 %0, -2100
%22 = icmp ult i32 %21, -127
%23 = select i1 %22, i32 %13, i32 %0
%24 = add i32 %1, -13
%25 = icmp ult i32 %24, -12
%26 = select i1 %25, i32 %17, i32 %1
%27 = icmp eq i32 %26, %17
%28 = icmp eq i32 %23, %13
%29 = icmp eq i32 %2, 0
%30 = and i1 %29, %28
%31 = select i1 %27, i1 %30, i1 false
%32 = select i1 %31, i32 %20, i32 %2
%33 = and i32 %23, 3
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i32 29, i32 28
store i32 %35, i32* getelementptr inbounds ([14 x i32], [14 x i32]* @calendar.modays, i64 0, i64 2)
%36 = call i32 @strcpy(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
%37 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%38 = sext i32 %26 to i64
%39 = shl i64 %38, 2
%40 = call i8* @llvm.load.relative.i64(i8* bitcast ([14 x i32]* @reltable.calendar to i8*), i64 %39)
%41 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %40)
%42 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%43 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %23)
%44 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %7)
%45 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%46 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.18, i64 0, i64 0))
%47 = getelementptr inbounds [14 x i32], [14 x i32]* @calendar.modays, i64 0, i64 %38
%48 = load i32, i32* %47
%49 = icmp slt i32 %48, 1
br i1 %49, label %86, label %50
50: ; preds = %3, %82
%51 = phi i32 [ %83, %82 ], [ 1, %3 ]
%52 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @daynumber to i32 (i32, i32, i32, ...)*)(i32 %23, i32 %26, i32 %51)
%53 = srem i32 %52, 7
%54 = add nsw i32 %53, 1
%55 = icmp eq i32 %54, 7
%56 = select i1 %55, i32 0, i32 %54
%57 = icmp eq i32 %51, 1
%58 = icmp sgt i32 %56, 0
%59 = select i1 %57, i1 %58, i1 false
br i1 %59, label %60, label %66
60: ; preds = %50
%61 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0))
%62 = mul nuw nsw i32 %56, 3
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %63
store i8 0, i8* %64
%65 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %7)
br label %66
66: ; preds = %60, %50
%67 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 %51)
%68 = icmp eq i32 %51, %32
br i1 %68, label %69, label %73
69: ; preds = %66
%70 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.20, i64 0, i64 0))
%71 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %7)
%72 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.21, i64 0, i64 0))
br label %75
73: ; preds = %66
%74 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %7)
br label %75
75: ; preds = %73, %69
%76 = load i32, i32* %47
%77 = icmp slt i32 %51, %76
br i1 %77, label %78, label %82
78: ; preds = %75
%79 = icmp slt i32 %56, 6
%80 = select i1 %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.23, i64 0, i64 0)
%81 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %78, %75
%83 = add nuw nsw i32 %51, 1
%84 = load i32, i32* %47
%85 = icmp slt i32 %51, %84
br i1 %85, label %50, label %86
86: ; preds = %82, %3
%87 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.23, i64 0, i64 0))
%88 = call i32 @strcat(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.24, i64 0, i64 0))
ret i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @calendar.calbuff, i64 0, i64 0)
}