; LLVM IR from pms67/HadesFCS :: Firmware/F4/HadesF4Testbed_RTOS/Core/Src (GPSNMEAParser)

; 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 [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @GPSNMEAParser_ExtractGGA(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @GPSNMEAParser_Feed(ptr noundef %0, i8 noundef signext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.GPSData, ptr %5, i32 0, i32 13
  %7 = load i8, ptr %6, align 4, !tbaa !10
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %9, label %71

9:                                                ; preds = %2
  %10 = load i8, ptr %4, align 1, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.GPSData, ptr %11, i32 0, i32 15
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.GPSData, ptr %13, i32 0, i32 16
  %15 = load i8, ptr %14, align 4, !tbaa !14
  %16 = zext i8 %15 to i64
  %17 = getelementptr inbounds [6 x i8], ptr %12, i64 0, i64 %16
  store i8 %10, ptr %17, align 1, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.GPSData, ptr %18, i32 0, i32 16
  %20 = load i8, ptr %19, align 4, !tbaa !14
  %21 = add i8 %20, 1
  store i8 %21, ptr %19, align 4, !tbaa !14
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.GPSData, ptr %22, i32 0, i32 16
  %24 = load i8, ptr %23, align 4, !tbaa !14
  %25 = zext i8 %24 to i32
  %26 = icmp eq i32 %25, 5
  br i1 %26, label %27, label %70

27:                                               ; preds = %9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.GPSData, ptr %28, i32 0, i32 13
  store i8 0, ptr %29, align 4, !tbaa !10
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.GPSData, ptr %30, i32 0, i32 14
  store i8 1, ptr %31, align 1, !tbaa !15
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.GPSData, ptr %32, i32 0, i32 15
  %34 = getelementptr inbounds [6 x i8], ptr %33, i64 0, i64 0
  %35 = call i32 @strcmp(ptr noundef %34, ptr noundef @.str) #2
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %40, label %37

37:                                               ; preds = %27
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.GPSData, ptr %38, i32 0, i32 12
  store i32 1, ptr %39, align 4, !tbaa !16
  br label %65

40:                                               ; preds = %27
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.GPSData, ptr %41, i32 0, i32 15
  %43 = getelementptr inbounds [6 x i8], ptr %42, i64 0, i64 0
  %44 = call i32 @strcmp(ptr noundef %43, ptr noundef @.str.1) #2
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %49, label %46

46:                                               ; preds = %40
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.GPSData, ptr %47, i32 0, i32 12
  store i32 2, ptr %48, align 4, !tbaa !16
  br label %64

49:                                               ; preds = %40
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.GPSData, ptr %50, i32 0, i32 15
  %52 = getelementptr inbounds [6 x i8], ptr %51, i64 0, i64 0
  %53 = call i32 @strcmp(ptr noundef %52, ptr noundef @.str.2) #2
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %58, label %55

55:                                               ; preds = %49
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.GPSData, ptr %56, i32 0, i32 12
  store i32 3, ptr %57, align 4, !tbaa !16
  br label %63

58:                                               ; preds = %49
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.GPSData, ptr %59, i32 0, i32 12
  store i32 0, ptr %60, align 4, !tbaa !16
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.GPSData, ptr %61, i32 0, i32 14
  store i8 0, ptr %62, align 1, !tbaa !15
  br label %63

63:                                               ; preds = %58, %55
  br label %64

64:                                               ; preds = %63, %46
  br label %65

65:                                               ; preds = %64, %37
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.GPSData, ptr %66, i32 0, i32 18
  store i8 0, ptr %67, align 1, !tbaa !17
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.GPSData, ptr %68, i32 0, i32 19
  store i8 0, ptr %69, align 2, !tbaa !18
  br label %70

70:                                               ; preds = %65, %9
  br label %153

71:                                               ; preds = %2
  %72 = load i8, ptr %4, align 1, !tbaa !9
  %73 = sext i8 %72 to i32
  %74 = icmp eq i32 %73, 36
  br i1 %74, label %75, label %82

75:                                               ; preds = %71
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.GPSData, ptr %76, i32 0, i32 13
  store i8 1, ptr %77, align 4, !tbaa !10
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.GPSData, ptr %78, i32 0, i32 14
  store i8 0, ptr %79, align 1, !tbaa !15
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.GPSData, ptr %80, i32 0, i32 16
  store i8 0, ptr %81, align 4, !tbaa !14
  br label %82

82:                                               ; preds = %75, %71
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.GPSData, ptr %83, i32 0, i32 14
  %85 = load i8, ptr %84, align 1, !tbaa !15
  %86 = icmp ne i8 %85, 0
  br i1 %86, label %87, label %152

87:                                               ; preds = %82
  %88 = load i8, ptr %4, align 1, !tbaa !9
  %89 = sext i8 %88 to i32
  %90 = icmp eq i32 %89, 13
  br i1 %90, label %95, label %91

91:                                               ; preds = %87
  %92 = load i8, ptr %4, align 1, !tbaa !9
  %93 = sext i8 %92 to i32
  %94 = icmp eq i32 %93, 10
  br i1 %94, label %95, label %98

95:                                               ; preds = %91, %87
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.GPSData, ptr %96, i32 0, i32 14
  store i8 0, ptr %97, align 1, !tbaa !15
  br label %151

98:                                               ; preds = %91
  %99 = load i8, ptr %4, align 1, !tbaa !9
  %100 = sext i8 %99 to i32
  %101 = icmp eq i32 %100, 44
  br i1 %101, label %102, label %137

102:                                              ; preds = %98
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.GPSData, ptr %103, i32 0, i32 19
  %105 = load i8, ptr %104, align 2, !tbaa !18
  %106 = zext i8 %105 to i32
  %107 = icmp sgt i32 %106, 1
  br i1 %107, label %108, label %130

108:                                              ; preds = %102
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.GPSData, ptr %109, i32 0, i32 12
  %111 = load i32, ptr %110, align 4, !tbaa !16
  %112 = icmp eq i32 %111, 1
  br i1 %112, label %113, label %115

113:                                              ; preds = %108
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  call void @GPSNMEAParser_ExtractGGA(ptr noundef %114)
  br label %129

115:                                              ; preds = %108
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.GPSData, ptr %116, i32 0, i32 12
  %118 = load i32, ptr %117, align 4, !tbaa !16
  %119 = icmp eq i32 %118, 2
  br i1 %119, label %120, label %121

120:                                              ; preds = %115
  br label %128

121:                                              ; preds = %115
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.GPSData, ptr %122, i32 0, i32 12
  %124 = load i32, ptr %123, align 4, !tbaa !16
  %125 = icmp eq i32 %124, 3
  br i1 %125, label %126, label %127

126:                                              ; preds = %121
  br label %127

127:                                              ; preds = %126, %121
  br label %128

128:                                              ; preds = %127, %120
  br label %129

129:                                              ; preds = %128, %113
  br label %130

130:                                              ; preds = %129, %102
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.GPSData, ptr %131, i32 0, i32 18
  store i8 0, ptr %132, align 1, !tbaa !17
  %133 = load ptr, ptr %3, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.GPSData, ptr %133, i32 0, i32 19
  %135 = load i8, ptr %134, align 2, !tbaa !18
  %136 = add i8 %135, 1
  store i8 %136, ptr %134, align 2, !tbaa !18
  br label %150

137:                                              ; preds = %98
  %138 = load i8, ptr %4, align 1, !tbaa !9
  %139 = load ptr, ptr %3, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.GPSData, ptr %139, i32 0, i32 17
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.GPSData, ptr %141, i32 0, i32 18
  %143 = load i8, ptr %142, align 1, !tbaa !17
  %144 = zext i8 %143 to i64
  %145 = getelementptr inbounds [16 x i8], ptr %140, i64 0, i64 %144
  store i8 %138, ptr %145, align 1, !tbaa !9
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.GPSData, ptr %146, i32 0, i32 18
  %148 = load i8, ptr %147, align 1, !tbaa !17
  %149 = add i8 %148, 1
  store i8 %149, ptr %147, align 1, !tbaa !17
  br label %150

150:                                              ; preds = %137, %130
  br label %151

151:                                              ; preds = %150, %95
  br label %152

152:                                              ; preds = %151, %82
  br label %153

153:                                              ; preds = %152, %70
  ret void
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

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 = { nounwind willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 40}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !13, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 48, !7, i64 49, !7, i64 65, !7, i64 66}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!11, !7, i64 48}
!15 = !{!11, !7, i64 41}
!16 = !{!11, !13, i64 36}
!17 = !{!11, !7, i64 65}
!18 = !{!11, !7, i64 66}


; 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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @GPSNMEAParser_ExtractGGA(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @GPSNMEAParser_Feed(ptr noundef %0, i8 noundef signext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %31, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 42
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load i8, ptr %7, align 4, !tbaa !11
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds [6 x i8], ptr %6, i64 0, i64 %9
  store i8 %1, ptr %10, align 1, !tbaa !12
  %11 = load i8, ptr %7, align 4, !tbaa !11
  %12 = add i8 %11, 1
  store i8 %12, ptr %7, align 4, !tbaa !11
  %13 = icmp eq i8 %12, 5
  br i1 %13, label %14, label %60

14:                                               ; preds = %5
  store i8 0, ptr %3, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 41
  store i8 1, ptr %15, align 1, !tbaa !13
  %16 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str) #2
  %.not41 = icmp eq i32 %16, 0
  br i1 %.not41, label %17, label %19

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 1, ptr %18, align 4, !tbaa !14
  br label %28

19:                                               ; preds = %14
  %20 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.1) #2
  %.not42 = icmp eq i32 %20, 0
  br i1 %.not42, label %21, label %23

21:                                               ; preds = %19
  %22 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 2, ptr %22, align 4, !tbaa !14
  br label %28

23:                                               ; preds = %19
  %24 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.2) #2
  %.not43 = icmp eq i32 %24, 0
  %25 = getelementptr inbounds i8, ptr %0, i64 36
  br i1 %.not43, label %26, label %27

