#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 EXIT_FAILURE;
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ prt3mon(int, int, char *);
main(int argc, char **argv) {
  int yr, wrkyr, dig1, dig2, dig3, dig4;
  if (argc < 2) {
    printf("Calendar - print a calendar\n");
    printf("Written by Paul Edwards, Sydney, Australia\n");
    printf("You must enter 1 parameter - the 4-digit\n");
    printf("year you want printed\n");
    printf("This program then prints a calendar for that year\n");
    return (EXIT_FAILURE);
  }
  yr = atoi(*(argv + 1));
  wrkyr = yr;
  dig1 = wrkyr / 1000;
  wrkyr %= 1000;
  dig2 = wrkyr / 100;
  wrkyr %= 100;
  dig3 = wrkyr / 10;
  wrkyr %= 10;
  dig4 = wrkyr;
  printf("                                %d %d %d %d\n\n\n\n\n", dig1, dig2,
         dig3, dig4);
  prt3mon(yr, 0,
          "       JANUARY                 FEBRUARY"
          "                   MARCH");
  prt3mon(yr, 1,
          "        APRIL                     MAY"
          "                     JUNE");
  prt3mon(yr, 2,
          "        JULY                    AUGUST"
          "                  SEPTEMBER");
  prt3mon(yr, 3,
          "       OCTOBER                 NOVEMBER"
          "                 DECEMBER");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a7 <main+0x77>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1286 <main+0x156>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
lea    0xeb0(%rip),%rdx
call   1040 <prt3mon@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
lea    0xedc(%rip),%rdx
call   1040 <prt3mon@plt>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
lea    0xf07(%rip),%rdx
call   1040 <prt3mon@plt>
mov    -0x14(%rbp),%edi
mov    $0x3,%esi
lea    0xf35(%rip),%rdx
call   1040 <prt3mon@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1192 <main+0x52>
lea    0xfe4(%rip),%rdi
call   1030 <puts@plt>
lea    0xff4(%rip),%rdi
call   1030 <puts@plt>
lea    0x1013(%rip),%rdi
call   1030 <puts@plt>
lea    0x1030(%rip),%rdi
call   1030 <puts@plt>
lea    0x103a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%ebp
jmp    1255 <main+0x115>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
movslq %eax,%rbx
imul   $0x10624dd3,%rbx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
imul   $0x3e8,%esi,%ecx
mov    %ebx,%eax
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0x147b,%ecx,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0x13,%edx
add    %ecx,%edx
imul   $0x64,%edx,%ecx
sub    %ecx,%eax
movsbl %al,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edi
shr    $0xf,%ecx
shr    $0xa,%edi
add    %cl,%dil
movsbl %dil,%ecx
movzbl %cl,%edi
add    %edi,%edi
lea    (%rdi,%rdi,4),%edi
sub    %dil,%al
movsbl %al,%r8d
lea    0xdfd(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdx
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <prt3mon@plt>
lea    0xe4e(%rip),%rdx
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <prt3mon@plt>
lea    0xe7a(%rip),%rdx
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <prt3mon@plt>
lea    0xea9(%rip),%rdx
mov    %ebx,%edi
mov    $0x3,%esi
call   1050 <prt3mon@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Calendar - print a calendar\0A\00"
@.str.1 = [44 x i8] c"Written by Paul Edwards, Sydney, Australia\0A\00"
@.str.2 = [42 x i8] c"You must enter 1 parameter - the 4-digit\0A\00"
@.str.3 = [23 x i8] c"year you want printed\0A\00"
@.str.4 = [51 x i8] c"This program then prints a calendar for that year\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [49 x i8] c" %d %d %d %d\0A\0A\0A\0A\0A\00"
@.str.6 = [64 x i8] c" JANUARY FEBRUARY MARCH\00"
@.str.7 = [63 x i8] c" APRIL MAY JUNE\00"
@.str.8 = [66 x i8] c" JULY AUGUST SEPTEMBER\00"
@.str.9 = [65 x i8] c" OCTOBER NOVEMBER DECEMBER\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %53
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = sdiv i32 %27, 1000
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = srem i32 %29, 1000
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = sdiv i32 %31, 100
store i32 %32, i32* %9
%33 = load i32, i32* %7
%34 = srem i32 %33, 100
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = sdiv i32 %35, 10
store i32 %36, i32* %10
%37 = load i32, i32* %7
%38 = srem i32 %37, 10
store i32 %38, i32* %7
%39 = load i32, i32* %7
store i32 %39, i32* %11
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43)
%45 = load i32, i32* %6
%46 = call i32 @prt3mon(i32 %45, i32 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
%47 = load i32, i32* %6
%48 = call i32 @prt3mon(i32 %47, i32 1, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0))
%49 = load i32, i32* %6
%50 = call i32 @prt3mon(i32 %49, i32 2, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0))
%51 = load i32, i32* %6
%52 = call i32 @prt3mon(i32 %51, i32 3, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %53
53: ; preds = %21, %14
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.5 = [49 x i8] c" %d %d %d %d\0A\0A\0A\0A\0A\00"
@.str.6 = [64 x i8] c" JANUARY FEBRUARY MARCH\00"
@.str.7 = [63 x i8] c" APRIL MAY JUNE\00"
@.str.8 = [66 x i8] c" JULY AUGUST SEPTEMBER\00"
@.str.9 = [65 x i8] c" OCTOBER NOVEMBER DECEMBER\00"
@str = [28 x i8] c"Calendar - print a calendar\00"
@str.10 = [43 x i8] c"Written by Paul Edwards, Sydney, Australia\00"
@str.11 = [41 x i8] c"You must enter 1 parameter - the 4-digit\00"
@str.12 = [22 x i8] c"year you want printed\00"
@str.13 = [50 x i8] c"This program then prints a calendar for that year\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.13, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
br label %31
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = sdiv i32 %14, 1000
%16 = srem i32 %14, 1000
%17 = trunc i32 %16 to i16
%18 = sdiv i16 %17, 100
%19 = sext i16 %18 to i32
%20 = srem i16 %17, 100
%21 = trunc i16 %20 to i8
%22 = sdiv i8 %21, 10
%23 = sext i8 %22 to i32
%24 = srem i8 %21, 10
%25 = sext i8 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %15, i32 %19, i32 %23, i32 %25)
%27 = tail call i32 @prt3mon(i32 %14, i32 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
%28 = tail call i32 @prt3mon(i32 %14, i32 1, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0))
%29 = tail call i32 @prt3mon(i32 %14, i32 2, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0))
%30 = tail call i32 @prt3mon(i32 %14, i32 3, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0))
br label %31
31: ; preds = %11, %4
%32 = phi i32 [ %10, %4 ], [ 0, %11 ]
ret i32 %32
}