#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 */
scalar_t__ date2sec(int, int, int, int /*<<< orphan*/, int /*<<< orphan*/,
                    int /*<<< orphan*/);
int fabs(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *, int *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int is_outdatefile(char *filename, int year, int mon, int day, int thr_day) {
  int pos = 12;
  char *p1 = filename;
  char datebuf[9];
  int year_log, mon_log, day_log;
  int secs_log, secs;
  int thr_sec;
  int diff;
  memset(datebuf, 0, 9);
  thr_sec = thr_day * (3600 * 24);
  thr_sec = ((thr_sec >= 0) ? thr_sec : 0);
  while (*p1)
    p1++;
  while (pos) {
    pos--;
    p1--;
  }
  strncpy(datebuf, p1, 8);
  datebuf[8] = '\0';
  sscanf(datebuf, "%4d%2d%2d", &year_log, &mon_log, &day_log);
  secs_log = (int)date2sec(year_log, mon_log, day_log, 0, 0, 0);
  secs = (int)date2sec(year, mon, day, 0, 0, 0);
  diff = fabs(secs_log - secs);
  if (diff >= thr_sec)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<is_outdatefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0xc,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x39(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1040 <memset@plt>
imul   $0x15180,-0x20(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jl     11a7 <is_outdatefile+0x57>
mov    -0x54(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    11b1 <is_outdatefile+0x61>
xor    %eax,%eax
mov    %eax,-0x5c(%rbp)
jmp    11b1 <is_outdatefile+0x61>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d5 <is_outdatefile+0x85>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11b7 <is_outdatefile+0x67>
jmp    11da <is_outdatefile+0x8a>
cmpl   $0x0,-0x24(%rbp)
je     11fe <is_outdatefile+0xae>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    11da <is_outdatefile+0x8a>
lea    -0x39(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x31(%rbp)
lea    -0x39(%rbp),%rdi
lea    0xde1(%rip),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1060 <sscanf@plt>
mov    -0x40(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
call   1070 <date2sec@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
call   1070 <date2sec@plt>
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%edi
sub    -0x50(%rbp),%edi
call   1050 <fabs@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jl     128a <is_outdatefile+0x13a>
movl   $0x1,-0x4(%rbp)
jmp    1291 <is_outdatefile+0x141>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_outdatefile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0xf(%rsp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1040 <memset@plt>
add    $0xfffffffffffffff3,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x0,0xd(%rbp)
lea    0x1(%rbp),%rbp
jne    1190 <is_outdatefile+0x40>
imul   $0x15180,%ebx,%r13d
xor    %eax,%eax
test   %ebx,%ebx
cmovs  %eax,%r13d
lea    0xf(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x17(%rsp)
lea    0xe36(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
call   1060 <sscanf@plt>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <date2sec@plt>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r14d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <date2sec@plt>
sub    %eax,%ebx
mov    %ebx,%edi
call   1050 <fabs@plt>
xor    %ecx,%ecx
cmp    %r13d,%eax
setge  %cl
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%4d%2d%2d\00"
define i32 @is_outdatefile(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca [9 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 12, i32* %12
%22 = load i8*, i8** %7
store i8* %22, i8** %13
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 9)
%25 = load i32, i32* %11
%26 = mul nsw i32 %25, 86400
store i32 %26, i32* %20
%27 = load i32, i32* %20
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %5
%30 = load i32, i32* %20
br label %32
31: ; preds = %5
br label %32
32: ; preds = %31, %29
%33 = phi i32 [ %30, %29 ], [ 0, %31 ]
store i32 %33, i32* %20
br label %34
34: ; preds = %38, %32
%35 = load i8*, i8** %13
%36 = load i8, i8* %35
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %13
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %13
br label %34
41: ; preds = %34
br label %42
42: ; preds = %45, %41
%43 = load i32, i32* %12
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* %12
%47 = add nsw i32 %46, -1
store i32 %47, i32* %12
%48 = load i8*, i8** %13
%49 = getelementptr inbounds i8, i8* %48, i32 -1
store i8* %49, i8** %13
br label %42
50: ; preds = %42
%51 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%52 = load i8*, i8** %13
%53 = call i32 @strncpy(i8* %51, i8* %52, i32 8)
%54 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 8
store i8 0, i8* %54
%55 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 0, i64 0
%56 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %15, i32* %16, i32* %17)
%57 = load i32, i32* %15
%58 = load i32, i32* %16
%59 = load i32, i32* %17
%60 = call i64 @date2sec(i32 %57, i32 %58, i32 %59, i32 0, i32 0, i32 0)
%61 = trunc i64 %60 to i32
store i32 %61, i32* %18
%62 = load i32, i32* %8
%63 = load i32, i32* %9
%64 = load i32, i32* %10
%65 = call i64 @date2sec(i32 %62, i32 %63, i32 %64, i32 0, i32 0, i32 0)
%66 = trunc i64 %65 to i32
store i32 %66, i32* %19
%67 = load i32, i32* %18
%68 = load i32, i32* %19
%69 = sub nsw i32 %67, %68
%70 = call i32 @fabs(i32 %69)
store i32 %70, i32* %21
%71 = load i32, i32* %21
%72 = load i32, i32* %20
%73 = icmp sge i32 %71, %72
br i1 %73, label %74, label %75
74: ; preds = %50
store i32 1, i32* %6
br label %76
75: ; preds = %50
store i32 0, i32* %6
br label %76
76: ; preds = %75, %74
%77 = load i32, i32* %6
ret i32 %77
}

LLVM IR (-O2):
@.str = [10 x i8] c"%4d%2d%2d\00"
define i32 @is_outdatefile(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [9 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%11 = bitcast i32* %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = call i32 @memset(i8* %10, i32 0, i32 9)
br label %15
15: ; preds = %15, %5
%16 = phi i8* [ %0, %5 ], [ %19, %15 ]
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = getelementptr inbounds i8, i8* %16, i64 1
br i1 %18, label %20, label %15
20: ; preds = %15
%21 = getelementptr i8, i8* %16, i64 -12
%22 = icmp slt i32 %4, 0
%23 = mul nsw i32 %4, 86400
%24 = select i1 %22, i32 0, i32 %23
%25 = call i32 @strncpy(i8* %10, i8* %21, i32 8)
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 8
store i8 0, i8* %26
%27 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = call i64 @date2sec(i32 %28, i32 %29, i32 %30, i32 0, i32 0, i32 0)
%32 = trunc i64 %31 to i32
%33 = call i64 @date2sec(i32 %1, i32 %2, i32 %3, i32 0, i32 0, i32 0)
%34 = trunc i64 %33 to i32
%35 = sub nsw i32 %32, %34
%36 = call i32 @fabs(i32 %35)
%37 = icmp sge i32 %36, %24
%38 = zext i1 %37 to i32
ret i32 %38
}