#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*/ calendar_date(int, int *, int *, int *);
int /*<<< orphan*/ check_it(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, ...);
double get_csv_val_r(int, int);
int /*<<< orphan*/ load_csv_line(int);
int /*<<< orphan*/ stderr;
void find_day(int csv, int time_idx, int jday) {
  int y, m, d;
  double tr;
  if (!check_it(csv, time_idx)) {
    fprintf(stderr, "Fatal error in find_day: file %d index %d\n", csv,
            time_idx);
    exit(1);
  }
  while ((tr = get_csv_val_r(csv, time_idx)) < jday) {
    if (!load_csv_line(csv)) {
      calendar_date(jday, &y, &m, &d);
      fprintf(stderr, "Day %d (%d-%02d-%02d) not found\n", jday, y, m, d);
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<find_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <check_it@plt>
cmp    $0x0,%eax
jne    11ac <find_day+0x4c>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11b1 <find_day+0x51>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <get_csv_val_r@plt>
movaps %xmm0,%xmm1
movsd  %xmm1,-0x20(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122c <find_day+0xcc>
mov    -0x4(%rbp),%edi
call   1050 <load_csv_line@plt>
cmp    $0x0,%eax
jne    1227 <find_day+0xc7>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1070 <calendar_date@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11b1 <find_day+0x51>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_day>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <check_it@plt>
test   %eax,%eax
je     1202 <find_day+0xa2>
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <get_csv_val_r@plt>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11f9 <find_day+0x99>
mov    %ebx,%edi
call   1050 <load_csv_line@plt>
test   %eax,%eax
jne    1190 <find_day+0x30>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r14d,%edi
call   1070 <calendar_date@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0xc(%rsp),%r9d
lea    0xe46(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Fatal error in find_day: file %d index %d\0A\00"
@.str.1 = [33 x i8] c"Day %d (%d-%02d-%02d) not found\0A\00"
define void @find_day(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @check_it(i32 %11, i32 %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %3
br label %22
22: ; preds = %43, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call double @get_csv_val_r(i32 %23, i32 %24)
store double %25, double* %10
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = fcmp olt double %25, %27
br i1 %28, label %29, label %44
29: ; preds = %22
%30 = load i32, i32* %4
%31 = call i32 @load_csv_line(i32 %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %43, label %33
33: ; preds = %29
%34 = load i32, i32* %6
%35 = call i32 @calendar_date(i32 %34, i32* %7, i32* %8, i32* %9)
%36 = load i32, i32* @stderr
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %29
br label %22
44: ; preds = %22
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Fatal error in find_day: file %d index %d\0A\00"
@.str.1 = [33 x i8] c"Day %d (%d-%02d-%02d) not found\0A\00"
define void @find_day(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = tail call i32 @check_it(i32 %0, i32 %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = sitofp i32 %2 to double
br label %18
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %12, %21
%19 = tail call double @get_csv_val_r(i32 %0, i32 %1)
%20 = fcmp olt double %19, %13
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = tail call i32 @load_csv_line(i32 %0)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %18
24: ; preds = %21
%25 = call i32 @calendar_date(i32 %2, i32* %4, i32* %5, i32* %6)
%26 = load i32, i32* @stderr
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %27, i32 %28, i32 %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %18
ret void
}