; LLVM IR from ponylang/ponyc :: src/libponyc/pkg (buildflagset)

; 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.buildflagset_t = type { i8, i8, i8, i8, i8, i8, ptr, i32, i32, i32, i32, ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@__func__.buildflagset_configcount = external hidden unnamed_addr constant [25 x i8], align 1
@_os_flags = external hidden global [9 x ptr], align 16
@_arch_flags = external hidden global [4 x ptr], align 16
@_size_flags = external hidden global [5 x ptr], align 16
@_endian_flags = external hidden global [4 x ptr], 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @flagtab_next(ptr noundef, ptr noundef) #1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

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

11:                                               ; preds = %1
  br label %13

12:                                               ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 293, ptr noundef @__func__.buildflagset_configcount)
  br label %13

13:                                               ; preds = %12, %11
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.buildflagset_t, ptr %14, i32 0, i32 6
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  br label %20

19:                                               ; preds = %13
  call void @ponyint_assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 294, ptr noundef @__func__.buildflagset_configcount)
  br label %20

20:                                               ; preds = %19, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store double 1.000000e+00, ptr %3, align 8, !tbaa !14
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.buildflagset_t, ptr %21, i32 0, i32 0
  %23 = load i8, ptr %22, align 8, !tbaa !16, !range !17, !noundef !18
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %40

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !19
  br label %26

26:                                               ; preds = %32, %25
  %27 = load i32, ptr %4, align 4, !tbaa !19
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [9 x ptr], ptr @_os_flags, i64 0, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %35

32:                                               ; preds = %26
  %33 = load i32, ptr %4, align 4, !tbaa !19
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !19
  br label %26, !llvm.loop !20

35:                                               ; preds = %26
  %36 = load i32, ptr %4, align 4, !tbaa !19
  %37 = sitofp i32 %36 to double
  %38 = load double, ptr %3, align 8, !tbaa !14
  %39 = fmul double %38, %37
  store double %39, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %40

40:                                               ; preds = %35, %20
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.buildflagset_t, ptr %41, i32 0, i32 1
  %43 = load i8, ptr %42, align 1, !tbaa !22, !range !17, !noundef !18
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %60

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !19
  br label %46

46:                                               ; preds = %52, %45
  %47 = load i32, ptr %5, align 4, !tbaa !19
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [4 x ptr], ptr @_arch_flags, i64 0, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %55

52:                                               ; preds = %46
  %53 = load i32, ptr %5, align 4, !tbaa !19
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !19
  br label %46, !llvm.loop !23

55:                                               ; preds = %46
  %56 = load i32, ptr %5, align 4, !tbaa !19
  %57 = sitofp i32 %56 to double
  %58 = load double, ptr %3, align 8, !tbaa !14
  %59 = fmul double %58, %57
  store double %59, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %60

60:                                               ; preds = %55, %40
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.buildflagset_t, ptr %61, i32 0, i32 2
  %63 = load i8, ptr %62, align 2, !tbaa !24, !range !17, !noundef !18
  %64 = trunc i8 %63 to i1
  br i1 %64, label %65, label %80

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !19
  br label %66

66:                                               ; preds = %72, %65
  %67 = load i32, ptr %6, align 4, !tbaa !19
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [5 x ptr], ptr @_size_flags, i64 0, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %75

72:                                               ; preds = %66
  %73 = load i32, ptr %6, align 4, !tbaa !19
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !19
  br label %66, !llvm.loop !25

75:                                               ; preds = %66
  %76 = load i32, ptr %6, align 4, !tbaa !19
  %77 = sitofp i32 %76 to double
  %78 = load double, ptr %3, align 8, !tbaa !14
  %79 = fmul double %78, %77
  store double %79, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %80

80:                                               ; preds = %75, %60
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.buildflagset_t, ptr %81, i32 0, i32 3
  %83 = load i8, ptr %82, align 1, !tbaa !26, !range !17, !noundef !18
  %84 = trunc i8 %83 to i1
  br i1 %84, label %85, label %100

85:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !19
  br label %86

86:                                               ; preds = %92, %85
  %87 = load i32, ptr %7, align 4, !tbaa !19
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [4 x ptr], ptr @_endian_flags, i64 0, i64 %88
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %95

92:                                               ; preds = %86
  %93 = load i32, ptr %7, align 4, !tbaa !19
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %7, align 4, !tbaa !19
  br label %86, !llvm.loop !27

95:                                               ; preds = %86
  %96 = load i32, ptr %7, align 4, !tbaa !19
  %97 = sitofp i32 %96 to double
  %98 = load double, ptr %3, align 8, !tbaa !14
  %99 = fmul double %98, %97
  store double %99, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %100

100:                                              ; preds = %95, %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 -1, ptr %8, align 8, !tbaa !28
  br label %101

101:                                              ; preds = %107, %100
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.buildflagset_t, ptr %102, i32 0, i32 6
  %104 = load ptr, ptr %103, align 8, !tbaa !9
  %105 = call ptr @flagtab_next(ptr noundef %104, ptr noundef %8)
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %110

107:                                              ; preds = %101
  %108 = load double, ptr %3, align 8, !tbaa !14
  %109 = fmul double %108, 2.000000e+00
  store double %109, ptr %3, align 8, !tbaa !14
  br label %101, !llvm.loop !29

110:                                              ; preds = %101
  %111 = load double, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %111
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }

!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, !6, i64 8}
!10 = !{!"buildflagset_t", !11, i64 0, !11, i64 1, !11, i64 2, !11, i64 3, !11, i64 4, !11, i64 5, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !6, i64 32, !13, i64 40}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!10, !11, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !12, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !11, i64 1}
!23 = distinct !{!23, !21}
!24 = !{!10, !11, i64 2}
!25 = distinct !{!25, !21}
!26 = !{!10, !11, i64 3}
!27 = distinct !{!27, !21}
!28 = !{!13, !13, i64 0}
!29 = distinct !{!29, !21}


; 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.1 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@__func__.buildflagset_configcount = external hidden unnamed_addr constant [25 x i8], align 1
@_os_flags = external hidden local_unnamed_addr global [9 x ptr], align 16
@_arch_flags = external hidden local_unnamed_addr global [4 x ptr], align 16
@_size_flags = external hidden local_unnamed_addr global [5 x ptr], align 16
@_endian_flags = external hidden local_unnamed_addr global [4 x ptr], align 16

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @flagtab_next(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local double @buildflagset_configcount(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 293, ptr noundef nonnull @__func__.buildflagset_configcount) #3
  br label %4

4:                                                ; preds = %1, %3
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not28 = icmp eq ptr %6, null
  br i1 %.not28, label %7, label %8

7:                                                ; preds = %4
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i64 noundef 294, ptr noundef nonnull @__func__.buildflagset_configcount) #3
  br label %8

8:                                                ; preds = %4, %7
  %9 = load i8, ptr %0, align 8, !tbaa !13, !range !14, !noundef !15
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %.preheader36, label %16

.preheader36:                                     ; preds = %8, %.preheader36
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader36 ], [ 0, %8 ]
  %11 = getelementptr inbounds [9 x ptr], ptr @_os_flags, i64 0, i64 %indvars.iv
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  %.not29 = icmp eq ptr %12, null
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not29, label %13, label %.preheader36, !llvm.loop !17

13:                                               ; preds = %.preheader36
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = uitofp nneg i32 %14 to double
  br label %16

16:                                               ; preds = %13, %8
  %.027 = phi double [ %15, %13 ], [ 1.000000e+00, %8 ]
  %17 = getelementptr inbounds i8, ptr %0, i64 1
  %18 = load i8, ptr %17, align 1, !tbaa !19, !range !14, !noundef !15
  %19 = trunc nuw i8 %18 to i1
  br i1 %19, label %.preheader35, label %26

