; 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.flag_t = type { ptr, i8 }
%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.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@__func__.buildflagset_get = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [11 x i8], align 1

; 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_get(ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden i64 @os_index(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @arch_index(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @size_index(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @endian_index(ptr noundef) #1

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

13:                                               ; preds = %2
  br label %15

14:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 448, ptr noundef @__func__.buildflagset_get)
  br label %15

15:                                               ; preds = %14, %13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 449, ptr noundef @__func__.buildflagset_get)
  br label %20

20:                                               ; preds = %19, %18
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.buildflagset_t, ptr %21, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  br label %27

26:                                               ; preds = %20
  call void @ponyint_assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 450, ptr noundef @__func__.buildflagset_get)
  br label %27

27:                                               ; preds = %26, %25
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.buildflagset_t, ptr %28, i32 0, i32 4
  %30 = load i8, ptr %29, align 4, !tbaa !14, !range !15, !noundef !16
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %33

32:                                               ; preds = %27
  br label %34

33:                                               ; preds = %27
  call void @ponyint_assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 451, ptr noundef @__func__.buildflagset_get)
  br label %34

34:                                               ; preds = %33, %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call i64 @os_index(ptr noundef %35)
  store i64 %36, ptr %6, align 8, !tbaa !17
  %37 = load i64, ptr %6, align 8, !tbaa !17
  %38 = icmp sge i64 %37, 0
  br i1 %38, label %39, label %46

39:                                               ; preds = %34
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.buildflagset_t, ptr %40, i32 0, i32 7
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %43 = load i64, ptr %6, align 8, !tbaa !17
  %44 = trunc i64 %43 to i32
  %45 = icmp eq i32 %42, %44
  store i1 %45, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %99

46:                                               ; preds = %34
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = call i64 @arch_index(ptr noundef %47)
  store i64 %48, ptr %6, align 8, !tbaa !17
  %49 = load i64, ptr %6, align 8, !tbaa !17
  %50 = icmp sge i64 %49, 0
  br i1 %50, label %51, label %58

51:                                               ; preds = %46
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.buildflagset_t, ptr %52, i32 0, i32 8
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = load i64, ptr %6, align 8, !tbaa !17
  %56 = trunc i64 %55 to i32
  %57 = icmp eq i32 %54, %56
  store i1 %57, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %99

58:                                               ; preds = %46
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call i64 @size_index(ptr noundef %59)
  store i64 %60, ptr %6, align 8, !tbaa !17
  %61 = load i64, ptr %6, align 8, !tbaa !17
  %62 = icmp sge i64 %61, 0
  br i1 %62, label %63, label %70

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.buildflagset_t, ptr %64, i32 0, i32 9
  %66 = load i32, ptr %65, align 8, !tbaa !20
  %67 = load i64, ptr %6, align 8, !tbaa !17
  %68 = trunc i64 %67 to i32
  %69 = icmp eq i32 %66, %68
  store i1 %69, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %99

70:                                               ; preds = %58
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = call i64 @endian_index(ptr noundef %71)
  store i64 %72, ptr %6, align 8, !tbaa !17
  %73 = load i64, ptr %6, align 8, !tbaa !17
  %74 = icmp sge i64 %73, 0
  br i1 %74, label %75, label %82

75:                                               ; preds = %70
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.buildflagset_t, ptr %76, i32 0, i32 10
  %78 = load i32, ptr %77, align 4, !tbaa !21
  %79 = load i64, ptr %6, align 8, !tbaa !17
  %80 = trunc i64 %79 to i32
  %81 = icmp eq i32 %78, %80
  store i1 %81, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %99

82:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %83 = getelementptr inbounds %struct.flag_t, ptr %8, i32 0, i32 0
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %84, ptr %83, align 8, !tbaa !22
  %85 = getelementptr inbounds %struct.flag_t, ptr %8, i32 0, i32 1
  store i8 0, ptr %85, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 -1, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.buildflagset_t, ptr %86, i32 0, i32 6
  %88 = load ptr, ptr %87, align 8, !tbaa !9
  %89 = call ptr @flagtab_get(ptr noundef %88, ptr noundef %8, ptr noundef %9)
  store ptr %89, ptr %10, align 8, !tbaa !5
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %93

92:                                               ; preds = %82
  br label %94

93:                                               ; preds = %82
  call void @ponyint_assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i64 noundef 480, ptr noundef @__func__.buildflagset_get)
  br label %94

94:                                               ; preds = %93, %92
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.flag_t, ptr %95, i32 0, i32 1
  %97 = load i8, ptr %96, align 8, !tbaa !24, !range !15, !noundef !16
  %98 = trunc i8 %97 to i1
  store i1 %98, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  br label %99

