; LLVM IR from pms67/HadesFCS :: GPS (main)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.GPSData = type { float, float, float, float, float, float, float, i8, i8, i8, i8, i8, i32, i8, i8, [6 x i8], i8, [16 x i8], i8, i8 }

@.str = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.GPSData, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp ne i32 %10, 2
  br i1 %11, label %12, label %14

12:                                               ; preds = %2
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 -1, ptr %3, align 4
  br label %74

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds ptr, ptr %15, i64 1
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call noalias ptr @fopen(ptr noundef %17, ptr noundef @.str.1)
  store ptr %18, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %26

21:                                               ; preds = %14
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %24)
  br label %26

26:                                               ; preds = %21, %14
  call void @llvm.lifetime.start.p0(i64 68, ptr %7) #3
  call void @GPSNMEAParser_Init(ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %37, %26
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = call i32 @fgetc(ptr noundef %28)
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %8, align 1, !tbaa !11
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %32, label %69

32:                                               ; preds = %27
  %33 = load i8, ptr %8, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, -1
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  br label %69

37:                                               ; preds = %32
  %38 = load i8, ptr %8, align 1, !tbaa !11
  call void @GPSNMEAParser_Feed(ptr noundef %7, i8 noundef signext %38)
  %39 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 8
  %40 = load i8, ptr %39, align 1, !tbaa !12
  %41 = zext i8 %40 to i32
  %42 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 9
  %43 = load i8, ptr %42, align 2, !tbaa !15
  %44 = zext i8 %43 to i32
  %45 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 0
  %46 = load float, ptr %45, align 4, !tbaa !16
  %47 = fpext float %46 to double
  %48 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 1
  %49 = load float, ptr %48, align 4, !tbaa !17
  %50 = fpext float %49 to double
  %51 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 2
  %52 = load float, ptr %51, align 4, !tbaa !18
  %53 = fpext float %52 to double
  %54 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 3
  %55 = load float, ptr %54, align 4, !tbaa !19
  %56 = fpext float %55 to double
  %57 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 4
  %58 = load float, ptr %57, align 4, !tbaa !20
  %59 = fpext float %58 to double
  %60 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 5
  %61 = load float, ptr %60, align 4, !tbaa !21
  %62 = fpext float %61 to double
  %63 = getelementptr inbounds %struct.GPSData, ptr %7, i32 0, i32 6
  %64 = load float, ptr %63, align 4, !tbaa !22
  %65 = fpext float %64 to double
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %41, i32 noundef %44, double noundef %47, double noundef %50, double noundef %53, double noundef %56, double noundef %59, double noundef %62, double noundef %65)
  %67 = load i32, ptr %9, align 4, !tbaa !5
  %68 = add i32 %67, 1
  store i32 %68, ptr %9, align 4, !tbaa !5
  br label %27, !llvm.loop !23

69:                                               ; preds = %36, %27
  %70 = load i32, ptr %9, align 4, !tbaa !5
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %70)
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  %73 = call i32 @fclose(ptr noundef %72)
  store i32 0, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 68, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %74

74:                                               ; preds = %69, %12
  %75 = load i32, ptr %3, align 4
  ret i32 %75
}

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare void @GPSNMEAParser_Init(ptr noundef) #1

declare i32 @fgetc(ptr noundef) #1

declare void @GPSNMEAParser_Feed(ptr noundef, i8 noundef signext) #1

declare i32 @fclose(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 29}
!13 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !6, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 48, !7, i64 49, !7, i64 65, !7, i64 66}
!14 = !{!"float", !7, i64 0}
!15 = !{!13, !7, i64 30}
!16 = !{!13, !14, i64 0}
!17 = !{!13, !14, i64 4}
!18 = !{!13, !14, i64 8}
!19 = !{!13, !14, i64 12}
!20 = !{!13, !14, i64 16}
!21 = !{!13, !14, i64 20}
!22 = !{!13, !14, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.GPSData = type { float, float, float, float, float, float, float, i8, i8, i8, i8, i8, i32, i8, i8, [6 x i8], i8, [16 x i8], i8, i8 }

@.str = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.GPSData, align 4
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %6, label %4

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %55

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call noalias ptr @fopen(ptr noundef %8, ptr noundef nonnull @.str.1)
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %6
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %12)
  br label %14