.preheader35:                                     ; preds = %16, %.preheader35
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %.preheader35 ], [ 0, %16 ]
  %20 = getelementptr inbounds [4 x ptr], ptr @_arch_flags, i64 0, i64 %indvars.iv40
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %.not30 = icmp eq ptr %21, null
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  br i1 %.not30, label %22, label %.preheader35, !llvm.loop !20

22:                                               ; preds = %.preheader35
  %23 = trunc nuw nsw i64 %indvars.iv40 to i32
  %24 = uitofp nneg i32 %23 to double
  %25 = fmul double %.027, %24
  br label %26

26:                                               ; preds = %22, %16
  %.1 = phi double [ %25, %22 ], [ %.027, %16 ]
  %27 = getelementptr inbounds i8, ptr %0, i64 2
  %28 = load i8, ptr %27, align 2, !tbaa !21, !range !14, !noundef !15
  %29 = trunc nuw i8 %28 to i1
  br i1 %29, label %.preheader34, label %36

.preheader34:                                     ; preds = %26, %.preheader34
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %.preheader34 ], [ 0, %26 ]
  %30 = getelementptr inbounds [5 x ptr], ptr @_size_flags, i64 0, i64 %indvars.iv43
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %.not31 = icmp eq ptr %31, null
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  br i1 %.not31, label %32, label %.preheader34, !llvm.loop !22

32:                                               ; preds = %.preheader34
  %33 = trunc nuw nsw i64 %indvars.iv43 to i32
  %34 = uitofp nneg i32 %33 to double
  %35 = fmul double %.1, %34
  br label %36

36:                                               ; preds = %32, %26
  %.2 = phi double [ %35, %32 ], [ %.1, %26 ]
  %37 = getelementptr inbounds i8, ptr %0, i64 3
  %38 = load i8, ptr %37, align 1, !tbaa !23, !range !14, !noundef !15
  %39 = trunc nuw i8 %38 to i1
  br i1 %39, label %.preheader, label %46

.preheader:                                       ; preds = %36, %.preheader
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %.preheader ], [ 0, %36 ]
  %40 = getelementptr inbounds [4 x ptr], ptr @_endian_flags, i64 0, i64 %indvars.iv46
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %.not32 = icmp eq ptr %41, null
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  br i1 %.not32, label %42, label %.preheader, !llvm.loop !24

42:                                               ; preds = %.preheader
  %43 = trunc nuw nsw i64 %indvars.iv46 to i32
  %44 = uitofp nneg i32 %43 to double
  %45 = fmul double %.2, %44
  br label %46

46:                                               ; preds = %42, %36
  %.3 = phi double [ %45, %42 ], [ %.2, %36 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store i64 -1, ptr %2, align 8, !tbaa !25
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = call ptr @flagtab_next(ptr noundef %47, ptr noundef nonnull %2)
  %.not3337 = icmp eq ptr %48, null
  br i1 %.not3337, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %46, %.lr.ph
  %.438 = phi double [ %49, %.lr.ph ], [ %.3, %46 ]
  %49 = fmul double %.438, 2.000000e+00
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = call ptr @flagtab_next(ptr noundef %50, ptr noundef nonnull %2)
  %.not33 = icmp eq ptr %51, null
  br i1 %.not33, label %._crit_edge, label %.lr.ph, !llvm.loop !26

._crit_edge:                                      ; preds = %.lr.ph, %46
  %.4.lcssa = phi double [ %.3, %46 ], [ %49, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret double %.4.lcssa
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }

!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 = !{!"buildflagset_t", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !10, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !10, i64 32, !12, i64 40}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !7, i64 1}
!20 = distinct !{!20, !18}
!21 = !{!6, !7, i64 2}
!22 = distinct !{!22, !18}
!23 = !{!6, !7, i64 3}
!24 = distinct !{!24, !18}
!25 = !{!12, !12, i64 0}
!26 = distinct !{!26, !18}


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