#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ caldat(long, int *, int *, int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
long julday(int, int, int);
int /*<<< orphan*/ nrerror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int main(void) {
  int i, id, idd, im, imm, iy, iyy, n;
  long j;
  char dummy[80];
  static char *name[] = {
      "",     "january", "february",  "march",   "april",    "may",     "june",
      "july", "august",  "september", "october", "november", "december"};
  FILE *fp;
  if ((fp = fopen("dates1.dat", "r")) == NULL)
    nrerror("Data file dates1.dat not found\n");
  fgets(dummy, 80, fp);
  fscanf(fp, "%d %*s ", &n);
  printf("\n %14s %43s\n", "original date:", "reconstructed date");
  printf("%8s %5s %6s %15s %12s %5s %6s\n", "month", "day", "year",
         "julian day", "month", "day", "year");
  for (i = 1; i <= n; i++) {
    fscanf(fp, "%d %d %d ", &im, &id, &iy);
    fgets(dummy, 80, fp);
    j = julday(im, id, iy);
    caldat(j, &imm, &idd, &iyy);
    printf("%10s %3d %6d %13ld %16s %3d %6d\n", name[im], id, iy, j, name[imm],
           idd, iyy);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebd(%rip),%rdi
lea    0xf40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    11c2 <main+0x42>
lea    0xea4(%rip),%rdi
call   1030 <nrerror@plt>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    -0x88(%rbp),%rdi
lea    0xe9c(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
lea    0xe92(%rip),%rdi
lea    0xe98(%rip),%rsi
lea    0xea0(%rip),%rdx
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0xebd(%rip),%r9
lea    0xec8(%rip),%r10
lea    0xeb5(%rip),%rax
lea    0xeb3(%rip),%r8
mov    %r9,%rsi
mov    %r10,%rdx
mov    %rax,%rcx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     130b <main+0x18b>
mov    -0x88(%rbp),%rdi
lea    0xe84(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x1c(%rbp),%r8
mov    $0x0,%al
call   1070 <fscanf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <julday@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   10a0 <caldat@plt>
movslq -0x14(%rbp),%rcx
lea    0x2dad(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    -0xc(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x30(%rbp),%r8
movslq -0x18(%rbp),%rdi
lea    0x2d94(%rip),%rax
mov    (%rax,%rdi,8),%r9
mov    -0x10(%rbp),%r10d
mov    -0x20(%rbp),%eax
lea    0xe09(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124f <main+0xcf>
mov    -0x88(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xec1(%rip),%rdi
lea    0xf44(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11b5 <main+0x35>
lea    0xeb1(%rip),%rdi
call   1030 <nrerror@plt>
lea    0x20(%rsp),%rdi
mov    $0x50,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
lea    0xeb3(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0xea5(%rip),%rdi
lea    0xeab(%rip),%rsi
lea    0xeb3(%rip),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xedd(%rip),%rcx
lea    0xee2(%rip),%rdx
lea    0xeaa(%rip),%rdi
lea    0xecd(%rip),%r8
lea    0xebb(%rip),%rsi
mov    %rsi,%r9
xor    %eax,%eax
push   %rcx
push   %rdx
call   1060 <printf@plt>
add    $0x10,%rsp
cmpl   $0x0,0x4(%rsp)
jle    12f3 <main+0x173>
lea    0x2b72(%rip),%r14
lea    0xeb2(%rip),%r13
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
lea    0xe93(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0x20(%rsp),%rdi
mov    $0x50,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0x8(%rsp),%edx
call   1050 <julday@plt>
mov    %rax,%rbp
mov    %rax,%rdi
lea    0x18(%rsp),%rsi
lea    0x1c(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   10a0 <caldat@plt>
movslq 0xc(%rsp),%rax
mov    (%r14,%rax,8),%rsi
mov    0x10(%rsp),%edx
mov    0x8(%rsp),%ecx
movslq 0x18(%rsp),%rax
mov    (%r14,%rax,8),%r9
mov    0x1c(%rsp),%r10d
mov    0x14(%rsp),%ebx
mov    %r13,%rdi
mov    %rbp,%r8
xor    %eax,%eax
push   %rbx
push   %r10
call   1060 <printf@plt>
add    $0x10,%rsp
add    $0x1,%r15d
cmp    0x4(%rsp),%r15d
jl     1250 <main+0xd0>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.name = internal global [13 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 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)]
@.str = [1 x i8] zeroinitializer
@.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"
@.str.13 = [11 x i8] c"dates1.dat\00"
@.str.14 = [2 x i8] c"r\00"
@.str.15 = [32 x i8] c"Data file dates1.dat not found\0A\00"
@.str.16 = [8 x i8] c"%d %*s \00"
@.str.17 = [13 x i8] c"\0A %14s %43s\0A\00"
@.str.18 = [15 x i8] c"original date:\00"
@.str.19 = [19 x i8] c"reconstructed date\00"
@.str.20 = [31 x i8] c"%8s %5s %6s %15s %12s %5s %6s\0A\00"
@.str.21 = [6 x i8] c"month\00"
@.str.22 = [4 x i8] c"day\00"
@.str.23 = [5 x i8] c"year\00"
@.str.24 = [11 x i8] c"julian day\00"
@.str.25 = [10 x i8] c"%d %d %d \00"
@.str.26 = [33 x i8] c"%10s %3d %6d %13ld %16s %3d %6d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca [80 x i8]
%12 = alloca i32*
store i32 0, i32* %1
%13 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %13, i32** %12
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0))
br label %17
17: ; preds = %15, %0
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%19 = load i32*, i32** %12
%20 = call i32 @fgets(i8* %18, i32 80, i32* %19)
%21 = load i32*, i32** %12
%22 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i32* %9)
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0))
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0))
store i32 1, i32* %2
br label %25
25: ; preds = %55, %17
%26 = load i32, i32* %2
%27 = load i32, i32* %9
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %58
29: ; preds = %25
%30 = load i32*, i32** %12
%31 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.25, i64 0, i64 0), i32* %5, i32* %3, i32* %7)
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%33 = load i32*, i32** %12
%34 = call i32 @fgets(i8* %32, i32 80, i32* %33)
%35 = load i32, i32* %5
%36 = load i32, i32* %3
%37 = load i32, i32* %7
%38 = call i64 @julday(i32 %35, i32 %36, i32 %37)
store i64 %38, i64* %10
%39 = load i64, i64* %10
%40 = call i32 @caldat(i64 %39, i32* %6, i32* %4, i32* %8)
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [13 x i8*], [13 x i8*]* @main.name, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = load i32, i32* %3
%46 = load i32, i32* %7
%47 = load i64, i64* %10
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [13 x i8*], [13 x i8*]* @main.name, i64 0, i64 %49
%51 = load i8*, i8** %50
%52 = load i32, i32* %4
%53 = load i32, i32* %8
%54 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.26, i64 0, i64 0), i8* %44, i32 %45, i32 %46, i64 %47, i8* %51, i32 %52, i32 %53)
br label %55
55: ; preds = %29
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
br label %25
58: ; preds = %25
%59 = load i32*, i32** %12
%60 = call i32 @fclose(i32* %59)
ret i32 0
}