14:                                               ; preds = %11, %6
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %3) #4
  call void @GPSNMEAParser_Init(ptr noundef nonnull %3) #4
  %15 = call i32 @fgetc(ptr noundef %9)
  %16 = trunc i32 %15 to i8
  %17 = icmp eq i8 %16, 0
  %sext.mask14 = and i32 %15, 255
  %18 = icmp eq i32 %sext.mask14, 255
  %or.cond15 = or i1 %17, %18
  br i1 %or.cond15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %14
  %19 = getelementptr inbounds i8, ptr %3, i64 29
  %20 = getelementptr inbounds i8, ptr %3, i64 30
  %21 = getelementptr inbounds i8, ptr %3, i64 4
  %22 = getelementptr inbounds i8, ptr %3, i64 8
  %23 = getelementptr inbounds i8, ptr %3, i64 12
  %24 = getelementptr inbounds i8, ptr %3, i64 16
  %25 = getelementptr inbounds i8, ptr %3, i64 20
  %26 = getelementptr inbounds i8, ptr %3, i64 24
  br label %27

27:                                               ; preds = %.lr.ph, %27
  %28 = phi i8 [ %16, %.lr.ph ], [ %50, %27 ]
  %.016 = phi i32 [ 0, %.lr.ph ], [ %48, %27 ]
  call void @GPSNMEAParser_Feed(ptr noundef nonnull %3, i8 noundef signext %28) #4
  %29 = load i8, ptr %19, align 1, !tbaa !9
  %30 = zext i8 %29 to i32
  %31 = load i8, ptr %20, align 2, !tbaa !13
  %32 = zext i8 %31 to i32
  %33 = load float, ptr %3, align 4, !tbaa !14
  %34 = fpext float %33 to double
  %35 = load float, ptr %21, align 4, !tbaa !15
  %36 = fpext float %35 to double
  %37 = load float, ptr %22, align 4, !tbaa !16
  %38 = fpext float %37 to double
  %39 = load float, ptr %23, align 4, !tbaa !17
  %40 = fpext float %39 to double
  %41 = load float, ptr %24, align 4, !tbaa !18
  %42 = fpext float %41 to double
  %43 = load float, ptr %25, align 4, !tbaa !19
  %44 = fpext float %43 to double
  %45 = load float, ptr %26, align 4, !tbaa !20
  %46 = fpext float %45 to double
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %30, i32 noundef %32, double noundef %34, double noundef %36, double noundef %38, double noundef %40, double noundef %42, double noundef %44, double noundef %46)
  %48 = add i32 %.016, 1
  %49 = call i32 @fgetc(ptr noundef %9)
  %50 = trunc i32 %49 to i8
  %51 = icmp eq i8 %50, 0
  %sext.mask = and i32 %49, 255
  %52 = icmp eq i32 %sext.mask, 255
  %or.cond = or i1 %51, %52
  br i1 %or.cond, label %._crit_edge, label %27, !llvm.loop !21

._crit_edge:                                      ; preds = %27, %14
  %.0.lcssa = phi i32 [ 0, %14 ], [ %48, %27 ]
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.0.lcssa)
  %54 = call i32 @fclose(ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %3) #4
  br label %55

55:                                               ; preds = %._crit_edge, %4
  %.012 = phi i32 [ -1, %4 ], [ 0, %._crit_edge ]
  ret i32 %.012
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

declare void @GPSNMEAParser_Init(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fgetc(ptr nocapture noundef) local_unnamed_addr #1

declare void @GPSNMEAParser_Feed(ptr noundef, i8 noundef signext) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 29}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !12, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 48, !7, i64 49, !7, i64 65, !7, i64 66}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !7, i64 30}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !11, i64 4}
!16 = !{!10, !11, i64 8}
!17 = !{!10, !11, i64 12}
!18 = !{!10, !11, i64 16}
!19 = !{!10, !11, i64 20}
!20 = !{!10, !11, i64 24}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass