#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 ffdt2s(int year, int month, int day, char *datestr, int *status) {
  char errmsg[81];
  if (*status > 0)
    return (*status);
  if (year < 0 || year > 9999) {
    sprintf(errmsg, "input year value is out of range 0 - 9999: %d (ffdt2s)",
            year);
    ffpmsg(errmsg);
    return (*status = 420);
  } else if (month < 1 || month > 12) {
    sprintf(errmsg, "input month value is out of range 1 - 12: %d (ffdt2s)",
            month);
    ffpmsg(errmsg);
    return (*status = 420);
  } else if (day < 1 || day > 31) {
    sprintf(errmsg, "input day value is out of range 1 - 31: %d (ffdt2s)", day);
    ffpmsg(errmsg);
    return (*status = 420);
  }
  if (year >= 1900 && year <= 1998)
    sprintf(datestr, "%.2d/%.2d/%.2d", day, month, year - 1900);
  else
    sprintf(datestr, "%.4d-%.2d-%.2d", year, month, day);
  return (*status);
}


x86 assembly (clang, -O0):
<ffdt2s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1157 <ffdt2s+0x37>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <ffdt2s+0x183>
cmpl   $0x0,-0x8(%rbp)
jl     116e <ffdt2s+0x4e>
cmpl   $0x270f,-0x8(%rbp)
jle    11a2 <ffdt2s+0x82>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    12a3 <ffdt2s+0x183>
cmpl   $0x1,-0xc(%rbp)
jl     11b6 <ffdt2s+0x96>
cmpl   $0xc,-0xc(%rbp)
jle    11ea <ffdt2s+0xca>
lea    -0x80(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    12a3 <ffdt2s+0x183>
cmpl   $0x1,-0x10(%rbp)
jl     11fe <ffdt2s+0xde>
cmpl   $0x1f,-0x10(%rbp)
jle    1232 <ffdt2s+0x112>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <ffpmsg@plt>
mov    -0x20(%rbp),%rax
movl   $0x1a4,(%rax)
movl   $0x1a4,-0x4(%rbp)
jmp    12a3 <ffdt2s+0x183>
jmp    1237 <ffdt2s+0x117>
jmp    123c <ffdt2s+0x11c>
cmpl   $0x76c,-0x8(%rbp)
jl     127e <ffdt2s+0x15e>
cmpl   $0x7ce,-0x8(%rbp)
jg     127e <ffdt2s+0x15e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%r8d
sub    $0x76c,%r8d
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    129a <ffdt2s+0x17a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffdt2s>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    (%r8),%eax
test   %eax,%eax
jg     119e <ffdt2s+0x7e>
mov    %r8,%rbx
mov    %edx,%r10d
mov    %edi,%edx
cmp    $0x2710,%edi
jb     114d <ffdt2s+0x2d>
lea    0xebb(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
jmp    1184 <ffdt2s+0x64>
mov    %esi,%r9d
lea    -0xd(%r9),%eax
cmp    $0xfffffff3,%eax
ja     116b <ffdt2s+0x4b>
lea    0xed7(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r9d,%edx
jmp    1184 <ffdt2s+0x64>
lea    -0x20(%r10),%eax
cmp    $0xffffffe0,%eax
ja     11a6 <ffdt2s+0x86>
lea    0xef2(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r10d,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %r14,%rdi
call   1030 <ffpmsg@plt>
movl   $0x1a4,(%rbx)
mov    $0x1a4,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
lea    -0x76c(%rdx),%r8d
cmp    $0x62,%r8d
ja     11c5 <ffdt2s+0xa5>
lea    0xee7(%rip),%rsi
mov    %rcx,%rdi
mov    %r10d,%edx
mov    %r9d,%ecx
jmp    11d5 <ffdt2s+0xb5>
lea    0xee4(%rip),%rsi
mov    %rcx,%rdi
mov    %r9d,%ecx
mov    %r10d,%r8d
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    (%rbx),%eax
jmp    119e <ffdt2s+0x7e>

LLVM IR (-O0):
@.str = [55 x i8] c"input year value is out of range 0 - 9999: %d (ffdt2s)\00"
@.str.1 = [54 x i8] c"input month value is out of range 1 - 12: %d (ffdt2s)\00"
@.str.2 = [52 x i8] c"input day value is out of range 1 - 31: %d (ffdt2s)\00"
@.str.3 = [15 x i8] c"%.2d/%.2d/%.2d\00"
@.str.4 = [15 x i8] c"%.4d-%.2d-%.2d\00"
define i32 @ffdt2s(i32 %0, i32 %1, i32 %2, i8* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca [81 x i8]
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32* %4, i32** %11
%13 = load i32*, i32** %11
%14 = load i32, i32* %13
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %5
%17 = load i32*, i32** %11
%18 = load i32, i32* %17
store i32 %18, i32* %6
br label %82
19: ; preds = %5
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* %7
%24 = icmp sgt i32 %23, 9999
br i1 %24, label %25, label %32
25: ; preds = %22, %19
%26 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%27 = load i32, i32* %7
%28 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%30 = call i32 @ffpmsg(i8* %29)
%31 = load i32*, i32** %11
store i32 420, i32* %31
store i32 420, i32* %6
br label %82
32: ; preds = %22
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 1
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %8
%37 = icmp sgt i32 %36, 12
br i1 %37, label %38, label %45
38: ; preds = %35, %32
%39 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%40 = load i32, i32* %8
%41 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%43 = call i32 @ffpmsg(i8* %42)
%44 = load i32*, i32** %11
store i32 420, i32* %44
store i32 420, i32* %6
br label %82
45: ; preds = %35
%46 = load i32, i32* %9
%47 = icmp slt i32 %46, 1
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* %9
%50 = icmp sgt i32 %49, 31
br i1 %50, label %51, label %58
51: ; preds = %48, %45
%52 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%53 = load i32, i32* %9
%54 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [81 x i8], [81 x i8]* %12, i64 0, i64 0
%56 = call i32 @ffpmsg(i8* %55)
%57 = load i32*, i32** %11
store i32 420, i32* %57
store i32 420, i32* %6
br label %82
58: ; preds = %48
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59
%61 = load i32, i32* %7
%62 = icmp sge i32 %61, 1900
br i1 %62, label %63, label %73
63: ; preds = %60
%64 = load i32, i32* %7
%65 = icmp sle i32 %64, 1998
br i1 %65, label %66, label %73
66: ; preds = %63
%67 = load i8*, i8** %10
%68 = load i32, i32* %9
%69 = load i32, i32* %8
%70 = load i32, i32* %7
%71 = sub nsw i32 %70, 1900
%72 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %68, i32 %69, i32 %71)
br label %79
73: ; preds = %63, %60
%74 = load i8*, i8** %10
%75 = load i32, i32* %7
%76 = load i32, i32* %8
%77 = load i32, i32* %9
%78 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %74, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %75, i32 %76, i32 %77)
br label %79
79: ; preds = %73, %66
%80 = load i32*, i32** %11
%81 = load i32, i32* %80
store i32 %81, i32* %6
br label %82
82: ; preds = %79, %51, %38, %25, %16
%83 = load i32, i32* %6
ret i32 %83
}

LLVM IR (-O2):
@.str = [55 x i8] c"input year value is out of range 0 - 9999: %d (ffdt2s)\00"
@.str.1 = [54 x i8] c"input month value is out of range 1 - 12: %d (ffdt2s)\00"
@.str.2 = [52 x i8] c"input day value is out of range 1 - 31: %d (ffdt2s)\00"
@.str.3 = [15 x i8] c"%.2d/%.2d/%.2d\00"
@.str.4 = [15 x i8] c"%.4d-%.2d-%.2d\00"
define i32 @ffdt2s(i32 %0, i32 %1, i32 %2, i8* nocapture writeonly %3, i32* nocapture %4) {
%6 = alloca [81 x i8]
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %36, label %10
10: ; preds = %5
%11 = icmp ugt i32 %0, 9999
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %0)
%14 = call i32 @ffpmsg(i8* %7)
store i32 420, i32* %4
br label %36
15: ; preds = %10
%16 = add i32 %1, -13
%17 = icmp ult i32 %16, -12
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%20 = call i32 @ffpmsg(i8* %7)
store i32 420, i32* %4
br label %36
21: ; preds = %15
%22 = add i32 %2, -32
%23 = icmp ult i32 %22, -31
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%26 = call i32 @ffpmsg(i8* %7)
store i32 420, i32* %4
br label %36
27: ; preds = %21
%28 = add nsw i32 %0, -1900
%29 = icmp ult i32 %28, 99
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %2, i32 %1, i32 %28)
br label %34
32: ; preds = %27
%33 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %0, i32 %1, i32 %2)
br label %34
34: ; preds = %32, %30
%35 = load i32, i32* %4
br label %36
36: ; preds = %5, %34, %24, %18, %12
%37 = phi i32 [ 420, %12 ], [ 420, %18 ], [ 420, %24 ], [ %35, %34 ], [ %8, %5 ]
ret i32 %37
}