#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*/ ffpmsg(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int ffverifydate(int year, int month, int day, int *status) {
  int ndays[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  char errmsg[81];
  if (year < 0 || year > 9999) {
    sprintf(errmsg, "input year value = %d is out of range 0 - 9999", year);
    ffpmsg(errmsg);
    return (*status = 420);
  } else if (month < 1 || month > 12) {
    sprintf(errmsg, "input month value = %d is out of range 1 - 12", month);
    ffpmsg(errmsg);
    return (*status = 420);
  }
  if (ndays[month] == 31) {
    if (day < 1 || day > 31) {
      sprintf(errmsg,
              "input day value = %d is out of range 1 - 31 for month %d", day,
              month);
      ffpmsg(errmsg);
      return (*status = 420);
    }
  } else if (ndays[month] == 30) {
    if (day < 1 || day > 30) {
      sprintf(errmsg,
              "input day value = %d is out of range 1 - 30 for month %d", day,
              month);
      ffpmsg(errmsg);
      return (*status = 420);
    }
  } else {
    if (day < 1 || day > 28) {
      if (day == 29) {
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
          return (*status);
        sprintf(errmsg,
                "input day value = %d is out of range 1 - 28 for February %d "
                "(not leap year)",
                day, year);
        ffpmsg(errmsg);
      } else {
        sprintf(
            errmsg,
            "input day value = %d is out of range 1 - 28 (or 29) for February",
            day);
        ffpmsg(errmsg);
      }
      return (*status = 420);
    }
  }
  return (*status);
}


