#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);
int /*<<< orphan*/ readstat_dta_days_string(int, char *, int);
int readstat_dta_num_days(char *, char **);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
void test_dta_dates() {
  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 buf[1024];
  char buf2[1024];
  for (int yr = 1600; yr < 2050; yr++) {
    for (int month = 0; month < 12; month++) {
      int max_days =
          is_leap(yr) ? daysPerMonthLeap[month] : daysPerMonth[month];
      for (int days = 1; days <= max_days; days++) {
        snprintf(buf, sizeof(buf), "%04d-%02d-%02d", yr, month + 1, days);
        char *dest;
        int numdays = readstat_dta_num_days(buf, &dest);
        if (dest == buf) {
          fprintf(stderr, "failure to parse date\n");
          exit(EXIT_FAILURE);
        }
        readstat_dta_days_string(numdays, buf2, sizeof(buf2) - 1);
        if (0 != strncmp(buf, buf2, strlen(buf))) {
          fprintf(stderr, "failure. Expected %s, got %s\n", buf, buf2);
          exit(EXIT_FAILURE);
        }
      }
    }
  }
  {
    char *dest;
    char b[] = "2016-00-01";
    readstat_dta_num_days(b, &dest);
    if (dest != b) {
      fprintf(stderr, "Expected failure!\n");
      exit(EXIT_FAILURE);
    }
  }
  {
    char *dest;
    char b[] = "";
    readstat_dta_num_days(b, &dest);
    if (dest != b) {
      fprintf(stderr, "Expected failure!\n");
      exit(EXIT_FAILURE);
    }
  }
  {
    char *dest;
    char b[] = "2016-13-01";
    readstat_dta_num_days(b, &dest);
    if (dest != b) {
      fprintf(stderr, "Expected failure!\n");
      exit(EXIT_FAILURE);
    }
  }
  {
    char *dest;
    char b[] = "2016-04-31";
    readstat_dta_num_days(b, &dest);
    if (dest != b) {
      fprintf(stderr, "Expected failure!\n");
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<test_dta_dates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8f0,%rsp
lea    -0x30(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x30,%edx
call   10a0 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x30,%edx
call   10a0 <memcpy@plt>
movl   $0x640,-0x864(%rbp)
cmpl   $0x802,-0x864(%rbp)
jge    13cf <test_dta_dates+0x22f>
movl   $0x0,-0x868(%rbp)
cmpl   $0xc,-0x868(%rbp)
jge    13b6 <test_dta_dates+0x216>
mov    -0x864(%rbp),%edi
call   1060 <is_leap@plt>
cmp    $0x0,%rax
je     1231 <test_dta_dates+0x91>
movslq -0x868(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x8d8(%rbp)
jmp    1242 <test_dta_dates+0xa2>
movslq -0x868(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x8d8(%rbp)
mov    -0x8d8(%rbp),%eax
mov    %eax,-0x86c(%rbp)
movl   $0x1,-0x870(%rbp)
mov    -0x870(%rbp),%eax
cmp    -0x86c(%rbp),%eax
jg     139d <test_dta_dates+0x1fd>
lea    -0x460(%rbp),%rdi
mov    -0x864(%rbp),%ecx
mov    -0x868(%rbp),%r8d
add    $0x1,%r8d
mov    -0x870(%rbp),%r9d
mov    $0x400,%esi
lea    0xdcb(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x460(%rbp),%rdi
lea    -0x878(%rbp),%rsi
call   10b0 <readstat_dta_num_days@plt>
mov    %eax,-0x87c(%rbp)
mov    -0x878(%rbp),%rax
lea    -0x460(%rbp),%rcx
cmp    %rcx,%rax
jne    12ef <test_dta_dates+0x14f>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x87c(%rbp),%edi
lea    -0x860(%rbp),%rsi
mov    $0x3ff,%edx
call   1080 <readstat_dta_days_string@plt>
lea    -0x460(%rbp),%rax
mov    %rax,-0x8e8(%rbp)
lea    -0x860(%rbp),%rax
mov    %rax,-0x8e0(%rbp)
lea    -0x460(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x8e8(%rbp),%rdi
mov    -0x8e0(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1384 <test_dta_dates+0x1e4>
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
lea    -0x460(%rbp),%rdx
lea    -0x860(%rbp),%rcx
lea    0xd17(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1389 <test_dta_dates+0x1e9>
mov    -0x870(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x870(%rbp)
jmp    1258 <test_dta_dates+0xb8>
jmp    13a2 <test_dta_dates+0x202>
mov    -0x868(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x868(%rbp)
jmp    11f9 <test_dta_dates+0x59>
jmp    13bb <test_dta_dates+0x21b>
mov    -0x864(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x864(%rbp)
jmp    11df <test_dta_dates+0x3f>
mov    0xcce(%rip),%rax
mov    %rax,-0x893(%rbp)
mov    0xcc8(%rip),%ax
mov    %ax,-0x88b(%rbp)
mov    0xcbd(%rip),%al
mov    %al,-0x889(%rbp)
lea    -0x893(%rbp),%rdi
lea    -0x888(%rbp),%rsi
call   10b0 <readstat_dta_num_days@plt>
mov    -0x888(%rbp),%rax
lea    -0x893(%rbp),%rcx
cmp    %rcx,%rax
je     1446 <test_dta_dates+0x2a6>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x8a1(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1070 <memset@plt>
lea    -0x8a1(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
call   10b0 <readstat_dta_num_days@plt>
mov    -0x8a0(%rbp),%rax
lea    -0x8a1(%rbp),%rcx
cmp    %rcx,%rax
je     14a8 <test_dta_dates+0x308>
mov    0x2b56(%rip),%rax
mov    (%rax),%edi
lea    0xc1c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0xc13(%rip),%rax
mov    %rax,-0x8bb(%rbp)
mov    0xc0d(%rip),%ax
mov    %ax,-0x8b3(%rbp)
mov    0xc02(%rip),%al
mov    %al,-0x8b1(%rbp)
lea    -0x8bb(%rbp),%rdi
lea    -0x8b0(%rbp),%rsi
call   10b0 <readstat_dta_num_days@plt>
mov    -0x8b0(%rbp),%rax
lea    -0x8bb(%rbp),%rcx
cmp    %rcx,%rax
je     151f <test_dta_dates+0x37f>
mov    0x2adf(%rip),%rax
mov    (%rax),%edi
lea    0xba5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ac0(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0xba7(%rip),%rax
mov    %rax,-0x8d3(%rbp)
mov    0xba1(%rip),%ax
mov    %ax,-0x8cb(%rbp)
mov    0xb96(%rip),%al
mov    %al,-0x8c9(%rbp)
lea    -0x8d3(%rbp),%rdi
lea    -0x8c8(%rbp),%rsi
call   10b0 <readstat_dta_num_days@plt>
mov    -0x8c8(%rbp),%rax
lea    -0x8d3(%rbp),%rcx
cmp    %rcx,%rax
je     1596 <test_dta_dates+0x3f6>
mov    0x2a68(%rip),%rax
mov    (%rax),%edi
lea    0xb2e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2a49(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
add    $0x8f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_dta_dates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    $0x640,%r12d
lea    0x420(%rsp),%rbx
lea    0x20(%rsp),%r13
jmp    11c1 <test_dta_dates+0x41>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    $0x802,%r12d
je     128c <test_dta_dates+0x10c>
xor    %ebp,%ebp
jmp    11d6 <test_dta_dates+0x56>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0xc,%rbp
je     11b0 <test_dta_dates+0x30>
mov    %r12d,%edi
call   1060 <is_leap@plt>
test   %rax,%rax
lea    0xe48(%rip),%rax
lea    0xe11(%rip),%rcx
cmove  %rcx,%rax
mov    (%rax,%rbp,4),%r15d
add    $0x1,%rbp
test   %r15d,%r15d
jle    11d0 <test_dta_dates+0x50>
neg    %r15d
mov    $0x1,%r14d
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xe41(%rip),%rdx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %r14d,%r9d
call   1050 <snprintf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1090 <readstat_dta_num_days@plt>
cmp    %rbx,0x8(%rsp)
je     134f <test_dta_dates+0x1cf>
mov    %eax,%edi
mov    %r13,%rsi
mov    $0x3ff,%edx
call   1070 <readstat_dta_days_string@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1368 <test_dta_dates+0x1e8>
lea    (%r15,%r14,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
mov    %ecx,%r14d
cmp    $0x1,%eax
jne    1210 <test_dta_dates+0x90>
jmp    11d0 <test_dta_dates+0x50>
movabs $0x2d30302d36313032,%rax
30 30 2d
mov    %rax,0x8(%rsp)
movl   $0x31302d,0xf(%rsp)
lea    0x18(%rsp),%rbp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <readstat_dta_num_days@plt>
cmp    %rbx,0x18(%rsp)
jne    139a <test_dta_dates+0x21a>
movb   $0x0,0x18(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <readstat_dta_num_days@plt>
cmp    %rbp,0x8(%rsp)
jne    139a <test_dta_dates+0x21a>
movabs $0x2d33312d36313032,%rax
31 33 2d
mov    %rax,0x8(%rsp)
movl   $0x31302d,0xf(%rsp)
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <readstat_dta_num_days@plt>
cmp    %rbx,0x18(%rsp)
jne    139a <test_dta_dates+0x21a>
movabs $0x2d34302d36313032,%rax
30 34 2d
mov    %rax,0x8(%rsp)
movl   $0x31332d,0xf(%rsp)
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <readstat_dta_num_days@plt>
cmp    %rbx,0x18(%rsp)
jne    139a <test_dta_dates+0x21a>
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
lea    0xd10(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    138c <test_dta_dates+0x20c>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
lea    0x420(%rsp),%rdx
lea    0x20(%rsp),%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
jmp    135f <test_dta_dates+0x1df>

LLVM IR (-O0):
@__const.test_dta_dates.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.test_dta_dates.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]
@.str = [15 x i8] c"%04d-%02d-%02d\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"failure to parse date\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"failure. Expected %s, got %s\0A\00"
@__const.test_dta_dates.b = [11 x i8] c"2016-00-01\00"
@.str.3 = [19 x i8] c"Expected failure!\0A\00"
@__const.test_dta_dates.b.4 = [11 x i8] c"2016-13-01\00"
@__const.test_dta_dates.b.5 = [11 x i8] c"2016-04-31\00"
define void @test_dta_dates() {
%1 = alloca [12 x i32]
%2 = alloca [12 x i32]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [11 x i8]
%13 = alloca i8*
%14 = alloca [1 x i8]
%15 = alloca i8*
%16 = alloca [11 x i8]
%17 = alloca i8*
%18 = alloca [11 x i8]
%19 = bitcast [12 x i32]* %1 to i8*
%20 = bitcast [12 x i32]* %2 to i8*
store i32 1600, i32* %5
br label %21
21: ; preds = %91, %0
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 2050
br i1 %23, label %24, label %94
24: ; preds = %21
store i32 0, i32* %6
br label %25
25: ; preds = %87, %24
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 12
br i1 %27, label %28, label %90
28: ; preds = %25
%29 = load i32, i32* %5
%30 = call i64 @is_leap(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
br label %42
37: ; preds = %28
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %39
%41 = load i32, i32* %40
br label %42
42: ; preds = %37, %32
%43 = phi i32 [ %36, %32 ], [ %41, %37 ]
store i32 %43, i32* %7
store i32 1, i32* %8
br label %44
44: ; preds = %83, %42
%45 = load i32, i32* %8
%46 = load i32, i32* %7
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %86
48: ; preds = %44
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
%53 = load i32, i32* %8
%54 = call i32 @snprintf(i8* %49, i32 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %50, i32 %52, i32 %53)
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%56 = call i32 @readstat_dta_num_days(i8* %55, i8** %9)
store i32 %56, i32* %10
%57 = load i8*, i8** %9
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%59 = icmp eq i8* %57, %58
br i1 %59, label %60, label %65
60: ; preds = %48
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %48
%66 = load i32, i32* %10
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%68 = call i32 @readstat_dta_days_string(i32 %66, i8* %67, i32 1023)
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%72 = call i32 @strlen(i8* %71)
%73 = call i64 @strncmp(i8* %69, i8* %70, i32 %72)
%74 = icmp ne i64 0, %73
br i1 %74, label %75, label %82
75: ; preds = %65
%76 = load i32, i32* @stderr
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %77, i8* %78)
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %65
br label %83
83: ; preds = %82
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %44
86: ; preds = %44
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %25
90: ; preds = %25
br label %91
91: ; preds = %90
%92 = load i32, i32* %5
%93 = add nsw i32 %92, 1
store i32 %93, i32* %5
br label %21
94: ; preds = %21
%95 = bitcast [11 x i8]* %12 to i8*
%96 = getelementptr inbounds [11 x i8], [11 x i8]* %12, i64 0, i64 0
%97 = call i32 @readstat_dta_num_days(i8* %96, i8** %11)
%98 = load i8*, i8** %11
%99 = getelementptr inbounds [11 x i8], [11 x i8]* %12, i64 0, i64 0
%100 = icmp ne i8* %98, %99
br i1 %100, label %101, label %106
101: ; preds = %94
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%104 = load i32, i32* @EXIT_FAILURE
%105 = call i32 @exit(i32 %104)
unreachable
106: ; preds = %94
%107 = bitcast [1 x i8]* %14 to i8*
%108 = getelementptr inbounds [1 x i8], [1 x i8]* %14, i64 0, i64 0
%109 = call i32 @readstat_dta_num_days(i8* %108, i8** %13)
%110 = load i8*, i8** %13
%111 = getelementptr inbounds [1 x i8], [1 x i8]* %14, i64 0, i64 0
%112 = icmp ne i8* %110, %111
br i1 %112, label %113, label %118
113: ; preds = %106
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%116 = load i32, i32* @EXIT_FAILURE
%117 = call i32 @exit(i32 %116)
unreachable
118: ; preds = %106
%119 = bitcast [11 x i8]* %16 to i8*
%120 = getelementptr inbounds [11 x i8], [11 x i8]* %16, i64 0, i64 0
%121 = call i32 @readstat_dta_num_days(i8* %120, i8** %15)
%122 = load i8*, i8** %15
%123 = getelementptr inbounds [11 x i8], [11 x i8]* %16, i64 0, i64 0
%124 = icmp ne i8* %122, %123
br i1 %124, label %125, label %130
125: ; preds = %118
%126 = load i32, i32* @stderr
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @exit(i32 %128)
unreachable
130: ; preds = %118
%131 = bitcast [11 x i8]* %18 to i8*
%132 = getelementptr inbounds [11 x i8], [11 x i8]* %18, i64 0, i64 0
%133 = call i32 @readstat_dta_num_days(i8* %132, i8** %17)
%134 = load i8*, i8** %17
%135 = getelementptr inbounds [11 x i8], [11 x i8]* %18, i64 0, i64 0
%136 = icmp ne i8* %134, %135
br i1 %136, label %137, label %142
137: ; preds = %130
%138 = load i32, i32* @stderr
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%140 = load i32, i32* @EXIT_FAILURE
%141 = call i32 @exit(i32 %140)
unreachable
142: ; preds = %130
ret void
}

LLVM IR (-O2):
@__const.test_dta_dates.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.test_dta_dates.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]
@.str = [15 x i8] c"%04d-%02d-%02d\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"failure to parse date\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"failure. Expected %s, got %s\0A\00"
@__const.test_dta_dates.b = [11 x i8] c"2016-00-01\00"
@.str.3 = [19 x i8] c"Expected failure!\0A\00"
@__const.test_dta_dates.b.4 = [11 x i8] c"2016-13-01\00"
@__const.test_dta_dates.b.5 = [11 x i8] c"2016-04-31\00"
define void @test_dta_dates() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [11 x i8]
%6 = alloca i8*
%7 = alloca [1 x i8]
%8 = alloca i8*
%9 = alloca [11 x i8]
%10 = alloca i8*
%11 = alloca [11 x i8]
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%14 = bitcast i8** %3 to i8*
br label %15
15: ; preds = %0, %23
%16 = phi i32 [ 1600, %0 ], [ %24, %23 ]
br label %26
17: ; preds = %23
%18 = bitcast i8** %4 to i8*
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%20 = call i32 @readstat_dta_num_days(i8* %19, i8** %4)
%21 = load i8*, i8** %4
%22 = icmp eq i8* %21, %19
br i1 %22, label %69, label %64
23: ; preds = %38
%24 = add nuw nsw i32 %16, 1
%25 = icmp eq i32 %24, 2050
br i1 %25, label %17, label %15
26: ; preds = %15, %38
%27 = phi i64 [ 0, %15 ], [ %35, %38 ]
%28 = call i64 @is_leap(i32 %16)
%29 = icmp eq i64 %28, 0
%30 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.test_dta_dates.daysPerMonthLeap, i64 0, i64 %27
%31 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.test_dta_dates.daysPerMonth, i64 0, i64 %27
%32 = select i1 %29, i32* %31, i32* %30
%33 = load i32, i32* %32
%34 = icmp slt i32 %33, 1
%35 = add nuw nsw i64 %27, 1
br i1 %34, label %38, label %36
36: ; preds = %26
%37 = trunc i64 %35 to i32
br label %40
38: ; preds = %61, %26
%39 = icmp eq i64 %35, 12
br i1 %39, label %23, label %26
40: ; preds = %36, %61
%41 = phi i32 [ 1, %36 ], [ %62, %61 ]
%42 = call i32 @snprintf(i8* %12, i32 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %37, i32 %41)
%43 = call i32 @readstat_dta_num_days(i8* %12, i8** %3)
%44 = load i8*, i8** %3
%45 = icmp eq i8* %44, %12
br i1 %45, label %46, label %51
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %40
%52 = call i32 @readstat_dta_days_string(i32 %43, i8* %13, i32 1023)
%53 = call i32 @strlen(i8* %12)
%54 = call i64 @strncmp(i8* %12, i8* %13, i32 %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %51
%62 = add nuw i32 %41, 1
%63 = icmp eq i32 %41, %33
br i1 %63, label %38, label %40
64: ; preds = %17
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %17
%70 = bitcast i8** %6 to i8*
%71 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
store i8 0, i8* %71
%72 = call i32 @readstat_dta_num_days(i8* %71, i8** %6)
%73 = load i8*, i8** %6
%74 = icmp eq i8* %73, %71
br i1 %74, label %80, label %75
75: ; preds = %69
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %69
%81 = bitcast i8** %8 to i8*
%82 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%83 = call i32 @readstat_dta_num_days(i8* %82, i8** %8)
%84 = load i8*, i8** %8
%85 = icmp eq i8* %84, %82
br i1 %85, label %91, label %86
86: ; preds = %80
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %80
%92 = bitcast i8** %10 to i8*
%93 = getelementptr inbounds [11 x i8], [11 x i8]* %11, i64 0, i64 0
%94 = call i32 @readstat_dta_num_days(i8* %93, i8** %10)
%95 = load i8*, i8** %10
%96 = icmp eq i8* %95, %93
br i1 %96, label %102, label %97
97: ; preds = %91
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %91
ret void
}