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

%struct.pass_opt_t = type { i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i64, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.typecheck_t, ptr, ptr }
%struct.typecheck_t = type { ptr, %struct.typecheck_stats_t, ptr }
%struct.typecheck_stats_t = type { i64, i64, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [25 x i8], align 1
@__func__.expr_repeat = external hidden unnamed_addr constant [12 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

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

declare ptr @ast_type(ptr noundef) #0

declare zeroext i1 @is_typecheck_error(ptr noundef) #0

declare void @ast_error(ptr noundef, ptr noundef, ptr noundef, ...) #0

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

declare ptr @control_type_add_branch(ptr noundef, ptr noundef, ptr noundef) #0

declare void @ast_settype(ptr noundef, ptr noundef) #0

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

declare zeroext i1 @is_bool(ptr noundef) #0

declare i32 @ast_checkflag(ptr noundef, i32 noundef) #0

declare void @literal_unify_control(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_repeat(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [4 x ptr], align 16
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call i32 @ast_id(ptr noundef %13)
  %15 = icmp eq i32 %14, 118
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  br label %18

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

18:                                               ; preds = %17, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #3
  store ptr %6, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds ptr, ptr %9, i64 1
  store ptr %7, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds ptr, ptr %9, i64 2
  store ptr %8, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %9, i64 3
  store ptr null, ptr %21, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 0
  call void @ast_get_children(ptr noundef %22, i64 noundef 3, ptr noundef %23)
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call ptr @ast_type(ptr noundef %24)
  store ptr %25, ptr %10, align 8, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = call zeroext i1 @is_typecheck_error(ptr noundef %26)
  br i1 %27, label %28, label %29

28:                                               ; preds = %18
  store i1 false, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %74

29:                                               ; preds = %18
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = call zeroext i1 @is_bool(ptr noundef %30)
  br i1 %31, label %38, label %32

32:                                               ; preds = %29
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.pass_opt_t, ptr %33, i32 0, i32 36
  %35 = getelementptr inbounds %struct.typecheck_t, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error(ptr noundef %36, ptr noundef %37, ptr noundef @.str.4)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %74

38:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call ptr @ast_type(ptr noundef %39)
  store ptr %40, ptr %12, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call i32 @ast_checkflag(ptr noundef %41, i32 noundef 1048576)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %54, label %44

44:                                               ; preds = %38
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call ptr @ast_type(ptr noundef %45)
  %47 = call zeroext i1 @is_typecheck_error(ptr noundef %46)
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  store i1 false, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %73

49:                                               ; preds = %44
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = call ptr @control_type_add_branch(ptr noundef %50, ptr noundef %51, ptr noundef %52)
  store ptr %53, ptr %12, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %49, %38
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = call i32 @ast_checkflag(ptr noundef %55, i32 noundef 1048576)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %68, label %58

58:                                               ; preds = %54
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = call ptr @ast_type(ptr noundef %59)
  %61 = call zeroext i1 @is_typecheck_error(ptr noundef %60)
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  store i1 false, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %73

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = call ptr @control_type_add_branch(ptr noundef %64, ptr noundef %65, ptr noundef %66)
  store ptr %67, ptr %12, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %63, %54
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %69, ptr noundef %70)
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  call void @literal_unify_control(ptr noundef %71, ptr noundef %72)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %73

73:                                               ; preds = %68, %62, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %74

74:                                               ; preds = %73, %32, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %75 = load i1, ptr %3, align 1
  ret i1 %75
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 216}
!10 = !{!"pass_opt_t", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 9, !12, i64 10, !12, i64 11, !12, i64 12, !12, i64 13, !12, i64 14, !12, i64 15, !12, i64 16, !12, i64 17, !12, i64 18, !12, i64 19, !12, i64 20, !12, i64 21, !11, i64 24, !13, i64 32, !12, i64 40, !12, i64 41, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !14, i64 176, !6, i64 224, !6, i64 232}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"typecheck_t", !6, i64 0, !15, i64 8, !6, i64 40}
!15 = !{!"typecheck_stats_t", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}


; 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.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [25 x i8], align 1
@__func__.expr_repeat = external hidden unnamed_addr constant [12 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

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

declare ptr @ast_type(ptr noundef) local_unnamed_addr #0

declare zeroext i1 @is_typecheck_error(ptr noundef) local_unnamed_addr #0

declare void @ast_error(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

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

declare ptr @control_type_add_branch(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @ast_settype(ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare zeroext i1 @is_bool(ptr noundef) local_unnamed_addr #0

declare i32 @ast_checkflag(ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @literal_unify_control(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @expr_repeat(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [4 x ptr], align 16
  %7 = tail call i32 @ast_id(ptr noundef %1) #3
  %8 = icmp eq i32 %7, 118
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i64 noundef 219, ptr noundef nonnull @__func__.expr_repeat) #3
  br label %10

10:                                               ; preds = %2, %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #3
  store ptr %3, ptr %6, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %4, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %5, ptr %12, align 16, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @ast_get_children(ptr noundef %1, i64 noundef 3, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call ptr @ast_type(ptr noundef %14) #3
  %16 = call zeroext i1 @is_typecheck_error(ptr noundef %15) #3
  br i1 %16, label %45, label %17

17:                                               ; preds = %10
  %18 = call zeroext i1 @is_bool(ptr noundef %15) #3
  br i1 %18, label %23, label %19

19:                                               ; preds = %17
  %20 = getelementptr inbounds i8, ptr %0, i64 216
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error(ptr noundef %21, ptr noundef %22, ptr noundef nonnull @.str.4) #3
  br label %45

23:                                               ; preds = %17
  %24 = call ptr @ast_type(ptr noundef %1) #3
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call i32 @ast_checkflag(ptr noundef %25, i32 noundef 1048576) #3
  %.not = icmp eq i32 %26, 0
  br i1 %.not, label %27, label %34

27:                                               ; preds = %23
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call ptr @ast_type(ptr noundef %28) #3
  %30 = call zeroext i1 @is_typecheck_error(ptr noundef %29) #3
  br i1 %30, label %45, label %31

31:                                               ; preds = %27
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call ptr @control_type_add_branch(ptr noundef %0, ptr noundef %24, ptr noundef %32) #3
  br label %34

34:                                               ; preds = %31, %23
  %.0 = phi ptr [ %24, %23 ], [ %33, %31 ]
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call i32 @ast_checkflag(ptr noundef %35, i32 noundef 1048576) #3
  %.not17 = icmp eq i32 %36, 0
  br i1 %.not17, label %37, label %44

37:                                               ; preds = %34
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = call ptr @ast_type(ptr noundef %38) #3
  %40 = call zeroext i1 @is_typecheck_error(ptr noundef %39) #3
  br i1 %40, label %45, label %41

41:                                               ; preds = %37
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call ptr @control_type_add_branch(ptr noundef %0, ptr noundef %.0, ptr noundef %42) #3
  br label %44

44:                                               ; preds = %41, %34
  %.1 = phi ptr [ %.0, %34 ], [ %43, %41 ]
  call void @ast_settype(ptr noundef %1, ptr noundef %.1) #3
  call void @literal_unify_control(ptr noundef %1, ptr noundef %0) #3
  br label %45

45:                                               ; preds = %44, %27, %37, %10, %19
  %.116 = phi i1 [ false, %19 ], [ false, %10 ], [ true, %44 ], [ false, %27 ], [ false, %37 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i1 %.116
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 216}
!10 = !{!"pass_opt_t", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 9, !12, i64 10, !12, i64 11, !12, i64 12, !12, i64 13, !12, i64 14, !12, i64 15, !12, i64 16, !12, i64 17, !12, i64 18, !12, i64 19, !12, i64 20, !12, i64 21, !11, i64 24, !13, i64 32, !12, i64 40, !12, i64 41, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !14, i64 176, !6, i64 224, !6, i64 232}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"typecheck_t", !6, i64 0, !15, i64 8, !6, i64 40}
!15 = !{!"typecheck_stats_t", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}


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