#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*/ add_dt(int *, int *, int *, int *, int *, int *, int, int);
int /*<<< orphan*/ fatal_error(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int sscanf(char const *, char *, int *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ sub_dt(int *, int *, int *, int *, int *, int *, int, int);
int f_ndate(int mode, unsigned char **sec, float *data, unsigned int ndata,
            char *inv_out, void **local, const char *arg1, const char *arg2) {
  int year, month, day, hour, minute, second, i;
  int dtime, dt_unit, strlen_arg1, format;
  char string[3];
  if (mode == -1) {
    strlen_arg1 = strlen(arg1);
    day = month = 1;
    hour = minute = second = 0;
    format = (strlen_arg1 - 2) / 2;
    if (strlen_arg1 % 2 == 1 || strlen_arg1 < 4 || strlen_arg1 > 14)
      fatal_error(
          "ndates: "
          "(YYYY|YYYYMM|YYYYMMDD|YYYYMMDDHH|YYYYMMDDHHmm|YYYYMMDDHHmmss)",
          "");
    sscanf(arg1, "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute,
           &second);
    i = sscanf(arg2, "%d%2s", &dtime, string);
    string[2] = 0;
    if (i != 2)
      fatal_error("ndates: bad (int)(mn|hr|dy|mo|yr)", "");
    dt_unit = -1;
    if (strcmp(string, "yr") == 0)
      dt_unit = 4;
    else if (strcmp(string, "mo") == 0) {
      dt_unit = 3;
      format = (format >= 2) ? (format) : (2);
    } else if (strcmp(string, "dy") == 0) {
      dt_unit = 2;
      format = (format >= 3) ? (format) : (3);
    } else if (strcmp(string, "hr") == 0) {
      dt_unit = 1;
      format = (format >= 4) ? (format) : (4);
    } else if (strcmp(string, "mn") == 0) {
      dt_unit = 0;
      format = (format >= 5) ? (format) : (5);
    }
    if (dt_unit == -1)
      fatal_error("ndates: unsupported time unit %s", string);
    if (dtime >= 0)
      add_dt(&year, &month, &day, &hour, &minute, &second, dtime, dt_unit);
    else
      sub_dt(&year, &month, &day, &hour, &minute, &second, -dtime, dt_unit);
    if (format == 1) {
      sprintf(inv_out, "%.4d\n", year);
    } else if (format == 2) {
      sprintf(inv_out, "%.4d%.2d\n", year, month);
    } else if (format == 3) {
      sprintf(inv_out, "%.4d%.2d%.2d\n", year, month, day);
    } else if (format == 4) {
      sprintf(inv_out, "%.4d%.2d%.2d%.2d\n", year, month, day, hour);
    } else if (format == 5) {
      sprintf(inv_out, "%.4d%.2d%.2d%.2d%.2d\n", year, month, day, hour,
              minute);
    } else {
      sprintf(inv_out, "%.4d%.2d%.2d%.2d%.2d%.2d\n", year, month, day, hour,
              minute, second);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_ndate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    15a9 <f_ndate+0x439>
mov    0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x58(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
je     120b <f_ndate+0x9b>
cmpl   $0x4,-0x58(%rbp)
jl     120b <f_ndate+0x9b>
cmpl   $0xe,-0x58(%rbp)
jle    121e <f_ndate+0xae>
lea    0xdee(%rip),%rdi
lea    0xef7(%rip),%rsi
call   1060 <fatal_error@plt>
mov    0x10(%rbp),%rdi
lea    0xe1d(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%r10
lea    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    0x18(%rbp),%rdi
lea    -0x5f(%rbp),%rcx
lea    0xdf9(%rip),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
mov    %eax,-0x4c(%rbp)
movb   $0x0,-0x5d(%rbp)
cmpl   $0x2,-0x4c(%rbp)
je     128f <f_ndate+0x11f>
lea    0xddc(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1060 <fatal_error@plt>
movl   $0xffffffff,-0x54(%rbp)
lea    -0x5f(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12bc <f_ndate+0x14c>
movl   $0x4,-0x54(%rbp)
jmp    1403 <f_ndate+0x293>
lea    -0x5f(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    130a <f_ndate+0x19a>
movl   $0x3,-0x54(%rbp)
cmpl   $0x2,-0x5c(%rbp)
jl     12f2 <f_ndate+0x182>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x64(%rbp)
jmp    12ff <f_ndate+0x18f>
mov    $0x2,%eax
mov    %eax,-0x64(%rbp)
jmp    12ff <f_ndate+0x18f>
mov    -0x64(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    13fe <f_ndate+0x28e>
lea    -0x5f(%rbp),%rdi
lea    0xd72(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1358 <f_ndate+0x1e8>
movl   $0x2,-0x54(%rbp)
cmpl   $0x3,-0x5c(%rbp)
jl     1340 <f_ndate+0x1d0>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x68(%rbp)
jmp    134d <f_ndate+0x1dd>
mov    $0x3,%eax
mov    %eax,-0x68(%rbp)
jmp    134d <f_ndate+0x1dd>
mov    -0x68(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    13f9 <f_ndate+0x289>
lea    -0x5f(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    13a6 <f_ndate+0x236>
movl   $0x1,-0x54(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jl     138e <f_ndate+0x21e>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
jmp    139b <f_ndate+0x22b>
mov    $0x4,%eax
mov    %eax,-0x6c(%rbp)
jmp    139b <f_ndate+0x22b>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    13f4 <f_ndate+0x284>
lea    -0x5f(%rbp),%rdi
lea    0xcdc(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    13ef <f_ndate+0x27f>
movl   $0x0,-0x54(%rbp)
cmpl   $0x5,-0x5c(%rbp)
jl     13dc <f_ndate+0x26c>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x70(%rbp)
jmp    13e9 <f_ndate+0x279>
mov    $0x5,%eax
mov    %eax,-0x70(%rbp)
jmp    13e9 <f_ndate+0x279>
mov    -0x70(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    13f4 <f_ndate+0x284>
jmp    13f9 <f_ndate+0x289>
jmp    13fe <f_ndate+0x28e>
jmp    1403 <f_ndate+0x293>
cmpl   $0xffffffff,-0x54(%rbp)
jne    141d <f_ndate+0x2ad>
lea    -0x5f(%rbp),%rsi
lea    0xc78(%rip),%rdi
call   1060 <fatal_error@plt>
cmpl   $0x0,-0x50(%rbp)
jl     1458 <f_ndate+0x2e8>
mov    -0x50(%rbp),%r10d
mov    -0x54(%rbp),%eax
lea    -0x34(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x44(%rbp),%r8
lea    -0x48(%rbp),%r9
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1080 <add_dt@plt>
jmp    1487 <f_ndate+0x317>
xor    %r10d,%r10d
sub    -0x50(%rbp),%r10d
mov    -0x54(%rbp),%eax
lea    -0x34(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x44(%rbp),%r8
lea    -0x48(%rbp),%r9
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <sub_dt@plt>
cmpl   $0x1,-0x5c(%rbp)
jne    14ab <f_ndate+0x33b>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xc12(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    15a4 <f_ndate+0x434>
cmpl   $0x2,-0x5c(%rbp)
jne    14d2 <f_ndate+0x362>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xbf1(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    159f <f_ndate+0x42f>
cmpl   $0x3,-0x5c(%rbp)
jne    14fd <f_ndate+0x38d>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
lea    0xbd0(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    159a <f_ndate+0x42a>
cmpl   $0x4,-0x5c(%rbp)
jne    152c <f_ndate+0x3bc>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x40(%rbp),%r9d
lea    0xbaf(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    1595 <f_ndate+0x425>
cmpl   $0x5,-0x5c(%rbp)
jne    1561 <f_ndate+0x3f1>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x40(%rbp),%r9d
mov    -0x44(%rbp),%eax
lea    0xb8f(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    1590 <f_ndate+0x420>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x40(%rbp),%r9d
mov    -0x44(%rbp),%r10d
mov    -0x48(%rbp),%eax
lea    0xb76(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    1595 <f_ndate+0x425>
jmp    159a <f_ndate+0x42a>
jmp    159f <f_ndate+0x42f>
jmp    15a4 <f_ndate+0x434>
jmp    15a9 <f_ndate+0x439>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_ndate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0xffffffff,%edi
je     1194 <f_ndate+0x24>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r8,%r14
mov    0x68(%rsp),%r15
mov    0x60(%rsp),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
movl   $0x1,0xc(%rsp)
movl   $0x1,0x14(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
lea    -0x2(%rbp),%ebx
shr    $0x1f,%ebx
lea    -0xf(%rbp),%eax
cmp    $0xfffffff5,%eax
jb     11f4 <f_ndate+0x84>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
cmp    $0x1,%ecx
jne    1207 <f_ndate+0x97>
lea    0xe19(%rip),%rdi
lea    0xf22(%rip),%rsi
call   1060 <fatal_error@plt>
lea    (%rbx,%rbp,1),%r13d
add    $0xfffffffe,%r13d
lea    0x20(%rsp),%rbx
lea    0x1c(%rsp),%r10
lea    0xe3a(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x18(%rsp),%r9
mov    %r12,%rdi
xor    %eax,%eax
push   %rbx
push   %r10
call   1070 <sscanf@plt>
add    $0x10,%rsp
lea    0xe21(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x9(%rsp),%rcx
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
movb   $0x0,0xb(%rsp)
cmp    $0x2,%eax
je     127d <f_ndate+0x10d>
lea    0xe02(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fatal_error@plt>
sar    %r13d
lea    0xe0e(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1306 <f_ndate+0x196>
lea    0xdfb(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     130d <f_ndate+0x19d>
lea    0xde8(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1320 <f_ndate+0x1b0>
lea    0xdd5(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1333 <f_ndate+0x1c3>
lea    0xdc2(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1346 <f_ndate+0x1d6>
lea    0xdaf(%rip),%rdi
lea    0x9(%rsp),%rsi
call   1060 <fatal_error@plt>
mov    $0xffffffff,%eax
jmp    1357 <f_ndate+0x1e7>
mov    $0x4,%eax
jmp    1357 <f_ndate+0x1e7>
cmp    $0x6,%ebp
mov    $0x2,%ecx
cmovge %r13d,%ecx
mov    $0x3,%eax
jmp    1354 <f_ndate+0x1e4>
cmp    $0x8,%ebp
mov    $0x3,%ecx
cmovge %r13d,%ecx
mov    $0x2,%eax
jmp    1354 <f_ndate+0x1e4>
cmp    $0xa,%ebp
mov    $0x4,%ecx
cmovge %r13d,%ecx
mov    $0x1,%eax
jmp    1354 <f_ndate+0x1e4>
cmp    $0xc,%ebp
mov    $0x5,%ecx
cmovge %r13d,%ecx
xor    %eax,%eax
mov    %ecx,%r13d
mov    0x24(%rsp),%ebx
test   %ebx,%ebx
js     1386 <f_ndate+0x216>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x20(%rsp),%r9
push   %rax
push   %rbx
call   1080 <add_dt@plt>
jmp    13ad <f_ndate+0x23d>
neg    %ebx
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x20(%rsp),%r9
push   %rax
push   %rbx
call   1050 <sub_dt@plt>
add    $0x10,%rsp
add    $0xffffffff,%r13d
cmp    $0x4,%r13d
ja     13e5 <f_ndate+0x275>
lea    0xc3e(%rip),%rax
movslq (%rax,%r13,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x10(%rsp),%edx
lea    0xcef(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    1183 <f_ndate+0x13>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
mov    0x1c(%rsp),%ebp
mov    0x20(%rsp),%ebx
lea    0xd05(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
push   %rbx
jmp    14a0 <f_ndate+0x330>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xcab(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    1183 <f_ndate+0x13>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x14(%rsp),%r8d
lea    0xc92(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    1183 <f_ndate+0x13>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
lea    0xc78(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    1183 <f_ndate+0x13>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
mov    0x1c(%rsp),%ebp
sub    $0x8,%rsp
lea    0xc5a(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
push   %rbp
call   1090 <sprintf@plt>
add    $0x10,%rsp
jmp    1183 <f_ndate+0x13>

LLVM IR (-O0):
@.str = [70 x i8] c"ndates: (YYYY|YYYYMM|YYYYMMDD|YYYYMMDDHH|YYYYMMDDHHmm|YYYYMMDDHHmmss)\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [19 x i8] c"%4d%2d%2d%2d%2d%2d\00"
@.str.3 = [6 x i8] c"%d%2s\00"
@.str.4 = [34 x i8] c"ndates: bad (int)(mn|hr|dy|mo|yr)\00"
@.str.5 = [3 x i8] c"yr\00"
@.str.6 = [3 x i8] c"mo\00"
@.str.7 = [3 x i8] c"dy\00"
@.str.8 = [3 x i8] c"hr\00"
@.str.9 = [3 x i8] c"mn\00"
@.str.10 = [33 x i8] c"ndates: unsupported time unit %s\00"
@.str.11 = [6 x i8] c"%.4d\0A\00"
@.str.12 = [10 x i8] c"%.4d%.2d\0A\00"
@.str.13 = [14 x i8] c"%.4d%.2d%.2d\0A\00"
@.str.14 = [18 x i8] c"%.4d%.2d%.2d%.2d\0A\00"
@.str.15 = [22 x i8] c"%.4d%.2d%.2d%.2d%.2d\0A\00"
@.str.16 = [26 x i8] c"%.4d%.2d%.2d%.2d%.2d%.2d\0A\00"
define i32 @f_ndate(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5, i8* %6, i8* %7) {
%9 = alloca i32
%10 = alloca i8**
%11 = alloca float*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8**
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca [3 x i8]
store i32 %0, i32* %9
store i8** %1, i8*** %10
store float* %2, float** %11
store i32 %3, i32* %12
store i8* %4, i8** %13
store i8** %5, i8*** %14
store i8* %6, i8** %15
store i8* %7, i8** %16
%29 = load i32, i32* %9
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %193
31: ; preds = %8
%32 = load i8*, i8** %15
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %26
store i32 1, i32* %18
store i32 1, i32* %19
store i32 0, i32* %22
store i32 0, i32* %21
store i32 0, i32* %20
%34 = load i32, i32* %26
%35 = sub nsw i32 %34, 2
%36 = sdiv i32 %35, 2
store i32 %36, i32* %27
%37 = load i32, i32* %26
%38 = srem i32 %37, 2
%39 = icmp eq i32 %38, 1
br i1 %39, label %46, label %40
40: ; preds = %31
%41 = load i32, i32* %26
%42 = icmp slt i32 %41, 4
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = load i32, i32* %26
%45 = icmp sgt i32 %44, 14
br i1 %45, label %46, label %48
46: ; preds = %43, %40, %31
%47 = call i32 @fatal_error(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %43
%49 = load i8*, i8** %15
%50 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %49, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32* %17, i32* %18, i32* %19, i32* %20, i32* %21, i32* %22)
%51 = load i8*, i8** %16
%52 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%53 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %24, i8* %52)
store i32 %53, i32* %23
%54 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 2
store i8 0, i8* %54
%55 = load i32, i32* %23
%56 = icmp ne i32 %55, 2
br i1 %56, label %57, label %59
57: ; preds = %48
%58 = call i32 @fatal_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %59
59: ; preds = %57, %48
store i32 -1, i32* %25
%60 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %59
store i32 4, i32* %25
br label %116
64: ; preds = %59
%65 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %76
68: ; preds = %64
store i32 3, i32* %25
%69 = load i32, i32* %27
%70 = icmp sge i32 %69, 2
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = load i32, i32* %27
br label %74
73: ; preds = %68
br label %74
74: ; preds = %73, %71
%75 = phi i32 [ %72, %71 ], [ 2, %73 ]
store i32 %75, i32* %27
br label %115
76: ; preds = %64
%77 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %88
80: ; preds = %76
store i32 2, i32* %25
%81 = load i32, i32* %27
%82 = icmp sge i32 %81, 3
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = load i32, i32* %27
br label %86
85: ; preds = %80
br label %86
86: ; preds = %85, %83
%87 = phi i32 [ %84, %83 ], [ 3, %85 ]
store i32 %87, i32* %27
br label %114
88: ; preds = %76
%89 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %100
92: ; preds = %88
store i32 1, i32* %25
%93 = load i32, i32* %27
%94 = icmp sge i32 %93, 4
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = load i32, i32* %27
br label %98
97: ; preds = %92
br label %98
98: ; preds = %97, %95
%99 = phi i32 [ %96, %95 ], [ 4, %97 ]
store i32 %99, i32* %27
br label %113
100: ; preds = %88
%101 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %112
104: ; preds = %100
store i32 0, i32* %25
%105 = load i32, i32* %27
%106 = icmp sge i32 %105, 5
br i1 %106, label %107, label %109
107: ; preds = %104
%108 = load i32, i32* %27
br label %110
109: ; preds = %104
br label %110
110: ; preds = %109, %107
%111 = phi i32 [ %108, %107 ], [ 5, %109 ]
store i32 %111, i32* %27
br label %112
112: ; preds = %110, %100
br label %113
113: ; preds = %112, %98
br label %114
114: ; preds = %113, %86
br label %115
115: ; preds = %114, %74
br label %116
116: ; preds = %115, %63
%117 = load i32, i32* %25
%118 = icmp eq i32 %117, -1
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = getelementptr inbounds [3 x i8], [3 x i8]* %28, i64 0, i64 0
%121 = call i32 @fatal_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %120)
br label %122
122: ; preds = %119, %116
%123 = load i32, i32* %24
%124 = icmp sge i32 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %122
%126 = load i32, i32* %24
%127 = load i32, i32* %25
%128 = call i32 @add_dt(i32* %17, i32* %18, i32* %19, i32* %20, i32* %21, i32* %22, i32 %126, i32 %127)
br label %134
129: ; preds = %122
%130 = load i32, i32* %24
%131 = sub nsw i32 0, %130
%132 = load i32, i32* %25
%133 = call i32 @sub_dt(i32* %17, i32* %18, i32* %19, i32* %20, i32* %21, i32* %22, i32 %131, i32 %132)
br label %134
134: ; preds = %129, %125
%135 = load i32, i32* %27
%136 = icmp eq i32 %135, 1
br i1 %136, label %137, label %141
137: ; preds = %134
%138 = load i8*, i8** %13
%139 = load i32, i32* %17
%140 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %138, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %139)
br label %192
141: ; preds = %134
%142 = load i32, i32* %27
%143 = icmp eq i32 %142, 2
br i1 %143, label %144, label %149
144: ; preds = %141
%145 = load i8*, i8** %13
%146 = load i32, i32* %17
%147 = load i32, i32* %18
%148 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %145, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %146, i32 %147)
br label %191
149: ; preds = %141
%150 = load i32, i32* %27
%151 = icmp eq i32 %150, 3
br i1 %151, label %152, label %158
152: ; preds = %149
%153 = load i8*, i8** %13
%154 = load i32, i32* %17
%155 = load i32, i32* %18
%156 = load i32, i32* %19
%157 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %153, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 %154, i32 %155, i32 %156)
br label %190
158: ; preds = %149
%159 = load i32, i32* %27
%160 = icmp eq i32 %159, 4
br i1 %160, label %161, label %168
161: ; preds = %158
%162 = load i8*, i8** %13
%163 = load i32, i32* %17
%164 = load i32, i32* %18
%165 = load i32, i32* %19
%166 = load i32, i32* %20
%167 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %162, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %163, i32 %164, i32 %165, i32 %166)
br label %189
168: ; preds = %158
%169 = load i32, i32* %27
%170 = icmp eq i32 %169, 5
br i1 %170, label %171, label %179
171: ; preds = %168
%172 = load i8*, i8** %13
%173 = load i32, i32* %17
%174 = load i32, i32* %18
%175 = load i32, i32* %19
%176 = load i32, i32* %20
%177 = load i32, i32* %21
%178 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %172, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), i32 %173, i32 %174, i32 %175, i32 %176, i32 %177)
br label %188
179: ; preds = %168
%180 = load i8*, i8** %13
%181 = load i32, i32* %17
%182 = load i32, i32* %18
%183 = load i32, i32* %19
%184 = load i32, i32* %20
%185 = load i32, i32* %21
%186 = load i32, i32* %22
%187 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %180, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.16, i64 0, i64 0), i32 %181, i32 %182, i32 %183, i32 %184, i32 %185, i32 %186)
br label %188
188: ; preds = %179, %171
br label %189
189: ; preds = %188, %161
br label %190
190: ; preds = %189, %152
br label %191
191: ; preds = %190, %144
br label %192
192: ; preds = %191, %137
br label %193
193: ; preds = %192, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [70 x i8] c"ndates: (YYYY|YYYYMM|YYYYMMDD|YYYYMMDDHH|YYYYMMDDHHmm|YYYYMMDDHHmmss)\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [19 x i8] c"%4d%2d%2d%2d%2d%2d\00"
@.str.3 = [6 x i8] c"%d%2s\00"
@.str.4 = [34 x i8] c"ndates: bad (int)(mn|hr|dy|mo|yr)\00"
@.str.5 = [3 x i8] c"yr\00"
@.str.6 = [3 x i8] c"mo\00"
@.str.7 = [3 x i8] c"dy\00"
@.str.8 = [3 x i8] c"hr\00"
@.str.9 = [3 x i8] c"mn\00"
@.str.10 = [33 x i8] c"ndates: unsupported time unit %s\00"
@.str.11 = [6 x i8] c"%.4d\0A\00"
@.str.12 = [10 x i8] c"%.4d%.2d\0A\00"
@.str.13 = [14 x i8] c"%.4d%.2d%.2d\0A\00"
@.str.14 = [18 x i8] c"%.4d%.2d%.2d%.2d\0A\00"
@.str.15 = [22 x i8] c"%.4d%.2d%.2d%.2d%.2d\0A\00"
@.str.16 = [26 x i8] c"%.4d%.2d%.2d%.2d%.2d%.2d\0A\00"
define i32 @f_ndate(i32 %0, i8** nocapture readnone %1, float* nocapture readnone %2, i32 %3, i8* nocapture writeonly %4, i8** nocapture readnone %5, i8* %6, i8* nocapture %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [3 x i8]
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = bitcast i32* %11 to i8*
%20 = bitcast i32* %12 to i8*
%21 = bitcast i32* %13 to i8*
%22 = bitcast i32* %14 to i8*
%23 = bitcast i32* %15 to i8*
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 0
%25 = icmp eq i32 %0, -1
br i1 %25, label %26, label %117
26: ; preds = %8
%27 = tail call i32 @strlen(i8* %6)
store i32 1, i32* %10
store i32 1, i32* %11
store i32 0, i32* %14
store i32 0, i32* %13
store i32 0, i32* %12
%28 = add nsw i32 %27, -2
%29 = sdiv i32 %28, 2
%30 = srem i32 %27, 2
%31 = icmp eq i32 %30, 1
%32 = add i32 %27, -15
%33 = icmp ult i32 %32, -11
%34 = or i1 %33, %31
br i1 %34, label %35, label %37
35: ; preds = %26
%36 = tail call i32 @fatal_error(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %26, %35
%38 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14)
%39 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %15, i8* %24)
%40 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 2
store i8 0, i8* %40
%41 = icmp eq i32 %39, 2
br i1 %41, label %44, label %42
42: ; preds = %37
%43 = call i32 @fatal_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
%45 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %73, label %47
47: ; preds = %44
%48 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = icmp sgt i32 %27, 5
%52 = select i1 %51, i32 %29, i32 2
br label %73
53: ; preds = %47
%54 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = icmp sgt i32 %27, 7
%58 = select i1 %57, i32 %29, i32 3
br label %73
59: ; preds = %53
%60 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = icmp sgt i32 %27, 9
%64 = select i1 %63, i32 %29, i32 4
br label %73
65: ; preds = %59
%66 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = icmp sgt i32 %27, 11
%70 = select i1 %69, i32 %29, i32 5
br label %73
71: ; preds = %65
%72 = call i32 @fatal_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %24)
br label %73
73: ; preds = %44, %56, %68, %62, %50, %71
%74 = phi i32 [ %29, %71 ], [ %29, %44 ], [ %58, %56 ], [ %70, %68 ], [ %64, %62 ], [ %52, %50 ]
%75 = phi i32 [ -1, %71 ], [ 4, %44 ], [ 2, %56 ], [ 0, %68 ], [ 1, %62 ], [ 3, %50 ]
%76 = load i32, i32* %15
%77 = icmp sgt i32 %76, -1
br i1 %77, label %78, label %80
78: ; preds = %73
%79 = call i32 @add_dt(i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32 %76, i32 %75)
br label %83
80: ; preds = %73
%81 = sub nsw i32 0, %76
%82 = call i32 @sub_dt(i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32 %81, i32 %75)
br label %83
83: ; preds = %80, %78
switch i32 %74, label %109 [
i32 1, label %84
i32 2, label %87
i32 3, label %91
i32 4, label %96
i32 5, label %102
]
84: ; preds = %83
%85 = load i32, i32* %9
%86 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %85)
br label %117
87: ; preds = %83
%88 = load i32, i32* %9
%89 = load i32, i32* %10
%90 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %88, i32 %89)
br label %117
91: ; preds = %83
%92 = load i32, i32* %9
%93 = load i32, i32* %10
%94 = load i32, i32* %11
%95 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 %92, i32 %93, i32 %94)
br label %117
96: ; preds = %83
%97 = load i32, i32* %9
%98 = load i32, i32* %10
%99 = load i32, i32* %11
%100 = load i32, i32* %12
%101 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %97, i32 %98, i32 %99, i32 %100)
br label %117
102: ; preds = %83
%103 = load i32, i32* %9
%104 = load i32, i32* %10
%105 = load i32, i32* %11
%106 = load i32, i32* %12
%107 = load i32, i32* %13
%108 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), i32 %103, i32 %104, i32 %105, i32 %106, i32 %107)
br label %117
109: ; preds = %83
%110 = load i32, i32* %9
%111 = load i32, i32* %10
%112 = load i32, i32* %11
%113 = load i32, i32* %12
%114 = load i32, i32* %13
%115 = load i32, i32* %14
%116 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.16, i64 0, i64 0), i32 %110, i32 %111, i32 %112, i32 %113, i32 %114, i32 %115)
br label %117
117: ; preds = %84, %91, %102, %109, %96, %87, %8
ret i32 0
}