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

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.ifdef_cond_normalise = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1

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

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 412, ptr noundef @__func__.ifdef_cond_normalise)
  br label %12

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

16:                                               ; preds = %12
  br label %18

17:                                               ; preds = %12
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 413, ptr noundef @__func__.ifdef_cond_normalise)
  br label %18

18:                                               ; preds = %17, %16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = call i32 @ast_id(ptr noundef %20)
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  store i1 true, ptr %3, align 1
  br label %49

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  call void @cond_normalise(ptr noundef %25)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %26 = call ptr (...) @buildflagset_create()
  store ptr %26, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  call void @find_flags_in_cond(ptr noundef %28, ptr noundef %29)
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  call void @check_config_count(ptr noundef %30, ptr noundef %32)
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  call void @buildflagset_startenum(ptr noundef %33)
  br label %34

34:                                               ; preds = %45, %24
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call zeroext i1 @buildflagset_next(ptr noundef %35)
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call zeroext i1 @cond_eval(ptr noundef %39, ptr noundef %40, i1 noundef zeroext false, ptr noundef %41)
  br i1 %42, label %43, label %45

43:                                               ; preds = %37
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  call void @buildflagset_free(ptr noundef %44)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %48

45:                                               ; preds = %37
  br label %34, !llvm.loop !9

46:                                               ; preds = %34
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  call void @buildflagset_free(ptr noundef %47)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %48

48:                                               ; preds = %46, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %49

49:                                               ; preds = %48, %23
  %50 = load i1, ptr %3, align 1
  ret i1 %50
}

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

declare i32 @ast_id(ptr noundef) #1

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

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

declare ptr @buildflagset_create(...) #1

; Function Attrs: nounwind uwtable
declare hidden void @find_flags_in_cond(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @check_config_count(ptr noundef, ptr noundef) #0

declare void @buildflagset_startenum(ptr noundef) #1

declare zeroext i1 @buildflagset_next(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cond_eval(ptr noundef, ptr noundef, i1 noundef zeroext, ptr noundef) #0

declare void @buildflagset_free(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.ifdef_cond_normalise = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @ifdef_cond_normalise(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

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

4:                                                ; preds = %2, %3
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %.not16 = icmp eq ptr %5, null
  br i1 %.not16, label %6, label %7

6:                                                ; preds = %4
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 413, ptr noundef nonnull @__func__.ifdef_cond_normalise) #2
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %4, %6
  %8 = phi ptr [ %5, %4 ], [ %.pre, %6 ]
  %9 = tail call i32 @ast_id(ptr noundef %8) #2
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %20, label %11

11:                                               ; preds = %7
  tail call void @cond_normalise(ptr noundef nonnull %0)
  %12 = tail call ptr (...) @buildflagset_create() #2
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @find_flags_in_cond(ptr noundef %13, ptr noundef %12)
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @check_config_count(ptr noundef %12, ptr noundef %14)
  tail call void @buildflagset_startenum(ptr noundef %12) #2
  br label %15

15:                                               ; preds = %17, %11
  %16 = tail call zeroext i1 @buildflagset_next(ptr noundef %12) #2
  br i1 %16, label %17, label %.sink.split

17:                                               ; preds = %15
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = tail call zeroext i1 @cond_eval(ptr noundef %18, ptr noundef %12, i1 noundef zeroext false, ptr noundef %1)
  br i1 %19, label %.sink.split, label %15, !llvm.loop !9

.sink.split:                                      ; preds = %15, %17
  tail call void @buildflagset_free(ptr noundef %12) #2
  br label %20

20:                                               ; preds = %.sink.split, %7
  %.1 = phi i1 [ true, %7 ], [ %16, %.sink.split ]
  ret i1 %.1
}

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

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

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

declare ptr @buildflagset_create(...) local_unnamed_addr #1

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

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

declare void @buildflagset_startenum(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @buildflagset_next(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cond_eval(ptr noundef, ptr noundef, i1 noundef zeroext, ptr noundef) local_unnamed_addr #0

declare void @buildflagset_free(ptr noundef) local_unnamed_addr #1

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 = { "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 }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass