; LLVM IR from ponylang/ponyc :: src/libponyc/expr (control)

; 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.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.is_local_or_param = external hidden unnamed_addr constant [18 x i8], align 1

declare i32 @ast_id(ptr noundef) #0

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

declare ptr @ast_child(ptr noundef) #0

declare ptr @ast_sibling(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @is_local_or_param(ptr noundef %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %15, %1
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = call i32 @ast_id(ptr noundef %5)
  %7 = icmp eq i32 %6, 175
  br i1 %7, label %8, label %16

8:                                                ; preds = %4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call ptr @ast_child(ptr noundef %9)
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call ptr @ast_sibling(ptr noundef %11)
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %8
  store i1 false, ptr %2, align 1
  br label %23

15:                                               ; preds = %8
  br label %4, !llvm.loop !9

16:                                               ; preds = %4
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call i32 @ast_id(ptr noundef %17)
  switch i32 %18, label %21 [
    i32 198, label %19
    i32 197, label %19
    i32 196, label %19
    i32 184, label %20
  ]

19:                                               ; preds = %16, %16, %16
  store i1 true, ptr %2, align 1
  br label %23

20:                                               ; preds = %16
  call void @ponyint_assert_fail(ptr noundef @.str.16, ptr noundef @.str.1, i64 noundef 419, ptr noundef @__func__.is_local_or_param)
  br label %21

21:                                               ; preds = %20, %16
  br label %22

22:                                               ; preds = %21
  store i1 false, ptr %2, align 1
  br label %23

23:                                               ; preds = %22, %19, %14
  %24 = load i1, ptr %2, align 1
  ret i1 %24
}

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

!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.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.is_local_or_param = external hidden unnamed_addr constant [18 x i8], align 1

declare i32 @ast_id(ptr noundef) local_unnamed_addr #0

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

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @is_local_or_param(ptr noundef %0) local_unnamed_addr #1 {
  br label %2

2:                                                ; preds = %5, %1
  %.0 = phi ptr [ %0, %1 ], [ %6, %5 ]
  %3 = tail call i32 @ast_id(ptr noundef %.0) #2
  %4 = icmp eq i32 %3, 175
  br i1 %4, label %5, label %8

5:                                                ; preds = %2
  %6 = tail call ptr @ast_child(ptr noundef %.0) #2
  %7 = tail call ptr @ast_sibling(ptr noundef %6) #2
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %2, label %.loopexit, !llvm.loop !5

8:                                                ; preds = %2
  %9 = tail call i32 @ast_id(ptr noundef %.0) #2
  switch i32 %9, label %11 [
    i32 198, label %.loopexit
    i32 197, label %.loopexit
    i32 196, label %.loopexit
    i32 184, label %10
  ]

10:                                               ; preds = %8
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.1, i64 noundef 419, ptr noundef nonnull @__func__.is_local_or_param) #2
  br label %11

11:                                               ; preds = %8, %10
  br label %.loopexit

.loopexit:                                        ; preds = %5, %8, %8, %8, %11
  %.05 = phi i1 [ false, %11 ], [ true, %8 ], [ true, %8 ], [ true, %8 ], [ false, %5 ]
  ret i1 %.05
}

attributes #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 = { 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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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