; LLVM IR from jim-b/ECCSI-SAKKE :: src/data (mikeySakkeParameters)

; 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.msParameterSet_t = type { i16, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@ms_parameter_sets_initialised = external dso_local global i16, align 2
@ms_parameter_sets = external dso_local global [1 x %struct.msParameterSet_t], align 16

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

declare void @BN_clear_free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ms_deleteParameterSets() #3 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %2

2:                                                ; preds = %100, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = icmp slt i32 %3, 1
  br i1 %4, label %5, label %103

5:                                                ; preds = %2
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %7
  %9 = getelementptr inbounds %struct.msParameterSet_t, ptr %8, i32 0, i32 3
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %18

12:                                               ; preds = %5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %14
  %16 = getelementptr inbounds %struct.msParameterSet_t, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  call void @BN_clear_free(ptr noundef %17)
  br label %18

18:                                               ; preds = %12, %5
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.msParameterSet_t, ptr %21, i32 0, i32 4
  %23 = load ptr, ptr %22, align 16, !tbaa !13
  %24 = icmp ne ptr null, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %18
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.msParameterSet_t, ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 16, !tbaa !13
  call void @BN_clear_free(ptr noundef %30)
  br label %31

31:                                               ; preds = %25, %18
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.msParameterSet_t, ptr %34, i32 0, i32 6
  %36 = load ptr, ptr %35, align 16, !tbaa !14
  %37 = icmp ne ptr null, %36
  br i1 %37, label %38, label %44

38:                                               ; preds = %31
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.msParameterSet_t, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 16, !tbaa !14
  call void @BN_clear_free(ptr noundef %43)
  br label %44

44:                                               ; preds = %38, %31
  %45 = load i32, ptr %1, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.msParameterSet_t, ptr %47, i32 0, i32 7
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = icmp ne ptr null, %49
  br i1 %50, label %51, label %57

51:                                               ; preds = %44
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.msParameterSet_t, ptr %54, i32 0, i32 7
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  call void @BN_clear_free(ptr noundef %56)
  br label %57

57:                                               ; preds = %51, %44
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.msParameterSet_t, ptr %60, i32 0, i32 8
  %62 = load ptr, ptr %61, align 16, !tbaa !16
  %63 = icmp ne ptr null, %62
  br i1 %63, label %64, label %70

64:                                               ; preds = %57
  %65 = load i32, ptr %1, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %66
  %68 = getelementptr inbounds %struct.msParameterSet_t, ptr %67, i32 0, i32 8
  %69 = load ptr, ptr %68, align 16, !tbaa !16
  call void @BN_clear_free(ptr noundef %69)
  br label %70

70:                                               ; preds = %64, %57
  %71 = load i32, ptr %1, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.msParameterSet_t, ptr %73, i32 0, i32 9
  %75 = load ptr, ptr %74, align 8, !tbaa !17
  %76 = icmp ne ptr null, %75
  br i1 %76, label %77, label %83

77:                                               ; preds = %70
  %78 = load i32, ptr %1, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.msParameterSet_t, ptr %80, i32 0, i32 9
  %82 = load ptr, ptr %81, align 8, !tbaa !17
  call void @EC_GROUP_clear_free(ptr noundef %82)
  br label %83

83:                                               ; preds = %77, %70
  %84 = load i32, ptr %1, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.msParameterSet_t, ptr %86, i32 0, i32 5
  %88 = load ptr, ptr %87, align 8, !tbaa !18
  %89 = icmp ne ptr null, %88
  br i1 %89, label %90, label %96

90:                                               ; preds = %83
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.msParameterSet_t, ptr %93, i32 0, i32 5
  %95 = load ptr, ptr %94, align 8, !tbaa !18
  call void @EC_POINT_clear_free(ptr noundef %95)
  br label %96

96:                                               ; preds = %90, %83
  %97 = load i32, ptr %1, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1 x %struct.msParameterSet_t], ptr @ms_parameter_sets, i64 0, i64 %98
  call void @llvm.memset.p0.i64(ptr align 16 %99, i8 0, i64 64, i1 false)
  br label %100