26:                                               ; preds = %23
  store i32 3, ptr %25, align 4, !tbaa !14
  br label %28

27:                                               ; preds = %23
  store i32 0, ptr %25, align 4, !tbaa !14
  store i8 0, ptr %15, align 1, !tbaa !13
  br label %28

28:                                               ; preds = %21, %27, %26, %17
  %29 = getelementptr inbounds i8, ptr %0, i64 65
  store i8 0, ptr %29, align 1, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %0, i64 66
  store i8 0, ptr %30, align 2, !tbaa !16
  br label %60

31:                                               ; preds = %2
  %32 = icmp eq i8 %1, 36
  br i1 %32, label %.thread, label %35

.thread:                                          ; preds = %31
  store i8 1, ptr %3, align 4, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 41
  store i8 0, ptr %33, align 1, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %0, i64 48
  store i8 0, ptr %34, align 4, !tbaa !11
  br label %60

35:                                               ; preds = %31
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 41
  %.pre = load i8, ptr %.phi.trans.insert, align 1, !tbaa !13
  %36 = icmp eq i8 %.pre, 0
  %37 = getelementptr inbounds i8, ptr %0, i64 41
  br i1 %36, label %60, label %38

38:                                               ; preds = %35
  switch i8 %1, label %52 [
    i8 13, label %39
    i8 10, label %39
    i8 44, label %40
  ]

