#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 */
struct RawIndex {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int RawFseek(int /*<<< orphan*/ *, int, int, int, int, int, int, double *,
             struct RawIndex *);
struct RawIndex *RawIndexFload(int /*<<< orphan*/ *);
int /*<<< orphan*/ RawIndexFree(struct RawIndex *);
int /*<<< orphan*/ TimeEpochToYMDHMS(double, int *, int *, int *, int *, int *,
                                     double *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *fp;
  struct RawIndex *inx = NULL;
  int yr = 2003, mo = 5, dy = 28, hr = 6, mt = 0;
  double sc = 0, atme;
  int s;
  if (argc > 2) {
    fp = fopen(argv[2], "r");
    if (fp == NULL) {
      fprintf(stderr, "Index not found.\n");
      exit(-1);
    }
    inx = RawIndexFload(fp);
    fclose(fp);
    if (inx == NULL) {
      fprintf(stderr, "Error loading index.\n");
      exit(-1);
    }
  }
  fp = fopen(argv[1], "r");
  if (fp == NULL) {
    fprintf(stderr, "File not found.\n");
    exit(-1);
  }
  s = RawFseek(fp, yr, mo, dy, hr, mt, (int)sc, &atme, inx);
  if (s == -1) {
    fprintf(stderr, "file does not contain that interval.\n");
    exit(-1);
  }
  fprintf(stdout, "Requested:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr, mo, dy, hr,
          mt, (int)sc);
  TimeEpochToYMDHMS(atme, &yr, &mo, &dy, &hr, &mt, &sc);
  fprintf(stdout, "Found:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr, mo, dy, hr, mt,
          (int)sc);
  fclose(fp);
  if (inx != NULL)
    RawIndexFree(inx);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x7d3,-0x24(%rbp)
movl   $0x5,-0x28(%rbp)
movl   $0x1c,-0x2c(%rbp)
movl   $0x6,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    125e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe1e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1217 <main+0x97>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <RawIndexFload@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1259 <main+0xd9>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
jmp    125e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd93(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a2 <main+0x122>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x34(%rbp),%r9d
cvttsd2si -0x40(%rbp),%r11d
mov    -0x20(%rbp),%rax
lea    -0x48(%rbp),%r10
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <RawFseek@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0xffffffff,-0x4c(%rbp)
jne    1306 <main+0x186>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
lea    0xd46(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x34(%rbp),%r10d
cvttsd2si -0x40(%rbp),%eax
lea    0xd34(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
movsd  -0x48(%rbp),%xmm0
lea    -0x24(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x40(%rbp),%r9
call   1050 <TimeEpochToYMDHMS@plt>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x34(%rbp),%r10d
cvttsd2si -0x40(%rbp),%eax
lea    0xd05(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     13b1 <main+0x231>
mov    -0x20(%rbp),%rdi
call   1080 <RawIndexFree@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
movl   $0x7d3,0x14(%rsp)
movl   $0x5,0x10(%rsp)
movl   $0x1c,0xc(%rsp)
movl   $0x6,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movq   $0x0,0x18(%rsp)
cmp    $0x3,%edi
jl     120d <main+0x8d>
mov    0x10(%r15),%rdi
lea    0xe31(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1342 <main+0x1c2>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <RawIndexFload@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <fclose@plt>
test   %r14,%r14
jne    1210 <main+0x90>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
jmp    1352 <main+0x1d2>
xor    %r14d,%r14d
mov    0x8(%r15),%rdi
lea    0xde5(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     131e <main+0x19e>
mov    %rax,%r12
sub    $0x8,%rsp
lea    0x28(%rsp),%rax
mov    %r12,%rdi
mov    $0x7d3,%esi
mov    $0x5,%edx
mov    $0x1c,%ecx
mov    $0x6,%r8d
xor    %r9d,%r9d
push   %r14
push   %rax
push   $0x0
call   1030 <RawFseek@plt>
add    $0x20,%rsp
cmp    $0xffffffff,%eax
je     1330 <main+0x1b0>
mov    0x2d6a(%rip),%r15
mov    (%r15),%edi
lea    0xde9(%rip),%rsi
mov    $0x7d3,%edx
mov    $0x5,%ecx
mov    $0x1c,%r8d
mov    $0x6,%r9d
xor    %eax,%eax
push   $0x0
push   $0x0
call   1070 <fprintf@plt>
add    $0x10,%rsp
movsd  0x20(%rsp),%xmm0
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0x18(%rsp),%r9
call   1050 <TimeEpochToYMDHMS@plt>
mov    (%r15),%edi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x8(%rsp),%r9d
mov    0x4(%rsp),%r10d
cvttsd2si 0x18(%rsp),%ebx
lea    0xd9d(%rip),%rsi
xor    %eax,%eax
push   %rbx
push   %r10
call   1070 <fprintf@plt>
add    $0x10,%rsp
mov    %r12,%rdi
call   1060 <fclose@plt>
test   %r14,%r14
je     1310 <main+0x190>
mov    %r14,%rdi
call   1080 <RawIndexFree@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
lea    0xcfc(%rip),%rsi
jmp    1352 <main+0x1d2>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
jmp    1352 <main+0x1d2>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xcb0(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.RawIndex = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Index not found.\0A\00"
@.str.2 = [22 x i8] c"Error loading index.\0A\00"
@.str.3 = [17 x i8] c"File not found.\0A\00"
@.str.4 = [38 x i8] c"file does not contain that interval.\0A\00"
@stdout = global i32 0
@.str.5 = [41 x i8] c"Requested:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\0A\00"
@.str.6 = [37 x i8] c"Found:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.RawIndex*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.RawIndex* null, %struct.RawIndex** %7
store i32 2003, i32* %8
store i32 5, i32* %9
store i32 28, i32* %10
store i32 6, i32* %11
store i32 0, i32* %12
store double 0.000000e+00, double* %13
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %41
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %18
%30 = load i32*, i32** %6
%31 = call %struct.RawIndex* @RawIndexFload(i32* %30)
store %struct.RawIndex* %31, %struct.RawIndex** %7
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
%34 = load %struct.RawIndex*, %struct.RawIndex** %7
%35 = icmp eq %struct.RawIndex* %34, null
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %29
br label %41
41: ; preds = %40, %2
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %45, i32** %6
%46 = load i32*, i32** %6
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %52
48: ; preds = %41
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %41
%53 = load i32*, i32** %6
%54 = load i32, i32* %8
%55 = load i32, i32* %9
%56 = load i32, i32* %10
%57 = load i32, i32* %11
%58 = load i32, i32* %12
%59 = load double, double* %13
%60 = fptosi double %59 to i32
%61 = load %struct.RawIndex*, %struct.RawIndex** %7
%62 = call i32 @RawFseek(i32* %53, i32 %54, i32 %55, i32 %56, i32 %57, i32 %58, i32 %60, double* %14, %struct.RawIndex* %61)
store i32 %62, i32* %15
%63 = load i32, i32* %15
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %69
65: ; preds = %52
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%68 = call i32 @exit(i32 -1)
unreachable
69: ; preds = %52
%70 = load i32, i32* @stdout
%71 = load i32, i32* %8
%72 = load i32, i32* %9
%73 = load i32, i32* %10
%74 = load i32, i32* %11
%75 = load i32, i32* %12
%76 = load double, double* %13
%77 = fptosi double %76 to i32
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %71, i32 %72, i32 %73, i32 %74, i32 %75, i32 %77)
%79 = load double, double* %14
%80 = call i32 @TimeEpochToYMDHMS(double %79, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, double* %13)
%81 = load i32, i32* @stdout
%82 = load i32, i32* %8
%83 = load i32, i32* %9
%84 = load i32, i32* %10
%85 = load i32, i32* %11
%86 = load i32, i32* %12
%87 = load double, double* %13
%88 = fptosi double %87 to i32
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %82, i32 %83, i32 %84, i32 %85, i32 %86, i32 %88)
%90 = load i32*, i32** %6
%91 = call i32 @fclose(i32* %90)
%92 = load %struct.RawIndex*, %struct.RawIndex** %7
%93 = icmp ne %struct.RawIndex* %92, null
br i1 %93, label %94, label %97
94: ; preds = %69
%95 = load %struct.RawIndex*, %struct.RawIndex** %7
%96 = call i32 @RawIndexFree(%struct.RawIndex* %95)
br label %97
97: ; preds = %94, %69
ret i32 0
}

LLVM IR (-O2):
%struct.RawIndex = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Index not found.\0A\00"
@.str.2 = [22 x i8] c"Error loading index.\0A\00"
@.str.3 = [17 x i8] c"File not found.\0A\00"
@.str.4 = [38 x i8] c"file does not contain that interval.\0A\00"
@stdout = global i32 0
@.str.5 = [41 x i8] c"Requested:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\0A\00"
@.str.6 = [37 x i8] c"Found:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = bitcast i32* %3 to i8*
store i32 2003, i32* %3
%11 = bitcast i32* %4 to i8*
store i32 5, i32* %4
%12 = bitcast i32* %5 to i8*
store i32 28, i32* %5
%13 = bitcast i32* %6 to i8*
store i32 6, i32* %6
%14 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%15 = bitcast double* %8 to i8*
store double 0.000000e+00, double* %8
%16 = bitcast double* %9 to i8*
%17 = icmp sgt i32 %0, 2
br i1 %17, label %18, label %35
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %18
%28 = tail call %struct.RawIndex* @RawIndexFload(i32* %21)
%29 = tail call i32 @fclose(i32* %21)
%30 = icmp eq %struct.RawIndex* %28, null
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%34 = tail call i32 @exit(i32 -1)
unreachable
35: ; preds = %27, %2
%36 = phi %struct.RawIndex* [ %28, %27 ], [ null, %2 ]
%37 = getelementptr inbounds i8*, i8** %1, i64 1
%38 = load i8*, i8** %37
%39 = tail call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%44 = tail call i32 @exit(i32 -1)
unreachable
45: ; preds = %35
%46 = call i32 @RawFseek(i32* %39, i32 2003, i32 5, i32 28, i32 6, i32 0, i32 0, double* %9, %struct.RawIndex* %36)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %45
%53 = load i32, i32* @stdout
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 2003, i32 5, i32 28, i32 6, i32 0, i32 0)
%55 = load double, double* %9
%56 = call i32 @TimeEpochToYMDHMS(double %55, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, double* %8)
%57 = load i32, i32* @stdout
%58 = load i32, i32* %3
%59 = load i32, i32* %4
%60 = load i32, i32* %5
%61 = load i32, i32* %6
%62 = load i32, i32* %7
%63 = load double, double* %8
%64 = fptosi double %63 to i32
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %58, i32 %59, i32 %60, i32 %61, i32 %62, i32 %64)
%66 = call i32 @fclose(i32* %39)
%67 = icmp eq %struct.RawIndex* %36, null
br i1 %67, label %70, label %68
68: ; preds = %52
%69 = call i32 @RawIndexFree(%struct.RawIndex* %36)
br label %70
70: ; preds = %68, %52
ret i32 0
}