; 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
@__func__.buildflagset_add = external hidden unnamed_addr constant [17 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.5 = external hidden unnamed_addr constant [19 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

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

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

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

11:                                               ; preds = %2
  br label %13

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

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

16:                                               ; preds = %13
  br label %18

17:                                               ; preds = %13
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 243, ptr noundef @__func__.buildflagset_add)
  br label %18

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

23:                                               ; preds = %18
  br label %25

24:                                               ; preds = %18
  call void @ponyint_assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 244, ptr noundef @__func__.buildflagset_add)
  br label %25

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

30:                                               ; preds = %25
  br label %32

31:                                               ; preds = %25
  call void @ponyint_assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i64 noundef 245, ptr noundef @__func__.buildflagset_add)
  br label %32

32:                                               ; preds = %31, %30
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i64 @os_index(ptr noundef %33)
  %35 = icmp sge i64 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %32
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.buildflagset_t, ptr %37, i32 0, i32 0
  store i8 1, ptr %38, align 8, !tbaa !17
  br label %79

39:                                               ; preds = %32
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = call i64 @arch_index(ptr noundef %40)
  %42 = icmp sge i64 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %39
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.buildflagset_t, ptr %44, i32 0, i32 1
  store i8 1, ptr %45, align 1, !tbaa !18
  br label %79

46:                                               ; preds = %39
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i64 @size_index(ptr noundef %47)
  %49 = icmp sge i64 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %46
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.buildflagset_t, ptr %51, i32 0, i32 2
  store i8 1, ptr %52, align 2, !tbaa !19
  br label %79

53:                                               ; preds = %46
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call i64 @endian_index(ptr noundef %54)
  %56 = icmp sge i64 %55, 0
  br i1 %56, label %57, label %60

57:                                               ; preds = %53
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.buildflagset_t, ptr %58, i32 0, i32 3
  store i8 1, ptr %59, align 1, !tbaa !20
  br label %79

60:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #3
  %61 = getelementptr inbounds %struct.flag_t, ptr %5, i32 0, i32 0
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %62, ptr %61, align 8, !tbaa !21
  %63 = getelementptr inbounds %struct.flag_t, ptr %5, i32 0, i32 1
  store i8 0, ptr %63, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 -1, ptr %6, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.buildflagset_t, ptr %64, i32 0, i32 6
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = call ptr @flagtab_get(ptr noundef %66, ptr noundef %5, ptr noundef %6)
  store ptr %67, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %71

70:                                               ; preds = %60
  store i32 1, ptr %8, align 4
  br label %77

71:                                               ; preds = %60
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.buildflagset_t, ptr %72, i32 0, i32 6
  %74 = load ptr, ptr %73, align 8, !tbaa !9
  %75 = call ptr @flag_dup(ptr noundef %5)
  %76 = load i64, ptr %6, align 8, !tbaa !24
  call void @flagtab_putindex(ptr noundef %74, ptr noundef %75, i64 noundef %76)
  store i32 0, ptr %8, align 4
  br label %77

77:                                               ; preds = %71, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  %78 = load i32, ptr %8, align 4
  switch i32 %78, label %80 [
    i32 0, label %79
    i32 1, label %79
  ]

79:                                               ; preds = %77, %77, %57, %50, %43, %36
  ret void

80:                                               ; preds = %77
  unreachable
}

; 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
declare hidden ptr @flag_dup(ptr noundef) #1

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 = !{!10, !11, i64 0}
!18 = !{!10, !11, i64 1}
!19 = !{!10, !11, i64 2}
!20 = !{!10, !11, i64 3}
!21 = !{!22, !6, i64 0}
!22 = !{!"flag_t", !6, i64 0, !11, i64 8}
!23 = !{!22, !11, i64 8}
!24 = !{!13, !13, 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.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
@__func__.buildflagset_add = external hidden unnamed_addr constant [17 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.5 = external hidden unnamed_addr constant [19 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

; Function Attrs: nounwind uwtable
declare dso_local void @flagtab_putindex(ptr noundef, ptr noundef, i64 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 void @buildflagset_add(ptr noundef %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 242, ptr noundef nonnull @__func__.buildflagset_add) #3
  br label %6

6:                                                ; preds = %2, %5
  %.not16 = icmp eq ptr %1, null
  br i1 %.not16, 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 243, ptr noundef nonnull @__func__.buildflagset_add) #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
  %.not17 = icmp eq ptr %10, null
  br i1 %.not17, 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 244, ptr noundef nonnull @__func__.buildflagset_add) #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 %16, label %17

16:                                               ; preds = %12
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i64 noundef 245, ptr noundef nonnull @__func__.buildflagset_add) #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 %21

20:                                               ; preds = %17
  store i8 1, ptr %0, align 8, !tbaa !16
  br label %45

21:                                               ; preds = %17
  %22 = tail call i64 @arch_index(ptr noundef %1)
  %23 = icmp sgt i64 %22, -1
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 1, ptr %25, align 1, !tbaa !17
  br label %45

26:                                               ; preds = %21
  %27 = tail call i64 @size_index(ptr noundef %1)
  %28 = icmp sgt i64 %27, -1
  br i1 %28, label %29, label %31

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 1, ptr %30, align 2, !tbaa !18
  br label %45

31:                                               ; preds = %26
  %32 = tail call i64 @endian_index(ptr noundef %1)
  %33 = icmp sgt i64 %32, -1
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 1, ptr %35, align 1, !tbaa !19
  br label %45

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  store ptr %1, ptr %3, align 8, !tbaa !20
  %37 = getelementptr inbounds i8, ptr %3, i64 8
  store i8 0, ptr %37, 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
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = call ptr @flagtab_get(ptr noundef %38, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not18 = icmp eq ptr %39, null
  br i1 %.not18, label %40, label %44

40:                                               ; preds = %36
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = call ptr @flag_dup(ptr noundef nonnull %3)
  %43 = load i64, ptr %4, align 8, !tbaa !23
  call void @flagtab_putindex(ptr noundef %41, ptr noundef %42, i64 noundef %43)
  br label %44

44:                                               ; preds = %36, %40
  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 %45

45:                                               ; preds = %44, %34, %29, %24, %20
  ret void
}

; 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
declare hidden ptr @flag_dup(ptr noundef) local_unnamed_addr #1

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, !7, i64 0}
!17 = !{!6, !7, i64 1}
!18 = !{!6, !7, i64 2}
!19 = !{!6, !7, i64 3}
!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,SROAPass,SimplifyCFGPass,TailCallElimPass