39:                                               ; preds = %38, %38
  store i8 0, ptr %37, align 1, !tbaa !13
  br label %60

40:                                               ; preds = %38
  %41 = getelementptr inbounds i8, ptr %0, i64 66
  %42 = load i8, ptr %41, align 2, !tbaa !16
  %43 = icmp ugt i8 %42, 1
  br i1 %43, label %44, label %48

44:                                               ; preds = %40
  %45 = getelementptr inbounds i8, ptr %0, i64 36
  %46 = load i32, ptr %45, align 4, !tbaa !14
  %cond = icmp eq i32 %46, 1
  br i1 %cond, label %47, label %48

47:                                               ; preds = %44
  tail call void @GPSNMEAParser_ExtractGGA(ptr noundef nonnull %0)
  %.pre44 = load i8, ptr %41, align 2, !tbaa !16
  br label %48

48:                                               ; preds = %44, %47, %40
  %49 = phi i8 [ %42, %44 ], [ %.pre44, %47 ], [ %42, %40 ]
  %50 = getelementptr inbounds i8, ptr %0, i64 65
  store i8 0, ptr %50, align 1, !tbaa !15
  %51 = add i8 %49, 1
  store i8 %51, ptr %41, align 2, !tbaa !16
  br label %60

52:                                               ; preds = %38
  %53 = getelementptr inbounds i8, ptr %0, i64 49
  %54 = getelementptr inbounds i8, ptr %0, i64 65
  %55 = load i8, ptr %54, align 1, !tbaa !15
  %56 = zext i8 %55 to i64
  %57 = getelementptr inbounds [16 x i8], ptr %53, i64 0, i64 %56
  store i8 %1, ptr %57, align 1, !tbaa !12
  %58 = load i8, ptr %54, align 1, !tbaa !15
  %59 = add i8 %58, 1
  store i8 %59, ptr %54, align 1, !tbaa !15
  br label %60

60:                                               ; preds = %.thread, %35, %48, %52, %39, %5, %28
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nounwind willreturn memory(read) }

!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, !8, i64 40}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !8, i64 28, !8, i64 29, !8, i64 30, !8, i64 31, !8, i64 32, !10, i64 36, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 48, !8, i64 49, !8, i64 65, !8, i64 66}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !8, i64 48}
!12 = !{!8, !8, i64 0}
!13 = !{!6, !8, i64 41}
!14 = !{!6, !10, i64 36}
!15 = !{!6, !8, i64 65}
!16 = !{!6, !8, i64 66}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass