#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*/ printf(char *, ...);
int /*<<< orphan*/ printgrid(size_t, size_t, int, int);
int /*<<< orphan*/ putchar(char);
void drawcal(size_t year, int month, size_t ncols, size_t nmons, int fday) {
  char *smon[] = {"  January", " February", "    March", "    April",
                  "      May", "     June", "     July", "   August",
                  "September", "  October", " November", " December"};
  char *days[] = {
      "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa",
  };
  size_t m, n, col, cur_year, cur_month, dow;
  int line;
  for (m = 0; m < nmons;) {
    n = m;
    for (col = 0; m < nmons && col < ncols; ++col, ++m) {
      cur_year = year + m / 12;
      cur_month = month + m % 12;
      if (cur_month > 11) {
        cur_month -= 12;
        cur_year += 1;
      }
      printf("   %s %zu    ", smon[cur_month], cur_year);
      printf("  ");
    }
    putchar('\n');
    for (col = 0, m = n; m < nmons && col < ncols; ++col, ++m) {
      for (dow = fday; dow < (fday + 7); ++dow)
        printf("%s ", days[dow % 7]);
      printf("  ");
    }
    putchar('\n');
    for (line = 1; line <= 6; ++line) {
      for (col = 0, m = n; m < nmons && col < ncols; ++col, ++m) {
        cur_year = year + m / 12;
        cur_month = month + m % 12;
        if (cur_month > 11) {
          cur_month -= 12;
          cur_year += 1;
        }
        printgrid(cur_year, cur_month, fday, line);
        printf("  ");
      }
      putchar('\n');
    }
  }
}


