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

@.str.1 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 x i8], align 1
@__func__.define_build_flag = external hidden unnamed_addr constant [18 x i8], align 1
@_user_flags = external hidden global ptr, align 8

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @flagtab_get(ptr noundef, ptr noundef, ptr noundef) #0

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

declare noalias ptr @ponyint_pool_alloc(i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @flag_dup(ptr noundef) #0

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

10:                                               ; preds = %1
  br label %12

11:                                               ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i64 noundef 582, ptr noundef @__func__.define_build_flag)
  br label %12

12:                                               ; preds = %11, %10
  %13 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %12
  %16 = call noalias ptr @ponyint_pool_alloc(i64 noundef 0)
  store ptr %16, ptr @_user_flags, align 8, !tbaa !5
  %17 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  call void @flagtab_init(ptr noundef %17, i64 noundef 8)
  br label %18

18:                                               ; preds = %15, %12
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #3
  %19 = getelementptr inbounds %struct.flag_t, ptr %4, i32 0, i32 0
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = call ptr @stringtab(ptr noundef %20)
  store ptr %21, ptr %19, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.flag_t, ptr %4, i32 0, i32 1
  store i8 0, ptr %22, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 -1, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %23 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  %24 = call ptr @flagtab_get(ptr noundef %23, ptr noundef %4, ptr noundef %5)
  store ptr %24, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %18
  store i1 false, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %32

28:                                               ; preds = %18
  %29 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  %30 = call ptr @flag_dup(ptr noundef %4)
  %31 = load i64, ptr %5, align 8, !tbaa !13
  call void @flagtab_putindex(ptr noundef %29, ptr noundef %30, i64 noundef %31)
  store i1 true, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %32

32:                                               ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #3
  %33 = load i1, ptr %2, align 1
  ret i1 %33
}

declare ptr @stringtab(ptr noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 0}
!10 = !{!"flag_t", !6, i64 0, !11, i64 8}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, 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.10 = external hidden unnamed_addr constant [13 x i8], align 1
@__func__.define_build_flag = external hidden unnamed_addr constant [18 x i8], align 1
@_user_flags = external hidden local_unnamed_addr global ptr, align 8

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

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

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

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

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

declare noalias ptr @ponyint_pool_alloc(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @flag_dup(ptr noundef) local_unnamed_addr #0

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

4:                                                ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i64 noundef 582, ptr noundef nonnull @__func__.define_build_flag) #3
  br label %5

5:                                                ; preds = %1, %4
  %6 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call noalias ptr @ponyint_pool_alloc(i64 noundef 0) #3
  store ptr %9, ptr @_user_flags, align 8, !tbaa !5
  tail call void @flagtab_init(ptr noundef %9, i64 noundef 8)
  br label %10

10:                                               ; preds = %8, %5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #3
  %11 = tail call ptr @stringtab(ptr noundef %0) #3
  store ptr %11, ptr %2, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  store i8 0, ptr %12, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store i64 -1, ptr %3, align 8, !tbaa !13
  %13 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  %14 = call ptr @flagtab_get(ptr noundef %13, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %.not4 = icmp eq ptr %14, null
  br i1 %.not4, label %15, label %19

15:                                               ; preds = %10
  %16 = load ptr, ptr @_user_flags, align 8, !tbaa !5
  %17 = call ptr @flag_dup(ptr noundef nonnull %2)
  %18 = load i64, ptr %3, align 8, !tbaa !13
  call void @flagtab_putindex(ptr noundef %16, ptr noundef %17, i64 noundef %18)
  br label %19

19:                                               ; preds = %10, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #3
  ret i1 %.not4
}

declare ptr @stringtab(ptr noundef) local_unnamed_addr #2

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 0}
!10 = !{!"flag_t", !6, i64 0, !11, i64 8}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


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