x86 assembly (clang, -O0):
<ffverifydate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x34,%edx
call   1040 <memcpy@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1174 <ffverifydate+0x44>
cmpl   $0x270f,-0x8(%rbp)
jle    11ae <ffverifydate+0x7e>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x18(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    13ac <ffverifydate+0x27c>
cmpl   $0x1,-0xc(%rbp)
jl     11c2 <ffverifydate+0x92>
cmpl   $0xc,-0xc(%rbp)
jle    11fc <ffverifydate+0xcc>
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x18(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    13ac <ffverifydate+0x27c>
jmp    1201 <ffverifydate+0xd1>
movslq -0xc(%rbp),%rax
cmpl   $0x1f,-0x50(%rbp,%rax,4)
jne    1266 <ffverifydate+0x136>
cmpl   $0x1,-0x10(%rbp)
jl     1224 <ffverifydate+0xf4>
cmpl   $0x1f,-0x10(%rbp)
jle    1261 <ffverifydate+0x131>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x18(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    13ac <ffverifydate+0x27c>
jmp    13a3 <ffverifydate+0x273>
movslq -0xc(%rbp),%rax
cmpl   $0x1e,-0x50(%rbp,%rax,4)
jne    12cb <ffverifydate+0x19b>
cmpl   $0x1,-0x10(%rbp)
jl     1289 <ffverifydate+0x159>
cmpl   $0x1e,-0x10(%rbp)
jle    12c6 <ffverifydate+0x196>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x18(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    13ac <ffverifydate+0x27c>
jmp    139e <ffverifydate+0x26e>
cmpl   $0x1,-0x10(%rbp)
jl     12df <ffverifydate+0x1af>
cmpl   $0x1c,-0x10(%rbp)
jle    1399 <ffverifydate+0x269>
cmpl   $0x1d,-0x10(%rbp)
jne    135f <ffverifydate+0x22f>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1311 <ffverifydate+0x1e1>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1325 <ffverifydate+0x1f5>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1333 <ffverifydate+0x203>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13ac <ffverifydate+0x27c>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xdbc(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <ffpmsg@plt>
jmp    1383 <ffverifydate+0x253>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x18(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    13ac <ffverifydate+0x27c>
jmp    139e <ffverifydate+0x26e>
jmp    13a3 <ffverifydate+0x273>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffverifydate>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rcx,%r14
mov    %edi,%ecx
cmp    $0x2710,%edi
jb     1145 <ffverifydate+0x25>
lea    0xec5(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ecx,%edx
jmp    115e <ffverifydate+0x3e>
mov    %esi,%eax
lea    -0xd(%rax),%esi
cmp    $0xfffffff3,%esi
ja     1181 <ffverifydate+0x61>
lea    0xed9(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <ffpmsg@plt>
movl   $0x1a4,(%r14)
mov    $0x1a4,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x15aa,%esi
bt     %rax,%rsi
jb     11fd <ffverifydate+0xdd>
mov    %eax,%esi
mov    $0xa50,%edi
bt     %rsi,%rdi
jb     120e <ffverifydate+0xee>
lea    -0x1d(%rdx),%eax
cmp    $0xffffffe3,%eax
ja     1231 <ffverifydate+0x111>
cmp    $0x1d,%edx
jne    1239 <ffverifydate+0x119>
test   $0x3,%cl
sete   %al
imul   $0x5c29,%ecx,%esi
mov    %esi,%edx
ror    $0x2,%dx
movzwl %dx,%edx
cmp    $0x290,%edx
setae  %dl
ror    $0x4,%si
movzwl %si,%esi
cmp    $0xa4,%esi
jb     1231 <ffverifydate+0x111>
and    %dl,%al
jne    1231 <ffverifydate+0x111>
lea    0xee9(%rip),%rsi
mov    %rsp,%rdi
mov    $0x1d,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rsp,%rdi
jmp    1168 <ffverifydate+0x48>
lea    -0x20(%rdx),%ecx
cmp    $0xffffffe0,%ecx
ja     1231 <ffverifydate+0x111>
lea    0xe51(%rip),%rsi
jmp    121d <ffverifydate+0xfd>
lea    -0x1f(%rdx),%ecx
cmp    $0xffffffe1,%ecx
ja     1231 <ffverifydate+0x111>
lea    0xe79(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1165 <ffverifydate+0x45>
mov    (%r14),%eax
jmp    1179 <ffverifydate+0x59>
lea    0xedb(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rsp,%rdi
jmp    1168 <ffverifydate+0x48>

LLVM IR (-O0):
@__const.ffverifydate.ndays = [13 x i32] [i32 0, i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@.str = [47 x i8] c"input year value = %d is out of range 0 - 9999\00"
@.str.1 = [46 x i8] c"input month value = %d is out of range 1 - 12\00"
@.str.2 = [57 x i8] c"input day value = %d is out of range 1 - 31 for month %d\00"
@.str.3 = [57 x i8] c"input day value = %d is out of range 1 - 30 for month %d\00"
@.str.4 = [76 x i8] c"input day value = %d is out of range 1 - 28 for February %d (not leap year)\00"
@.str.5 = [65 x i8] c"input day value = %d is out of range 1 - 28 (or 29) for February\00"
define i32 @ffverifydate(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [13 x i32]
%11 = alloca [81 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%12 = bitcast [13 x i32]* %10 to i8*
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %4
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 9999
br i1 %17, label %18, label %25
18: ; preds = %15, %4
%19 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%20 = load i32, i32* %6
%21 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%23 = call i32 @ffpmsg(i8* %22)
%24 = load i32*, i32** %9
store i32 420, i32* %24
store i32 420, i32* %5
br label %125
25: ; preds = %15
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 1
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %7
%30 = icmp sgt i32 %29, 12
br i1 %30, label %31, label %38
31: ; preds = %28, %25
%32 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%33 = load i32, i32* %7
%34 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%36 = call i32 @ffpmsg(i8* %35)
%37 = load i32*, i32** %9
store i32 420, i32* %37
store i32 420, i32* %5
br label %125
38: ; preds = %28
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [13 x i32], [13 x i32]* %10, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 31
br i1 %44, label %45, label %60
45: ; preds = %39
%46 = load i32, i32* %8
%47 = icmp slt i32 %46, 1
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* %8
%50 = icmp sgt i32 %49, 31
br i1 %50, label %51, label %59
51: ; preds = %48, %45
%52 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%53 = load i32, i32* %8
%54 = load i32, i32* %7
%55 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %53, i32 %54)
%56 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%57 = call i32 @ffpmsg(i8* %56)
%58 = load i32*, i32** %9
store i32 420, i32* %58
store i32 420, i32* %5
br label %125
59: ; preds = %48
br label %122
60: ; preds = %39
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [13 x i32], [13 x i32]* %10, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = icmp eq i32 %64, 30
br i1 %65, label %66, label %81
66: ; preds = %60
%67 = load i32, i32* %8
%68 = icmp slt i32 %67, 1
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load i32, i32* %8
%71 = icmp sgt i32 %70, 30
br i1 %71, label %72, label %80
72: ; preds = %69, %66
%73 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%74 = load i32, i32* %8
%75 = load i32, i32* %7
%76 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %74, i32 %75)
%77 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%78 = call i32 @ffpmsg(i8* %77)
%79 = load i32*, i32** %9
store i32 420, i32* %79
store i32 420, i32* %5
br label %125
80: ; preds = %69
br label %121
81: ; preds = %60
%82 = load i32, i32* %8
%83 = icmp slt i32 %82, 1
br i1 %83, label %87, label %84
84: ; preds = %81
%85 = load i32, i32* %8
%86 = icmp sgt i32 %85, 28
br i1 %86, label %87, label %120
87: ; preds = %84, %81
%88 = load i32, i32* %8
%89 = icmp eq i32 %88, 29
br i1 %89, label %90, label %112
90: ; preds = %87
%91 = load i32, i32* %6
%92 = srem i32 %91, 4
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %98
94: ; preds = %90
%95 = load i32, i32* %6
%96 = srem i32 %95, 100
%97 = icmp ne i32 %96, 0
br i1 %97, label %102, label %98
98: ; preds = %94, %90
%99 = load i32, i32* %6
%100 = srem i32 %99, 400
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %98, %94
%103 = load i32*, i32** %9
%104 = load i32, i32* %103
store i32 %104, i32* %5
br label %125
105: ; preds = %98
%106 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%107 = load i32, i32* %8
%108 = load i32, i32* %6
%109 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %106, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.4, i64 0, i64 0), i32 %107, i32 %108)
%110 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%111 = call i32 @ffpmsg(i8* %110)
br label %118
112: ; preds = %87
%113 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%114 = load i32, i32* %8
%115 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %113, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.5, i64 0, i64 0), i32 %114)
%116 = getelementptr inbounds [81 x i8], [81 x i8]* %11, i64 0, i64 0
%117 = call i32 @ffpmsg(i8* %116)
br label %118
118: ; preds = %112, %105
%119 = load i32*, i32** %9
store i32 420, i32* %119
store i32 420, i32* %5
br label %125
120: ; preds = %84
br label %121
121: ; preds = %120, %80
br label %122
122: ; preds = %121, %59
%123 = load i32*, i32** %9
%124 = load i32, i32* %123
store i32 %124, i32* %5
br label %125
125: ; preds = %122, %118, %102, %72, %51, %31, %18
%126 = load i32, i32* %5
ret i32 %126
}

LLVM IR (-O2):
@.str = [47 x i8] c"input year value = %d is out of range 0 - 9999\00"
@.str.1 = [46 x i8] c"input month value = %d is out of range 1 - 12\00"
@.str.2 = [57 x i8] c"input day value = %d is out of range 1 - 31 for month %d\00"
@.str.3 = [57 x i8] c"input day value = %d is out of range 1 - 30 for month %d\00"
@.str.4 = [76 x i8] c"input day value = %d is out of range 1 - 28 for February %d (not leap year)\00"
@.str.5 = [65 x i8] c"input day value = %d is out of range 1 - 28 (or 29) for February\00"
define i32 @ffverifydate(i32 %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = alloca [81 x i8]
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%7 = icmp ugt i32 %0, 9999
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = call i32 @ffpmsg(i8* %6)
store i32 420, i32* %3
br label %63
11: ; preds = %4
%12 = add i32 %1, -13
%13 = icmp ult i32 %12, -12
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%16 = call i32 @ffpmsg(i8* %6)
store i32 420, i32* %3
br label %63
17: ; preds = %11
%18 = zext i32 %1 to i64
%19 = lshr i64 5546, %18
%20 = and i64 %19, 1
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %17
%23 = add i32 %2, -32
%24 = icmp ult i32 %23, -31
br i1 %24, label %25, label %61
25: ; preds = %22
%26 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %2, i32 %1)
%27 = call i32 @ffpmsg(i8* %6)
store i32 420, i32* %3
br label %63
28: ; preds = %17
%29 = lshr i64 2640, %18
%30 = and i64 %29, 1
%31 = icmp eq i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %28
%33 = add i32 %2, -31
%34 = icmp ult i32 %33, -30
br i1 %34, label %35, label %61
35: ; preds = %32
%36 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %2, i32 %1)
%37 = call i32 @ffpmsg(i8* %6)
store i32 420, i32* %3
br label %63
38: ; preds = %28
%39 = add i32 %2, -29
%40 = icmp ult i32 %39, -28
br i1 %40, label %41, label %61
41: ; preds = %38
%42 = icmp eq i32 %2, 29
br i1 %42, label %43, label %57
43: ; preds = %41
%44 = and i32 %0, 3
%45 = icmp eq i32 %44, 0
%46 = trunc i32 %0 to i16
%47 = urem i16 %46, 100
%48 = icmp ne i16 %47, 0
%49 = and i1 %45, %48
%50 = urem i16 %46, 400
%51 = icmp eq i16 %50, 0
%52 = or i1 %51, %49
br i1 %52, label %53, label %55
53: ; preds = %43
%54 = load i32, i32* %3
br label %63
55: ; preds = %43
%56 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.4, i64 0, i64 0), i32 29, i32 %0)
br label %59
57: ; preds = %41
%58 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.5, i64 0, i64 0), i32 %2)
br label %59
59: ; preds = %57, %55
%60 = call i32 @ffpmsg(i8* %6)
store i32 420, i32* %3
br label %63
61: ; preds = %32, %38, %22
%62 = load i32, i32* %3
br label %63
63: ; preds = %61, %59, %53, %35, %25, %14, %8
%64 = phi i32 [ 420, %8 ], [ 420, %14 ], [ 420, %25 ], [ %62, %61 ], [ 420, %35 ], [ %54, %53 ], [ 420, %59 ]
ret i32 %64
}