x86 assembly (clang, -O0):
<drawcal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c14(%rip),%rsi
mov    $0x60,%edx
call   1050 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0x2c5c(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
movq   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1568 <drawcal+0x428>
mov    -0xd8(%rbp),%rax
mov    %rax,-0xe0(%rbp)
movq   $0x0,-0xe8(%rbp)
mov    -0xd8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x105(%rbp)
jae    11f0 <drawcal+0xb0>
mov    -0xe8(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x105(%rbp)
mov    -0x105(%rbp),%al
test   $0x1,%al
jne    1203 <drawcal+0xc3>
jmp    12ed <drawcal+0x1ad>
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0xd8(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x118(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0xf0(%rbp)
movslq -0xc(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0xd8(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x110(%rbp),%rax
add    %rdx,%rax
mov    %rax,-0xf8(%rbp)
cmpq   $0xb,-0xf8(%rbp)
0b
jbe    1292 <drawcal+0x152>
mov    -0xf8(%rbp),%rax
sub    $0xc,%rax
mov    %rax,-0xf8(%rbp)
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf8(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rsi
ff
mov    -0xf0(%rbp),%rdx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xe8(%rbp)
mov    -0xd8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd8(%rbp)
jmp    11c3 <drawcal+0x83>
mov    $0xa,%edi
call   1030 <putchar@plt>
movq   $0x0,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x119(%rbp)
jae    133d <drawcal+0x1fd>
mov    -0xe8(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    1350 <drawcal+0x210>
jmp    13e9 <drawcal+0x2a9>
movslq -0x24(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x100(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    13b2 <drawcal+0x272>
mov    -0x100(%rbp),%rax
mov    $0x7,%ecx
xor    %edx,%edx
div    %rcx
mov    -0xd0(%rbp,%rdx,8),%rsi
ff
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x100(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x100(%rbp)
jmp    135b <drawcal+0x21b>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xe8(%rbp)
mov    -0xd8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd8(%rbp)
jmp    1310 <drawcal+0x1d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x1,-0x104(%rbp)
cmpl   $0x6,-0x104(%rbp)
jg     1563 <drawcal+0x423>
movq   $0x0,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x11a(%rbp)
jae    1450 <drawcal+0x310>
mov    -0xe8(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x11a(%rbp)
mov    -0x11a(%rbp),%al
test   $0x1,%al
jne    1463 <drawcal+0x323>
jmp    1545 <drawcal+0x405>
mov    -0x8(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0xd8(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0xf0(%rbp)
movslq -0xc(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0xd8(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x128(%rbp),%rax
add    %rdx,%rax
mov    %rax,-0xf8(%rbp)
cmpq   $0xb,-0xf8(%rbp)
0b
jbe    14f2 <drawcal+0x3b2>
mov    -0xf8(%rbp),%rax
sub    $0xc,%rax
mov    %rax,-0xf8(%rbp)
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rdi
mov    -0xf8(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x104(%rbp),%ecx
call   1060 <printgrid@plt>
lea    0xb83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xe8(%rbp)
mov    -0xd8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd8(%rbp)
jmp    1423 <drawcal+0x2e3>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    13fd <drawcal+0x2bd>
jmp    1199 <drawcal+0x59>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawcal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8d,0x4(%rsp)
mov    %rdi,0x18(%rsp)
test   %rcx,%rcx
je     1409 <drawcal+0x2d9>
mov    %rcx,%r14
mov    %rdx,%r15
movslq %esi,%rbx
movslq 0x4(%rsp),%rcx
lea    0x7(%rcx),%eax
cltq
mov    %rax,0x48(%rsp)
lea    0xf60(%rip),%rax
mov    %rcx,0x30(%rsp)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x28(%rsp)
lea    0xf1b(%rip),%r13
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %r14,0x40(%rsp)
mov    %rdx,0x38(%rsp)
mov    %rbx,0x20(%rsp)
jmp    11b8 <drawcal+0x88>
nopl   (%rax)
mov    %r13,%rax
mov    %r13,0x8(%rsp)
cmp    %r14,%r13
lea    0xeee(%rip),%r13
jae    1409 <drawcal+0x2d9>
test   %r15,%r15
je     124c <drawcal+0x11c>
xor    %r12d,%r12d
mov    0x8(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbp,%rax
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mul    %rcx
shr    $0x3,%rdx
mov    0x18(%rsp),%rax
add    %rdx,%rax
shl    $0x2,%rdx
lea    (%rdx,%rdx,2),%rcx
mov    %rbp,%rdx
sub    %rcx,%rdx
lea    (%rdx,%rbx,1),%rcx
cmp    $0xc,%rcx
sbb    $0xffffffffffffffff,%rax
cmp    $0xc,%rcx
lea    -0xc(%rbx,%rdx,1),%rdx
cmovb  %rcx,%rdx
movslq 0x0(%r13,%rdx,4),%rsi
add    %r13,%rsi
lea    0xe6b(%rip),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
jae    124c <drawcal+0x11c>
add    $0x1,%r12
cmp    %r15,%r12
jb     11d0 <drawcal+0xa0>
test   %r15,%r15
setne  %bpl
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r14,0x8(%rsp)
setb   %al
and    %bpl,%al
mov    %al,0x3(%rsp)
cmp    $0x1,%al
jne    1344 <drawcal+0x214>
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%rdx
mov    %rdx,0x50(%rsp)
cmpl   $0xfffffff8,0x4(%rsp)
mov    0x48(%rsp),%r13
lea    0xe3a(%rip),%rcx
movabs $0x2492492492492493,%rdx
49 92 24
lea    0xdf4(%rip),%r15
ja     1304 <drawcal+0x1d4>
mov    0x28(%rsp),%r12
mov    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rax
mov    %rdx,%rbx
mul    %rdx
mov    %rbp,%rax
sub    %rdx,%rax
shr    %rax
add    %rdx,%rax
shr    $0x2,%rax
imul   $0xffffffffffffffe4,%rax,%rax
movslq (%r12,%rax,1),%rsi
add    %rcx,%rsi
mov    %r15,%rdi
xor    %eax,%eax
mov    %rcx,%r14
call   1040 <printf@plt>
mov    %rbx,%rdx
mov    %r14,%rcx
add    $0x1,%rbp
add    $0x4,%r12
cmp    %r13,%rbp
jb     12c0 <drawcal+0x190>
lea    0xd8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x50(%rsp),%rdx
add    $0x1,%rdx
mov    0x40(%rsp),%r14
cmp    %r14,%rdx
mov    0x38(%rsp),%r15
jae    1344 <drawcal+0x214>
mov    0x10(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x10(%rsp)
cmp    %r15,%rcx
jb     1280 <drawcal+0x150>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%r12d
mov    0x20(%rsp),%rbx
jmp    1378 <drawcal+0x248>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    $0x7,%r12d
je     11a0 <drawcal+0x70>
mov    0x8(%rsp),%r13
cmpb   $0x0,0x3(%rsp)
je     1360 <drawcal+0x230>
xor    %ebp,%ebp
mov    0x8(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %r13,%rax
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mul    %rcx
shr    $0x3,%rdx
mov    0x18(%rsp),%rax
lea    (%rdx,%rax,1),%rdi
shl    $0x2,%rdx
lea    (%rdx,%rdx,2),%rax
mov    %r13,%rcx
sub    %rax,%rcx
lea    (%rcx,%rbx,1),%rax
cmp    $0xc,%rax
sbb    $0xffffffffffffffff,%rdi
cmp    $0xc,%rax
lea    -0xc(%rbx,%rcx,1),%rsi
cmovb  %rax,%rsi
mov    0x4(%rsp),%edx
mov    %r12d,%ecx
call   1050 <printgrid@plt>
lea    0xcb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
cmp    %r14,%r13
jae    1360 <drawcal+0x230>
add    $0x1,%rbp
cmp    %r15,%rbp
jb     1390 <drawcal+0x260>
jmp    1360 <drawcal+0x230>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c" January\00"
@.str.1 = [10 x i8] c" February\00"
@.str.2 = [10 x i8] c" March\00"
@.str.3 = [10 x i8] c" April\00"
@.str.4 = [10 x i8] c" May\00"
@.str.5 = [10 x i8] c" June\00"
@.str.6 = [10 x i8] c" July\00"
@.str.7 = [10 x i8] c" August\00"
@.str.8 = [10 x i8] c"September\00"
@.str.9 = [10 x i8] c" October\00"
@.str.10 = [10 x i8] c" November\00"
@.str.11 = [10 x i8] c" December\00"
@__const.drawcal.smon = [12 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 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 ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [3 x i8] c"Su\00"
@.str.13 = [3 x i8] c"Mo\00"
@.str.14 = [3 x i8] c"Tu\00"
@.str.15 = [3 x i8] c"We\00"
@.str.16 = [3 x i8] c"Th\00"
@.str.17 = [3 x i8] c"Fr\00"
@.str.18 = [3 x i8] c"Sa\00"
@__const.drawcal.days = [7 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i32 0, i32 0)]
@.str.19 = [14 x i8] c" %s %zu \00"
@.str.20 = [3 x i8] c" \00"
@.str.21 = [4 x i8] c"%s \00"
define void @drawcal(i64 %0, i32 %1, i64 %2, i64 %3, i32 %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca [12 x i8*]
%12 = alloca [7 x i8*]
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
store i64 %0, i64* %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i32 %4, i32* %10
%20 = bitcast [12 x i8*]* %11 to i8*
%21 = bitcast [7 x i8*]* %12 to i8*
store i64 0, i64* %13
br label %22
22: ; preds = %156, %5
%23 = load i64, i64* %13
%24 = load i64, i64* %9
%25 = icmp ult i64 %23, %24
br i1 %25, label %26, label %157
26: ; preds = %22
%27 = load i64, i64* %13
store i64 %27, i64* %14
store i64 0, i64* %15
br label %28
28: ; preds = %62, %26
%29 = load i64, i64* %13
%30 = load i64, i64* %9
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i64, i64* %15
%34 = load i64, i64* %8
%35 = icmp ult i64 %33, %34
br label %36
36: ; preds = %32, %28
%37 = phi i1 [ false, %28 ], [ %35, %32 ]
br i1 %37, label %38, label %67
38: ; preds = %36
%39 = load i64, i64* %6
%40 = load i64, i64* %13
%41 = udiv i64 %40, 12
%42 = add i64 %39, %41
store i64 %42, i64* %16
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = load i64, i64* %13
%46 = urem i64 %45, 12
%47 = add i64 %44, %46
store i64 %47, i64* %17
%48 = load i64, i64* %17
%49 = icmp ugt i64 %48, 11
br i1 %49, label %50, label %55
50: ; preds = %38
%51 = load i64, i64* %17
%52 = sub i64 %51, 12
store i64 %52, i64* %17
%53 = load i64, i64* %16
%54 = add i64 %53, 1
store i64 %54, i64* %16
br label %55
55: ; preds = %50, %38
%56 = load i64, i64* %17
%57 = getelementptr inbounds [12 x i8*], [12 x i8*]* %11, i64 0, i64 %56
%58 = load i8*, i8** %57
%59 = load i64, i64* %16
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0), i8* %58, i64 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
br label %62
62: ; preds = %55
%63 = load i64, i64* %15
%64 = add i64 %63, 1
store i64 %64, i64* %15
%65 = load i64, i64* %13
%66 = add i64 %65, 1
store i64 %66, i64* %13
br label %28
67: ; preds = %36
%68 = call i32 @putchar(i8 signext 10)
store i64 0, i64* %15
%69 = load i64, i64* %14
store i64 %69, i64* %13
br label %70
70: ; preds = %100, %67
%71 = load i64, i64* %13
%72 = load i64, i64* %9
%73 = icmp ult i64 %71, %72
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = load i64, i64* %15
%76 = load i64, i64* %8
%77 = icmp ult i64 %75, %76
br label %78
78: ; preds = %74, %70
%79 = phi i1 [ false, %70 ], [ %77, %74 ]
br i1 %79, label %80, label %105
80: ; preds = %78
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
store i64 %82, i64* %18
br label %83
83: ; preds = %95, %80
%84 = load i64, i64* %18
%85 = load i32, i32* %10
%86 = add nsw i32 %85, 7
%87 = sext i32 %86 to i64
%88 = icmp ult i64 %84, %87
br i1 %88, label %89, label %98
89: ; preds = %83
%90 = load i64, i64* %18
%91 = urem i64 %90, 7
%92 = getelementptr inbounds [7 x i8*], [7 x i8*]* %12, i64 0, i64 %91
%93 = load i8*, i8** %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %89
%96 = load i64, i64* %18
%97 = add i64 %96, 1
store i64 %97, i64* %18
br label %83
98: ; preds = %83
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
br label %100
100: ; preds = %98
%101 = load i64, i64* %15
%102 = add i64 %101, 1
store i64 %102, i64* %15
%103 = load i64, i64* %13
%104 = add i64 %103, 1
store i64 %104, i64* %13
br label %70
105: ; preds = %78
%106 = call i32 @putchar(i8 signext 10)
store i32 1, i32* %19
br label %107
107: ; preds = %153, %105
%108 = load i32, i32* %19
%109 = icmp sle i32 %108, 6
br i1 %109, label %110, label %156
110: ; preds = %107
store i64 0, i64* %15
%111 = load i64, i64* %14
store i64 %111, i64* %13
br label %112
112: ; preds = %146, %110
%113 = load i64, i64* %13
%114 = load i64, i64* %9
%115 = icmp ult i64 %113, %114
br i1 %115, label %116, label %120
116: ; preds = %112
%117 = load i64, i64* %15
%118 = load i64, i64* %8
%119 = icmp ult i64 %117, %118
br label %120
120: ; preds = %116, %112
%121 = phi i1 [ false, %112 ], [ %119, %116 ]
br i1 %121, label %122, label %151
122: ; preds = %120
%123 = load i64, i64* %6
%124 = load i64, i64* %13
%125 = udiv i64 %124, 12
%126 = add i64 %123, %125
store i64 %126, i64* %16
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = load i64, i64* %13
%130 = urem i64 %129, 12
%131 = add i64 %128, %130
store i64 %131, i64* %17
%132 = load i64, i64* %17
%133 = icmp ugt i64 %132, 11
br i1 %133, label %134, label %139
134: ; preds = %122
%135 = load i64, i64* %17
%136 = sub i64 %135, 12
store i64 %136, i64* %17
%137 = load i64, i64* %16
%138 = add i64 %137, 1
store i64 %138, i64* %16
br label %139
139: ; preds = %134, %122
%140 = load i64, i64* %16
%141 = load i64, i64* %17
%142 = load i32, i32* %10
%143 = load i32, i32* %19
%144 = call i32 @printgrid(i64 %140, i64 %141, i32 %142, i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
br label %146
146: ; preds = %139
%147 = load i64, i64* %15
%148 = add i64 %147, 1
store i64 %148, i64* %15
%149 = load i64, i64* %13
%150 = add i64 %149, 1
store i64 %150, i64* %13
br label %112
151: ; preds = %120
%152 = call i32 @putchar(i8 signext 10)
br label %153
153: ; preds = %151
%154 = load i32, i32* %19
%155 = add nsw i32 %154, 1
store i32 %155, i32* %19
br label %107
156: ; preds = %107
br label %22
157: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" January\00"
@.str.1 = [10 x i8] c" February\00"
@.str.2 = [10 x i8] c" March\00"
@.str.3 = [10 x i8] c" April\00"
@.str.4 = [10 x i8] c" May\00"
@.str.5 = [10 x i8] c" June\00"
@.str.6 = [10 x i8] c" July\00"
@.str.7 = [10 x i8] c" August\00"
@.str.8 = [10 x i8] c"September\00"
@.str.9 = [10 x i8] c" October\00"
@.str.10 = [10 x i8] c" November\00"
@.str.11 = [10 x i8] c" December\00"
@reltable.drawcal = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.drawcal to i64)) to i32)]
@.str.12 = [3 x i8] c"Su\00"
@.str.13 = [3 x i8] c"Mo\00"
@.str.14 = [3 x i8] c"Tu\00"
@.str.15 = [3 x i8] c"We\00"
@.str.16 = [3 x i8] c"Th\00"
@.str.17 = [3 x i8] c"Fr\00"
@.str.18 = [3 x i8] c"Sa\00"
@reltable.drawcal.22 = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.12 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.13 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.14 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.15 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.16 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.17 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.18 to i64), i64 ptrtoint ([7 x i32]* @reltable.drawcal.22 to i64)) to i32)]
@.str.19 = [14 x i8] c" %s %zu \00"
@.str.20 = [3 x i8] c" \00"
@.str.21 = [4 x i8] c"%s \00"
define void @drawcal(i64 %0, i32 %1, i64 %2, i64 %3, i32 %4) {
%6 = icmp eq i64 %3, 0
br i1 %6, label %90, label %7
7: ; preds = %5
%8 = icmp eq i64 %2, 0
%9 = sext i32 %1 to i64
%10 = icmp ne i64 %2, 0
%11 = sext i32 %4 to i64
%12 = add nsw i32 %4, 7
%13 = sext i32 %12 to i64
%14 = icmp ult i32 %4, -7
br label %17
15: ; preds = %85
%16 = icmp ult i64 %86, %3
br i1 %16, label %17, label %90
17: ; preds = %7, %15
%18 = phi i64 [ 0, %7 ], [ %86, %15 ]
br i1 %8, label %40, label %19
19: ; preds = %17, %19
%20 = phi i64 [ %35, %19 ], [ 0, %17 ]
%21 = phi i64 [ %36, %19 ], [ %18, %17 ]
%22 = udiv i64 %21, 12
%23 = add i64 %22, %0
%24 = urem i64 %21, 12
%25 = add nsw i64 %24, %9
%26 = icmp ugt i64 %25, 11
%27 = add nsw i64 %25, -12
%28 = zext i1 %26 to i64
%29 = add i64 %23, %28
%30 = select i1 %26, i64 %27, i64 %25
%31 = shl i64 %30, 2
%32 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.drawcal to i8*), i64 %31)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0), i8* %32, i64 %29)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%35 = add nuw i64 %20, 1
%36 = add nuw i64 %21, 1
%37 = icmp ult i64 %36, %3
%38 = icmp ult i64 %35, %2
%39 = select i1 %37, i1 %38, i1 false
br i1 %39, label %19, label %40
40: ; preds = %19, %17
%41 = tail call i32 @putchar(i8 signext 10)
%42 = icmp ult i64 %18, %3
%43 = and i1 %42, %10
br i1 %43, label %44, label %62
44: ; preds = %40, %55
%45 = phi i64 [ %57, %55 ], [ 0, %40 ]
%46 = phi i64 [ %58, %55 ], [ %18, %40 ]
br i1 %14, label %47, label %55
47: ; preds = %44, %47
%48 = phi i64 [ %53, %47 ], [ %11, %44 ]
%49 = urem i64 %48, 7
%50 = shl i64 %49, 2
%51 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.drawcal.22 to i8*), i64 %50)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i64 0, i64 0), i8* %51)
%53 = add nuw i64 %48, 1
%54 = icmp ult i64 %53, %13
br i1 %54, label %47, label %55
55: ; preds = %47, %44
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%57 = add nuw i64 %45, 1
%58 = add nuw i64 %46, 1
%59 = icmp ult i64 %58, %3
%60 = icmp ult i64 %57, %2
%61 = select i1 %59, i1 %60, i1 false
br i1 %61, label %44, label %62
62: ; preds = %55, %40
%63 = tail call i32 @putchar(i8 signext 10)
br label %64
64: ; preds = %62, %85
%65 = phi i32 [ 1, %62 ], [ %88, %85 ]
br i1 %43, label %66, label %85
66: ; preds = %64, %66
%67 = phi i64 [ %80, %66 ], [ 0, %64 ]
%68 = phi i64 [ %81, %66 ], [ %18, %64 ]
%69 = udiv i64 %68, 12
%70 = add i64 %69, %0
%71 = urem i64 %68, 12
%72 = add nsw i64 %71, %9
%73 = icmp ugt i64 %72, 11
%74 = add nsw i64 %72, -12
%75 = zext i1 %73 to i64
%76 = add i64 %70, %75
%77 = select i1 %73, i64 %74, i64 %72
%78 = tail call i32 @printgrid(i64 %76, i64 %77, i32 %4, i32 %65)
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%80 = add nuw i64 %67, 1
%81 = add nuw i64 %68, 1
%82 = icmp ult i64 %81, %3
%83 = icmp ult i64 %80, %2
%84 = select i1 %82, i1 %83, i1 false
br i1 %84, label %66, label %85
85: ; preds = %66, %64
%86 = phi i64 [ %18, %64 ], [ %81, %66 ]
%87 = tail call i32 @putchar(i8 signext 10)
%88 = add nuw nsw i32 %65, 1
%89 = icmp eq i32 %88, 7
br i1 %89, label %15, label %64
90: ; preds = %15, %5
ret void
}