LLVM IR (-O2):
@main.name = internal unnamed_addr constant [13 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 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)]
@.str = [1 x i8] zeroinitializer
@.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"
@.str.13 = [11 x i8] c"dates1.dat\00"
@.str.14 = [2 x i8] c"r\00"
@.str.15 = [32 x i8] c"Data file dates1.dat not found\0A\00"
@.str.16 = [8 x i8] c"%d %*s \00"
@.str.17 = [13 x i8] c"\0A %14s %43s\0A\00"
@.str.18 = [15 x i8] c"original date:\00"
@.str.19 = [19 x i8] c"reconstructed date\00"
@.str.20 = [31 x i8] c"%8s %5s %6s %15s %12s %5s %6s\0A\00"
@.str.21 = [6 x i8] c"month\00"
@.str.22 = [4 x i8] c"day\00"
@.str.23 = [5 x i8] c"year\00"
@.str.24 = [11 x i8] c"julian day\00"
@.str.25 = [10 x i8] c"%d %d %d \00"
@.str.26 = [33 x i8] c"%10s %3d %6d %13ld %16s %3d %6d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [80 x i8]
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%17 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = tail call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0))
br label %21
21: ; preds = %19, %0
%22 = call i32 @fgets(i8* %16, i32 80, i32* %17)
%23 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i32* %7)
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0))
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0))
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 1
br i1 %27, label %53, label %28
28: ; preds = %21, %28
%29 = phi i32 [ %50, %28 ], [ 1, %21 ]
%30 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.25, i64 0, i64 0), i32* %3, i32* %1, i32* %5)
%31 = call i32 @fgets(i8* %16, i32 80, i32* %17)
%32 = load i32, i32* %3
%33 = load i32, i32* %1
%34 = load i32, i32* %5
%35 = call i64 @julday(i32 %32, i32 %33, i32 %34)
%36 = call i32 @caldat(i64 %35, i32* %4, i32* %2, i32* %6)
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [13 x i8*], [13 x i8*]* @main.name, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* %1
%42 = load i32, i32* %5
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [13 x i8*], [13 x i8*]* @main.name, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = load i32, i32* %2
%48 = load i32, i32* %6
%49 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.26, i64 0, i64 0), i8* %40, i32 %41, i32 %42, i64 %35, i8* %46, i32 %47, i32 %48)
%50 = add nuw nsw i32 %29, 1
%51 = load i32, i32* %7
%52 = icmp slt i32 %29, %51
br i1 %52, label %28, label %53
53: ; preds = %28, %21
%54 = call i32 @fclose(i32* %17)
ret i32 0
}