100:                                              ; preds = %96
  %101 = load i32, ptr %1, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !19

103:                                              ; preds = %2
  store i16 0, ptr @ms_parameter_sets_initialised, align 2, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

declare void @EC_GROUP_clear_free(ptr noundef) #2

declare void @EC_POINT_clear_free(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { "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 #3 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"msParameterSet_t", !11, i64 0, !7, i64 2, !7, i64 3, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56}
!11 = !{!"short", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !12, i64 16}
!14 = !{!10, !12, i64 32}
!15 = !{!10, !12, i64 40}
!16 = !{!10, !12, i64 48}
!17 = !{!10, !12, i64 56}
!18 = !{!10, !12, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!11, !11, i64 0}


; 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.msParameterSet_t = type { i16, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@ms_parameter_sets_initialised = external dso_local local_unnamed_addr global i16, align 2
@ms_parameter_sets = external dso_local local_unnamed_addr global [1 x %struct.msParameterSet_t], align 16

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

declare void @BN_clear_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @ms_deleteParameterSets() local_unnamed_addr #2 {
.critedge:
  %0 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 8), align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %1

1:                                                ; preds = %.critedge
  tail call void @BN_clear_free(ptr noundef nonnull %0) #3
  br label %2

2:                                                ; preds = %1, %.critedge
  %3 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 16), align 16, !tbaa !11
  %.not24 = icmp eq ptr %3, null
  br i1 %.not24, label %5, label %4

4:                                                ; preds = %2
  tail call void @BN_clear_free(ptr noundef nonnull %3) #3
  br label %5

5:                                                ; preds = %4, %2
  %6 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 32), align 16, !tbaa !12
  %.not25 = icmp eq ptr %6, null
  br i1 %.not25, label %8, label %7

7:                                                ; preds = %5
  tail call void @BN_clear_free(ptr noundef nonnull %6) #3
  br label %8

8:                                                ; preds = %7, %5
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 40), align 8, !tbaa !13
  %.not26 = icmp eq ptr %9, null
  br i1 %.not26, label %11, label %10

10:                                               ; preds = %8
  tail call void @BN_clear_free(ptr noundef nonnull %9) #3
  br label %11

11:                                               ; preds = %10, %8
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 48), align 16, !tbaa !14
  %.not27 = icmp eq ptr %12, null
  br i1 %.not27, label %14, label %13

13:                                               ; preds = %11
  tail call void @BN_clear_free(ptr noundef nonnull %12) #3
  br label %14

14:                                               ; preds = %13, %11
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 56), align 8, !tbaa !15
  %.not28 = icmp eq ptr %15, null
  br i1 %.not28, label %17, label %16

16:                                               ; preds = %14
  tail call void @EC_GROUP_clear_free(ptr noundef nonnull %15) #3
  br label %17

17:                                               ; preds = %16, %14
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @ms_parameter_sets, i64 24), align 8, !tbaa !16
  %.not29 = icmp eq ptr %18, null
  br i1 %.not29, label %20, label %19

19:                                               ; preds = %17
  tail call void @EC_POINT_clear_free(ptr noundef nonnull %18) #3
  br label %20

20:                                               ; preds = %19, %17
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) @ms_parameter_sets, i8 0, i64 64, i1 false)
  store i16 0, ptr @ms_parameter_sets_initialised, align 2, !tbaa !17
  ret void
}

declare void @EC_GROUP_clear_free(ptr noundef) local_unnamed_addr #1

declare void @EC_POINT_clear_free(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #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, !10, i64 8}
!6 = !{!"msParameterSet_t", !7, i64 0, !8, i64 2, !8, i64 3, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 56}
!16 = !{!6, !10, i64 24}
!17 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass