#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *, char *, char *, double *);
void get_next_tle_time(FILE *fpin, int *this_year, int *this_day,
                       int *this_msec, char *line1, char *line2) {
  int max = 256;
  int line_no = 0;
  char tmp1[7];
  char tmp2[7];
  double full_time;
  long msec_per_day = 24 * 60 * 60 * 1000;
  if (fgets(line1, max, fpin) == NULL) {
    printf("ERROR:bad get from tle file\n");
    exit(1);
  }
  if (line1[0] != '1') {
    printf("ERROR:bad get from tle file\n");
    exit(1);
  }
  if (fgets(line2, max, fpin) == NULL) {
    printf("ERROR:bad get from tle file\n");
    exit(1);
  }
  if (line2[0] != '2') {
    printf("ERROR:bad get from tle file\n");
    exit(1);
  }
  sscanf(line1, "%1i %s %s %lf", &line_no, tmp1, tmp2, &full_time);
  *this_year = (int)full_time / 1000;
  *this_day = (int)(full_time - (*this_year * 1000));
  *this_msec =
      (int)((full_time - (*this_year * 1000) - *this_day) * msec_per_day);
  *this_year = *this_year + 1900;
}


x86 assembly (clang, -O0):
<get_next_tle_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x100,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movq   $0x5265c00,-0x58(%rbp)
05
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11a6 <get_next_tle_time+0x66>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
je     11cc <get_next_tle_time+0x8c>
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11fc <get_next_tle_time+0xbc>
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
je     1222 <get_next_tle_time+0xe2>
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    -0x3f(%rbp),%rcx
lea    -0x46(%rbp),%r8
lea    0xde8(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x50(%rbp),%r9
call   1050 <sscanf@plt>
cvttsd2si -0x50(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3e8,(%rax),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3e8,(%rax),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
subsd  %xmm1,%xmm0
cvtsi2sdq -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x76c,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_tle_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r13
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbp
movl   $0x0,0xc(%rsp)
mov    %r8,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1253 <get_next_tle_time+0x113>
cmpb   $0x31,(%rbx)
jne    1253 <get_next_tle_time+0x113>
mov    %r13,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1253 <get_next_tle_time+0x113>
cmpb   $0x32,0x0(%r13)
jne    1253 <get_next_tle_time+0x113>
lea    0xe53(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x21(%rsp),%rcx
lea    0x1a(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rbx,%rdi
call   1050 <sscanf@plt>
movsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%ecx
cvtsi2sd %ecx,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
cvttsd2si %xmm2,%ecx
mov    %eax,(%r12)
mov    %ecx,(%r15)
imul   $0x3e8,(%r12),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
cvttpd2dq %xmm2,%xmm2
subsd  %xmm1,%xmm0
cvtdq2pd %xmm2,%xmm1
subsd  %xmm1,%xmm0
mulsd  0xdcb(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%r14)
addl   $0x76c,(%r12)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdbc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"ERROR:bad get from tle file\0A\00"
@.str.1 = [14 x i8] c"%1i %s %s %lf\00"
define void @get_next_tle_time(i32* %0, i32* %1, i32* %2, i32* %3, i8* %4, i8* %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca [7 x i8]
%16 = alloca [7 x i8]
%17 = alloca double
%18 = alloca i64
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
store i32 256, i32* %13
store i32 0, i32* %14
store i64 86400000, i64* %18
%19 = load i8*, i8** %11
%20 = load i32, i32* %13
%21 = load i32*, i32** %7
%22 = call i32* @fgets(i8* %19, i32 %20, i32* %21)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %6
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %6
%28 = load i8*, i8** %11
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 49
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %27
%37 = load i8*, i8** %12
%38 = load i32, i32* %13
%39 = load i32*, i32** %7
%40 = call i32* @fgets(i8* %37, i32 %38, i32* %39)
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %36
%46 = load i8*, i8** %12
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 50
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %45
%55 = load i8*, i8** %11
%56 = getelementptr inbounds [7 x i8], [7 x i8]* %15, i64 0, i64 0
%57 = getelementptr inbounds [7 x i8], [7 x i8]* %16, i64 0, i64 0
%58 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %14, i8* %56, i8* %57, double* %17)
%59 = load double, double* %17
%60 = fptosi double %59 to i32
%61 = sdiv i32 %60, 1000
%62 = load i32*, i32** %8
store i32 %61, i32* %62
%63 = load double, double* %17
%64 = load i32*, i32** %8
%65 = load i32, i32* %64
%66 = mul nsw i32 %65, 1000
%67 = sitofp i32 %66 to double
%68 = fsub double %63, %67
%69 = fptosi double %68 to i32
%70 = load i32*, i32** %9
store i32 %69, i32* %70
%71 = load double, double* %17
%72 = load i32*, i32** %8
%73 = load i32, i32* %72
%74 = mul nsw i32 %73, 1000
%75 = sitofp i32 %74 to double
%76 = fsub double %71, %75
%77 = load i32*, i32** %9
%78 = load i32, i32* %77
%79 = sitofp i32 %78 to double
%80 = fsub double %76, %79
%81 = load i64, i64* %18
%82 = sitofp i64 %81 to double
%83 = fmul double %80, %82
%84 = fptosi double %83 to i32
%85 = load i32*, i32** %10
store i32 %84, i32* %85
%86 = load i32*, i32** %8
%87 = load i32, i32* %86
%88 = add nsw i32 %87, 1900
%89 = load i32*, i32** %8
store i32 %88, i32* %89
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"%1i %s %s %lf\00"
@str.4 = [28 x i8] c"ERROR:bad get from tle file\00"
define void @get_next_tle_time(i32* nocapture %0, i32* nocapture %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca [7 x i8]
%9 = alloca [7 x i8]
%10 = alloca double
%11 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%14 = bitcast double* %10 to i8*
%15 = tail call i32* @fgets(i8* %4, i32 256, i32* %0)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %6
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %6
%21 = load i8, i8* %4
%22 = icmp eq i8 %21, 49
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %20
%27 = tail call i32* @fgets(i8* %5, i32 256, i32* %0)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %26
%33 = load i8, i8* %5
%34 = icmp eq i8 %33, 50
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %32
%39 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %7, i8* %12, i8* %13, double* %10)
%40 = load double, double* %10
%41 = fptosi double %40 to i32
%42 = sdiv i32 %41, 1000
store i32 %42, i32* %1
%43 = mul nsw i32 %42, 1000
%44 = sitofp i32 %43 to double
%45 = fsub double %40, %44
%46 = fptosi double %45 to i32
store i32 %46, i32* %2
%47 = load i32, i32* %1
%48 = mul nsw i32 %47, 1000
%49 = sitofp i32 %48 to double
%50 = fsub double %40, %49
%51 = sitofp i32 %46 to double
%52 = fsub double %50, %51
%53 = fmul double %52, 8.640000e+07
%54 = fptosi double %53 to i32
store i32 %54, i32* %3
%55 = load i32, i32* %1
%56 = add nsw i32 %55, 1900
store i32 %56, i32* %1
ret void
}