99:                                               ; preds = %94, %75, %63, %51, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %100 = load i1, ptr %3, align 1
  ret i1 %100
}

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 = !{!10, !11, i64 4}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!13, !13, i64 0}
!18 = !{!10, !12, i64 16}
!19 = !{!10, !12, i64 20}
!20 = !{!10, !12, i64 24}
!21 = !{!10, !12, i64 28}
!22 = !{!23, !6, i64 0}
!23 = !{!"flag_t", !6, i64 0, !11, i64 8}
!24 = !{!23, !11, i64 8}


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

@.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.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@__func__.buildflagset_get = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [11 x i8], align 1

; 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_get(ptr noundef, 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
declare hidden i64 @os_index(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @arch_index(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @size_index(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @endian_index(ptr noundef) local_unnamed_addr #1

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

5:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 448, ptr noundef nonnull @__func__.buildflagset_get) #3
  br label %6

6:                                                ; preds = %2, %5
  %.not28 = icmp eq ptr %1, null
  br i1 %.not28, label %7, label %8

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

8:                                                ; preds = %6, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not29 = icmp eq ptr %10, null
  br i1 %.not29, label %11, label %12

11:                                               ; preds = %8
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i64 noundef 450, ptr noundef nonnull @__func__.buildflagset_get) #3
  br label %12

12:                                               ; preds = %8, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = load i8, ptr %13, align 4, !tbaa !13, !range !14, !noundef !15
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 451, ptr noundef nonnull @__func__.buildflagset_get) #3
  br label %17

17:                                               ; preds = %12, %16
  %18 = tail call i64 @os_index(ptr noundef %1)
  %19 = icmp sgt i64 %18, -1
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = trunc i64 %18 to i32
  %24 = icmp eq i32 %22, %23
  br label %58

25:                                               ; preds = %17
  %26 = tail call i64 @arch_index(ptr noundef %1)
  %27 = icmp sgt i64 %26, -1
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %0, i64 20
  %30 = load i32, ptr %29, align 4, !tbaa !17
  %31 = trunc i64 %26 to i32
  %32 = icmp eq i32 %30, %31
  br label %58

33:                                               ; preds = %25
  %34 = tail call i64 @size_index(ptr noundef %1)
  %35 = icmp sgt i64 %34, -1
  br i1 %35, label %36, label %41

36:                                               ; preds = %33
  %37 = getelementptr inbounds i8, ptr %0, i64 24
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = trunc i64 %34 to i32
  %40 = icmp eq i32 %38, %39
  br label %58

41:                                               ; preds = %33
  %42 = tail call i64 @endian_index(ptr noundef %1)
  %43 = icmp sgt i64 %42, -1
  br i1 %43, label %44, label %49

44:                                               ; preds = %41
  %45 = getelementptr inbounds i8, ptr %0, i64 28
  %46 = load i32, ptr %45, align 4, !tbaa !19
  %47 = trunc i64 %42 to i32
  %48 = icmp eq i32 %46, %47
  br label %58

49:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  store ptr %1, ptr %3, align 8, !tbaa !20
  %50 = getelementptr inbounds i8, ptr %3, i64 8
  store i8 0, ptr %50, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store i64 -1, ptr %4, align 8, !tbaa !23
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = call ptr @flagtab_get(ptr noundef %51, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not30 = icmp eq ptr %52, null
  br i1 %.not30, label %53, label %54

53:                                               ; preds = %49
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i64 noundef 480, ptr noundef nonnull @__func__.buildflagset_get) #3
  br label %54

54:                                               ; preds = %49, %53
  %55 = getelementptr inbounds i8, ptr %52, i64 8
  %56 = load i8, ptr %55, align 8, !tbaa !22, !range !14, !noundef !15
  %57 = trunc nuw i8 %56 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  br label %58

58:                                               ; preds = %54, %44, %36, %28, %20
  %.0 = phi i1 [ %24, %20 ], [ %32, %28 ], [ %40, %36 ], [ %48, %44 ], [ %57, %54 ]
  ret i1 %.0
}

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 4}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!6, !11, i64 16}
!17 = !{!6, !11, i64 20}
!18 = !{!6, !11, i64 24}
!19 = !{!6, !11, i64 28}
!20 = !{!21, !10, i64 0}
!21 = !{!"flag_t", !10, i64 0, !7, i64 8}
!22 = !{!21, !7, i64 8}
!23 = !{!12, !12, i64 0}


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