#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*/ buf2;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ is_leap(int);
double readstat_sav_date_parse(char *, char **);
char *readstat_sav_date_string(double, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int daysPerMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int daysPerMonthLeap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  {
    char *dest;
    char s[] = "1582-10-14";
    double v = readstat_sav_date_parse(s, &dest);
    if (s == dest) {
      fprintf(stderr, "parse error\n");
      exit(EXIT_FAILURE);
    }
    if (v != 0) {
      fprintf(stderr, "expected value zero, was %lf\n", v);
      exit(EXIT_FAILURE);
    }
  }
  {
    char *dest;
    char s[] = "1582-10-15";
    double v = readstat_sav_date_parse(s, &dest);
    if (s == dest) {
      fprintf(stderr, "parse error\n");
      exit(EXIT_FAILURE);
    }
    if (v != 86400) {
      fprintf(stderr, "expected value 86400, was %lf\n", v);
      exit(EXIT_FAILURE);
    }
  }
  double expected = 0;
  char *dest;
  char buf[1024];
  char buf2[1024];
  int count = 0;
  for (int year = 1582; year < 2050; year++) {
    int start_month = year == 1582 ? (10 - 1) : 0;
    for (int month = start_month; month < 12; month++) {
      int start_day = (year == 1582 && month == 10 - 1) ? 14 : 1;
      int max_days =
          is_leap(year) ? daysPerMonthLeap[month] : daysPerMonth[month];
      for (int day = start_day; day <= max_days; day++) {
        snprintf(buf, sizeof(buf), "%04d-%02d-%02d", year, month + 1, day);
        double v = readstat_sav_date_parse(buf, &dest);
        if (buf == dest) {
          fprintf(stderr, "parse error\n");
          exit(EXIT_FAILURE);
        }
        if (v != expected) {
          fprintf(stderr, "got %lf but expected %lf for date %s\n", v, expected,
                  buf);
          exit(EXIT_FAILURE);
        }
        char *s = readstat_sav_date_string(v, buf2, sizeof(buf2) - 1);
        if (!s) {
          fprintf(stderr,
                  "could not make string of spss double date %lf, expected "
                  "date was %s\n",
                  v, buf);
          exit(EXIT_FAILURE);
        }
        if (0 != strcmp(buf2, buf)) {
          fprintf(stderr, "Expected %s, got %s\n", buf, s);
          exit(EXIT_FAILURE);
        }
        if ((++count % 1000) == 0) {
          fprintf(stdout, "verified date %s => %lf => %s OK\n", buf, v, buf2);
        }
        expected += 86400.0;
      }
    }
  }
  char *s = readstat_sav_date_string(1.0, buf2, sizeof(buf2) - 1);
  if (s != NULL) {
    fprintf(stderr, "expected parse failure!\n");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x900,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x30,%edx
call   1080 <memcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xe87(%rip),%rsi
mov    $0x30,%edx
call   1080 <memcpy@plt>
mov    0xea6(%rip),%rax
mov    %rax,-0x83(%rbp)
mov    0xea0(%rip),%ax
mov    %ax,-0x7b(%rbp)
mov    0xe98(%rip),%al
mov    %al,-0x79(%rbp)
lea    -0x83(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1030 <readstat_sav_date_parse@plt>
movsd  %xmm0,-0x90(%rbp)
ff
lea    -0x83(%rbp),%rax
cmp    -0x78(%rbp),%rax
jne    1233 <main+0xb3>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  -0x90(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1253 <main+0xd3>
jp     1253 <main+0xd3>
jmp    1280 <main+0x100>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
movsd  -0x90(%rbp),%xmm0
ff
lea    0xe1d(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0xe1f(%rip),%rax
mov    %rax,-0xa3(%rbp)
mov    0xe19(%rip),%ax
mov    %ax,-0x9b(%rbp)
mov    0xe0e(%rip),%al
mov    %al,-0x99(%rbp)
lea    -0xa3(%rbp),%rdi
lea    -0x98(%rbp),%rsi
call   1030 <readstat_sav_date_parse@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
lea    -0xa3(%rbp),%rax
cmp    -0x98(%rbp),%rax
jne    12fc <main+0x17c>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  -0xb0(%rbp),%xmm0
ff
movsd  0xcf4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1321 <main+0x1a1>
jp     1321 <main+0x1a1>
jmp    134e <main+0x1ce>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
movsd  -0xb0(%rbp),%xmm0
ff
lea    0xd78(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movl   $0x0,-0x8c4(%rbp)
movl   $0x62e,-0x8c8(%rbp)
cmpl   $0x802,-0x8c8(%rbp)
jge    169e <main+0x51e>
mov    -0x8c8(%rbp),%edx
xor    %eax,%eax
mov    $0x9,%ecx
cmp    $0x62e,%edx
cmove  %ecx,%eax
mov    %eax,-0x8cc(%rbp)
mov    -0x8cc(%rbp),%eax
mov    %eax,-0x8d0(%rbp)
cmpl   $0xc,-0x8d0(%rbp)
jge    1685 <main+0x505>
xor    %eax,%eax
cmpl   $0x62e,-0x8c8(%rbp)
mov    %al,-0x8f9(%rbp)
jne    13da <main+0x25a>
cmpl   $0x9,-0x8d0(%rbp)
sete   %al
mov    %al,-0x8f9(%rbp)
mov    -0x8f9(%rbp),%dl
mov    $0x1,%eax
mov    $0xe,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x8d4(%rbp)
mov    -0x8c8(%rbp),%edi
call   1050 <is_leap@plt>
cmp    $0x0,%rax
je     1421 <main+0x2a1>
movslq -0x8d0(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%eax
mov    %eax,-0x900(%rbp)
jmp    1432 <main+0x2b2>
movslq -0x8d0(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x900(%rbp)
mov    -0x900(%rbp),%eax
mov    %eax,-0x8d8(%rbp)
mov    -0x8d4(%rbp),%eax
mov    %eax,-0x8dc(%rbp)
mov    -0x8dc(%rbp),%eax
cmp    -0x8d8(%rbp),%eax
jg     166c <main+0x4ec>
lea    -0x4c0(%rbp),%rdi
mov    -0x8c8(%rbp),%ecx
mov    -0x8d0(%rbp),%r8d
add    $0x1,%r8d
mov    -0x8dc(%rbp),%r9d
mov    $0x400,%esi
lea    0xc49(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x4c0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1030 <readstat_sav_date_parse@plt>
movsd  %xmm0,-0x8e8(%rbp)
ff
lea    -0x4c0(%rbp),%rax
cmp    -0xc0(%rbp),%rax
jne    14e0 <main+0x360>
mov    0x2b1e(%rip),%rax
mov    (%rax),%edi
lea    0xbb0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  -0x8e8(%rbp),%xmm0
ff
ucomisd -0xb8(%rbp),%xmm0
ff
jne    1501 <main+0x381>
jp     1501 <main+0x381>
jmp    153d <main+0x3bd>
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
movsd  -0x8e8(%rbp),%xmm0
ff
movsd  -0xb8(%rbp),%xmm1
ff
lea    -0x4c0(%rbp),%rdx
lea    0xbb7(%rip),%rsi
mov    $0x2,%al
call   1070 <fprintf@plt>
mov    0x2aa2(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  -0x8e8(%rbp),%xmm0
ff
lea    -0x8c0(%rbp),%rdi
mov    $0x3ff,%esi
call   1090 <readstat_sav_date_string@plt>
mov    %rax,-0x8f0(%rbp)
cmpq   $0x0,-0x8f0(%rbp)
jne    159f <main+0x41f>
mov    0x2a6e(%rip),%rax
mov    (%rax),%edi
movsd  -0x8e8(%rbp),%xmm0
ff
lea    -0x4c0(%rbp),%rdx
lea    0xb7b(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    0x2a40(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x8c0(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     15f3 <main+0x473>
mov    0x2a19(%rip),%rax
mov    (%rax),%edi
lea    -0x4c0(%rbp),%rdx
mov    -0x8f0(%rbp),%rcx
lea    0xb6c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x29ec(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c4(%rbp)
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1640 <main+0x4c0>
mov    0x29b6(%rip),%rax
mov    (%rax),%edi
lea    -0x4c0(%rbp),%rdx
movsd  -0x8e8(%rbp),%xmm0
ff
lea    -0x8c0(%rbp),%rcx
lea    0xb26(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
movsd  0x9b8(%rip),%xmm0
addsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x8dc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8dc(%rbp)
jmp    144a <main+0x2ca>
jmp    1671 <main+0x4f1>
mov    -0x8d0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8d0(%rbp)
jmp    13a5 <main+0x225>
jmp    168a <main+0x50a>
mov    -0x8c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c8(%rbp)
jmp    136d <main+0x1ed>
lea    -0x8c0(%rbp),%rdi
movsd  0x95b(%rip),%xmm0
mov    $0x3ff,%esi
call   1090 <readstat_sav_date_string@plt>
mov    %rax,-0x8f8(%rbp)
cmpq   $0x0,-0x8f8(%rbp)
je     16f1 <main+0x571>
mov    0x290d(%rip),%rax
mov    (%rax),%edi
lea    0xaa5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x28ee(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
xor    %eax,%eax
add    $0x900,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
movabs $0x2d30312d32383531,%rbp
31 30 2d
mov    %rbp,0x30(%rsp)
movl   $0x34312d,0x37(%rsp)
lea    0x30(%rsp),%rbx
lea    0x430(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <readstat_sav_date_parse@plt>
cmp    0x430(%rsp),%rbx
je     1417 <main+0x2a7>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14a5 <main+0x335>
jp     14a5 <main+0x335>
mov    %rbp,0x30(%rsp)
movl   $0x35312d,0x37(%rsp)
lea    0x430(%rsp),%rsi
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <readstat_sav_date_parse@plt>
cmp    0x430(%rsp),%rbx
je     1417 <main+0x2a7>
ucomisd 0xdf9(%rip),%xmm0
jne    14b7 <main+0x347>
jp     14b7 <main+0x347>
mov    $0x62e,%r13d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xe,%ebp
lea    0x430(%rsp),%r15
jmp    1251 <main+0xe1>
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    $0x802,%r13d
je     13e0 <main+0x270>
xor    %eax,%eax
cmp    $0x62e,%r13d
sete   %al
lea    (%rax,%rax,8),%rbx
jmp    1280 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xe,%ebp
mov    0x18(%rsp),%rbx
cmp    $0xc,%rbx
je     1240 <main+0xd0>
cmp    $0x9,%rbx
mov    $0x1,%r14d
cmove  %ebp,%r14d
cmp    $0x62e,%r13d
mov    $0x1,%eax
cmovne %eax,%r14d
mov    %r13d,%edi
call   1050 <is_leap@plt>
test   %rax,%rax
lea    0xd90(%rip),%rax
lea    0xd59(%rip),%rcx
cmove  %rcx,%rax
mov    (%rax,%rbx,4),%r12d
add    $0x1,%rbx
cmp    %r12d,%r14d
jg     127a <main+0x10a>
mov    %rbx,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    %eax,%ebp
add    $0x1,%ebp
add    %r12d,%eax
add    $0x1,%eax
sub    %r14d,%eax
mov    %rax,0x10(%rsp)
add    $0x1,%r12d
jmp    1317 <main+0x1a7>
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
addsd  0xd02(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%r14d
add    $0x1,%ebp
cmp    %r14d,%r12d
mov    %ebx,%r13d
je     1270 <main+0x100>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xda5(%rip),%rdx
mov    %r13d,%ecx
mov    0x18(%rsp),%r8
mov    %r14d,%r9d
call   1040 <snprintf@plt>
mov    %rbx,%rdi
lea    0x28(%rsp),%rsi
call   1030 <readstat_sav_date_parse@plt>
cmp    0x28(%rsp),%rbx
je     1417 <main+0x2a7>
ucomisd 0x8(%rsp),%xmm0
jne    1430 <main+0x2c0>
jp     1430 <main+0x2c0>
mov    %r13d,%ebx
movsd  %xmm0,0x20(%rsp)
mov    %r15,%rdi
mov    $0x3ff,%esi
call   1080 <readstat_sav_date_string@plt>
test   %rax,%rax
je     1454 <main+0x2e4>
mov    %r15,%rdi
mov    %rax,%r13
lea    0x30(%rsp),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1478 <main+0x308>
imul   $0x26e978d5,%ebp,%eax
add    $0x10624d8,%eax
ror    $0x3,%eax
cmp    $0x418936,%eax
ja     12f0 <main+0x180>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
lea    0x30(%rsp),%rdx
movsd  0x20(%rsp),%xmm0
mov    %r15,%rcx
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    12f0 <main+0x180>
movsd  0xc20(%rip),%xmm0
lea    0x430(%rsp),%rdi
mov    $0x3ff,%esi
call   1080 <readstat_sav_date_string@plt>
test   %rax,%rax
jne    14d0 <main+0x360>
xor    %eax,%eax
add    $0x838,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
lea    0xc54(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1497 <main+0x327>
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
lea    0xc9f(%rip),%rsi
lea    0x30(%rsp),%rdx
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1070 <fprintf@plt>
jmp    1497 <main+0x327>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
lea    0xca1(%rip),%rsi
lea    0x30(%rsp),%rdx
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    1497 <main+0x327>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
lea    0x30(%rsp),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2b34(%rip),%rax
mov    (%rax),%edi
lea    0xbd3(%rip),%rsi
jmp    14c7 <main+0x357>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
lea    0xbea(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    1497 <main+0x327>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xca1(%rip),%rsi
jmp    1427 <main+0x2b7>

LLVM IR (-O0):
@__const.main.daysPerMonth = [12 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@__const.main.daysPerMonthLeap = [12 x i32] [i32 31, i32 29, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@__const.main.s = [11 x i8] c"1582-10-14\00"
@stderr = global i32 0
@.str = [13 x i8] c"parse error\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"expected value zero, was %lf\0A\00"
@__const.main.s.2 = [11 x i8] c"1582-10-15\00"
@.str.3 = [31 x i8] c"expected value 86400, was %lf\0A\00"
@.str.4 = [15 x i8] c"%04d-%02d-%02d\00"
@.str.5 = [38 x i8] c"got %lf but expected %lf for date %s\0A\00"
@.str.6 = [69 x i8] c"could not make string of spss double date %lf, expected date was %s\0A\00"
@.str.7 = [21 x i8] c"Expected %s, got %s\0A\00"
@stdout = global i32 0
@.str.8 = [34 x i8] c"verified date %s => %lf => %s OK\0A\00"
@.str.9 = [25 x i8] c"expected parse failure!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [12 x i32]
%7 = alloca [12 x i32]
%8 = alloca i8*
%9 = alloca [11 x i8]
%10 = alloca double
%11 = alloca i8*
%12 = alloca [11 x i8]
%13 = alloca double
%14 = alloca double
%15 = alloca i8*
%16 = alloca [1024 x i8]
%17 = alloca [1024 x i8]
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca double
%26 = alloca i8*
%27 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%28 = bitcast [12 x i32]* %6 to i8*
%29 = bitcast [12 x i32]* %7 to i8*
%30 = bitcast [11 x i8]* %9 to i8*
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%32 = call double @readstat_sav_date_parse(i8* %31, i8** %8)
store double %32, double* %10
%33 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%34 = load i8*, i8** %8
%35 = icmp eq i8* %33, %34
br i1 %35, label %36, label %41
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %2
%42 = load double, double* %10
%43 = fcmp une double %42, 0.000000e+00
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = load double, double* %10
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %41
%51 = bitcast [11 x i8]* %12 to i8*
%52 = getelementptr inbounds [11 x i8], [11 x i8]* %12, i64 0, i64 0
%53 = call double @readstat_sav_date_parse(i8* %52, i8** %11)
store double %53, double* %13
%54 = getelementptr inbounds [11 x i8], [11 x i8]* %12, i64 0, i64 0
%55 = load i8*, i8** %11
%56 = icmp eq i8* %54, %55
br i1 %56, label %57, label %62
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %50
%63 = load double, double* %13
%64 = fcmp une double %63, 8.640000e+04
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load i32, i32* @stderr
%67 = load double, double* %13
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %67)
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %62
store double 0.000000e+00, double* %14
store i32 0, i32* %18
store i32 1582, i32* %19
br label %72
72: ; preds = %190, %71
%73 = load i32, i32* %19
%74 = icmp slt i32 %73, 2050
br i1 %74, label %75, label %193
75: ; preds = %72
%76 = load i32, i32* %19
%77 = icmp eq i32 %76, 1582
%78 = zext i1 %77 to i64
%79 = select i1 %77, i32 9, i32 0
store i32 %79, i32* %20
%80 = load i32, i32* %20
store i32 %80, i32* %21
br label %81
81: ; preds = %186, %75
%82 = load i32, i32* %21
%83 = icmp slt i32 %82, 12
br i1 %83, label %84, label %189
84: ; preds = %81
%85 = load i32, i32* %19
%86 = icmp eq i32 %85, 1582
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = load i32, i32* %21
%89 = icmp eq i32 %88, 9
br label %90
90: ; preds = %87, %84
%91 = phi i1 [ false, %84 ], [ %89, %87 ]
%92 = zext i1 %91 to i64
%93 = select i1 %91, i32 14, i32 1
store i32 %93, i32* %22
%94 = load i32, i32* %19
%95 = call i64 @is_leap(i32 %94)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %102
97: ; preds = %90
%98 = load i32, i32* %21
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [12 x i32], [12 x i32]* %7, i64 0, i64 %99
%101 = load i32, i32* %100
br label %107
102: ; preds = %90
%103 = load i32, i32* %21
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %104
%106 = load i32, i32* %105
br label %107
107: ; preds = %102, %97
%108 = phi i32 [ %101, %97 ], [ %106, %102 ]
store i32 %108, i32* %23
%109 = load i32, i32* %22
store i32 %109, i32* %24
br label %110
110: ; preds = %182, %107
%111 = load i32, i32* %24
%112 = load i32, i32* %23
%113 = icmp sle i32 %111, %112
br i1 %113, label %114, label %185
114: ; preds = %110
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%116 = load i32, i32* %19
%117 = load i32, i32* %21
%118 = add nsw i32 %117, 1
%119 = load i32, i32* %24
%120 = call i32 @snprintf(i8* %115, i32 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %116, i32 %118, i32 %119)
%121 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%122 = call double @readstat_sav_date_parse(i8* %121, i8** %15)
store double %122, double* %25
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%124 = load i8*, i8** %15
%125 = icmp eq i8* %123, %124
br i1 %125, label %126, label %131
126: ; preds = %114
%127 = load i32, i32* @stderr
%128 = call i32 (i32, i8*, ...) @fprintf(i32 %127, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%129 = load i32, i32* @EXIT_FAILURE
%130 = call i32 @exit(i32 %129)
unreachable
131: ; preds = %114
%132 = load double, double* %25
%133 = load double, double* %14
%134 = fcmp une double %132, %133
br i1 %134, label %135, label %143
135: ; preds = %131
%136 = load i32, i32* @stderr
%137 = load double, double* %25
%138 = load double, double* %14
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), double %137, double %138, i8* %139)
%141 = load i32, i32* @EXIT_FAILURE
%142 = call i32 @exit(i32 %141)
unreachable
143: ; preds = %131
%144 = load double, double* %25
%145 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%146 = call i8* @readstat_sav_date_string(double %144, i8* %145, i32 1023)
store i8* %146, i8** %26
%147 = load i8*, i8** %26
%148 = icmp ne i8* %147, null
br i1 %148, label %156, label %149
149: ; preds = %143
%150 = load i32, i32* @stderr
%151 = load double, double* %25
%152 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0), double %151, i8* %152)
%154 = load i32, i32* @EXIT_FAILURE
%155 = call i32 @exit(i32 %154)
unreachable
156: ; preds = %143
%157 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%158 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%159 = call i64 @strcmp(i8* %157, i8* %158)
%160 = icmp ne i64 0, %159
br i1 %160, label %161, label %168
161: ; preds = %156
%162 = load i32, i32* @stderr
%163 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%164 = load i8*, i8** %26
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %163, i8* %164)
%166 = load i32, i32* @EXIT_FAILURE
%167 = call i32 @exit(i32 %166)
unreachable
168: ; preds = %156
%169 = load i32, i32* %18
%170 = add nsw i32 %169, 1
store i32 %170, i32* %18
%171 = srem i32 %170, 1000
%172 = icmp eq i32 %171, 0
br i1 %172, label %173, label %179
173: ; preds = %168
%174 = load i32, i32* @stdout
%175 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%176 = load double, double* %25
%177 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i8* %175, double %176, i8* %177)
br label %179
179: ; preds = %173, %168
%180 = load double, double* %14
%181 = fadd double %180, 8.640000e+04
store double %181, double* %14
br label %182
182: ; preds = %179
%183 = load i32, i32* %24
%184 = add nsw i32 %183, 1
store i32 %184, i32* %24
br label %110
185: ; preds = %110
br label %186
186: ; preds = %185
%187 = load i32, i32* %21
%188 = add nsw i32 %187, 1
store i32 %188, i32* %21
br label %81
189: ; preds = %81
br label %190
190: ; preds = %189
%191 = load i32, i32* %19
%192 = add nsw i32 %191, 1
store i32 %192, i32* %19
br label %72
193: ; preds = %72
%194 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%195 = call i8* @readstat_sav_date_string(double 1.000000e+00, i8* %194, i32 1023)
store i8* %195, i8** %27
%196 = load i8*, i8** %27
%197 = icmp ne i8* %196, null
br i1 %197, label %198, label %203
198: ; preds = %193
%199 = load i32, i32* @stderr
%200 = call i32 (i32, i8*, ...) @fprintf(i32 %199, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%201 = load i32, i32* @EXIT_FAILURE
%202 = call i32 @exit(i32 %201)
unreachable
203: ; preds = %193
ret i32 0
}

LLVM IR (-O2):
@__const.main.daysPerMonth = [12 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@__const.main.daysPerMonthLeap = [12 x i32] [i32 31, i32 29, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@__const.main.s = [11 x i8] c"1582-10-14\00"
@stderr = global i32 0
@.str = [13 x i8] c"parse error\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"expected value zero, was %lf\0A\00"
@__const.main.s.2 = [11 x i8] c"1582-10-15\00"
@.str.3 = [31 x i8] c"expected value 86400, was %lf\0A\00"
@.str.4 = [15 x i8] c"%04d-%02d-%02d\00"
@.str.5 = [38 x i8] c"got %lf but expected %lf for date %s\0A\00"
@.str.6 = [69 x i8] c"could not make string of spss double date %lf, expected date was %s\0A\00"
@.str.7 = [21 x i8] c"Expected %s, got %s\0A\00"
@stdout = global i32 0
@.str.8 = [34 x i8] c"verified date %s => %lf => %s OK\0A\00"
@.str.9 = [25 x i8] c"expected parse failure!\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca [11 x i8]
%5 = alloca i8*
%6 = alloca [11 x i8]
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = bitcast i8** %3 to i8*
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%12 = call double @readstat_sav_date_parse(i8* %11, i8** %3)
%13 = load i8*, i8** %3
%14 = icmp eq i8* %11, %13
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = fcmp une double %12, 0.000000e+00
br i1 %21, label %22, label %27
22: ; preds = %20
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %12)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %20
%28 = bitcast i8** %5 to i8*
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%30 = call double @readstat_sav_date_parse(i8* %29, i8** %5)
%31 = load i8*, i8** %5
%32 = icmp eq i8* %29, %31
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %27
%39 = fcmp une double %30, 8.640000e+04
br i1 %39, label %40, label %45
40: ; preds = %38
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %30)
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %38
%46 = bitcast i8** %7 to i8*
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
br label %52
49: ; preds = %58
%50 = call i8* @readstat_sav_date_string(double 1.000000e+00, i8* %48, i32 1023)
%51 = icmp eq i8* %50, null
br i1 %51, label %137, label %132
52: ; preds = %45, %58
%53 = phi double [ 0.000000e+00, %45 ], [ %83, %58 ]
%54 = phi i32 [ 0, %45 ], [ %82, %58 ]
%55 = phi i32 [ 1582, %45 ], [ %59, %58 ]
%56 = icmp eq i32 %55, 1582
%57 = select i1 %56, i64 9, i64 0
br label %61
58: ; preds = %81
%59 = add nuw nsw i32 %55, 1
%60 = icmp eq i32 %59, 2050
br i1 %60, label %49, label %52
61: ; preds = %52, %81
%62 = phi i64 [ %57, %52 ], [ %75, %81 ]
%63 = phi double [ %53, %52 ], [ %83, %81 ]
%64 = phi i32 [ %54, %52 ], [ %82, %81 ]
%65 = icmp eq i64 %62, 9
%66 = select i1 %56, i1 %65, i1 false
%67 = select i1 %66, i32 14, i32 1
%68 = call i64 @is_leap(i32 %55)
%69 = icmp eq i64 %68, 0
%70 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.main.daysPerMonthLeap, i64 0, i64 %62
%71 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.main.daysPerMonth, i64 0, i64 %62
%72 = select i1 %69, i32* %71, i32* %70
%73 = load i32, i32* %72
%74 = icmp sgt i32 %67, %73
%75 = add nuw nsw i64 %62, 1
br i1 %74, label %81, label %76
76: ; preds = %61
%77 = add i32 %64, 1
%78 = add i32 %77, %73
%79 = sub i32 %78, %67
%80 = trunc i64 %75 to i32
br label %85
81: ; preds = %128, %61
%82 = phi i32 [ %64, %61 ], [ %79, %128 ]
%83 = phi double [ %63, %61 ], [ %129, %128 ]
%84 = icmp eq i64 %75, 12
br i1 %84, label %58, label %61
85: ; preds = %76, %128
%86 = phi double [ %63, %76 ], [ %129, %128 ]
%87 = phi i32 [ %64, %76 ], [ %122, %128 ]
%88 = phi i32 [ %67, %76 ], [ %130, %128 ]
%89 = call i32 @snprintf(i8* %47, i32 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %55, i32 %80, i32 %88)
%90 = call double @readstat_sav_date_parse(i8* %47, i8** %7)
%91 = load i8*, i8** %7
%92 = icmp eq i8* %47, %91
br i1 %92, label %93, label %98
93: ; preds = %85
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %85
%99 = fcmp une double %90, %86
br i1 %99, label %100, label %105
100: ; preds = %98
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), double %90, double %86, i8* %47)
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @exit(i32 %103)
unreachable
105: ; preds = %98
%106 = call i8* @readstat_sav_date_string(double %90, i8* %48, i32 1023)
%107 = icmp eq i8* %106, null
br i1 %107, label %108, label %113
108: ; preds = %105
%109 = load i32, i32* @stderr
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0), double %90, i8* %47)
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %105
%114 = call i64 @strcmp(i8* %48, i8* %47)
%115 = icmp eq i64 %114, 0
br i1 %115, label %121, label %116
116: ; preds = %113
%117 = load i32, i32* @stderr
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %47, i8* %106)
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %113
%122 = add nsw i32 %87, 1
%123 = srem i32 %122, 1000
%124 = icmp eq i32 %123, 0
br i1 %124, label %125, label %128
125: ; preds = %121
%126 = load i32, i32* @stdout
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i8* %47, double %90, i8* %48)
br label %128
128: ; preds = %125, %121
%129 = fadd double %86, 8.640000e+04
%130 = add nuw i32 %88, 1
%131 = icmp eq i32 %88, %73
br i1 %131, label %81, label %85
132: ; preds = %49
%133 = load i32, i32* @stderr
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%135 = load i32, i32* @EXIT_FAILURE
%136 = call i32 @exit(i32 %135)
unreachable
137: ; preds = %49
ret i32 0
}