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

; 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 }
%struct.typecheck_frame_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.expr_paramref = external hidden unnamed_addr constant [14 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

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

declare i32 @ast_id(ptr noundef) #1

declare ptr @ast_type(ptr noundef) #1

declare zeroext i1 @is_typecheck_error(ptr noundef) #1

declare ptr @consume_type(ptr noundef, i32 noundef, i1 noundef zeroext) #1

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

declare ptr @typeparam_current(ptr noundef, ptr noundef, ptr noundef) #1

declare zeroext i1 @sendable(ptr noundef) #1

declare ptr @ast_parent(ptr noundef) #1

declare ptr @ast_data(ptr noundef) #1

declare ptr @set_cap_and_ephemeral(ptr noundef, i32 noundef, i32 noundef) #1

declare zeroext i1 @is_method_return(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_paramref(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 i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call i32 @ast_id(ptr noundef %11)
  %13 = icmp eq i32 %12, 198
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  br label %16

15:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.20, ptr noundef @.str.2, i64 noundef 556, ptr noundef @__func__.expr_paramref)
  br label %16

16:                                               ; preds = %15, %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call ptr @ast_data(ptr noundef %17)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  br label %23

22:                                               ; preds = %16
  call void @ponyint_assert_fail(ptr noundef @.str.16, ptr noundef @.str.2, i64 noundef 559, ptr noundef @__func__.expr_paramref)
  br label %23

23:                                               ; preds = %22, %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call ptr @ast_type(ptr noundef %24)
  store ptr %25, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call zeroext i1 @is_typecheck_error(ptr noundef %26)
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %70

29:                                               ; preds = %23
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call ptr @typeparam_current(ptr noundef %30, ptr noundef %31, ptr noundef %32)
  store ptr %33, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = call zeroext i1 @sendable(ptr noundef %34)
  br i1 %35, label %58, label %36

36:                                               ; preds = %29
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.pass_opt_t, ptr %37, i32 0, i32 36
  %39 = getelementptr inbounds %struct.typecheck_t, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.typecheck_frame_t, ptr %40, i32 0, i32 20
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %58

44:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call ptr @ast_parent(ptr noundef %45)
  store ptr %46, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = call i32 @ast_id(ptr noundef %47)
  %49 = icmp ne i32 %48, 19
  br i1 %49, label %50, label %57

50:                                               ; preds = %44
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = call i32 @ast_id(ptr noundef %51)
  %53 = icmp ne i32 %52, 21
  br i1 %53, label %54, label %57

54:                                               ; preds = %50
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call ptr @set_cap_and_ephemeral(ptr noundef %55, i32 noundef 96, i32 noundef 2)
  store ptr %56, ptr %7, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %54, %50, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %58

58:                                               ; preds = %57, %36, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %59, ptr %10, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.pass_opt_t, ptr %60, i32 0, i32 36
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = call zeroext i1 @is_method_return(ptr noundef %61, ptr noundef %62)
  br i1 %63, label %64, label %67

64:                                               ; preds = %58
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = call ptr @consume_type(ptr noundef %65, i32 noundef 2, i1 noundef zeroext false)
  store ptr %66, ptr %10, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %64, %58
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %68, ptr noundef %69)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %70

70:                                               ; preds = %67, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %71 = load i1, ptr %3, align 1
  ret i1 %71
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 176}
!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}
!16 = !{!17, !6, i64 160}
!17 = !{!"typecheck_frame_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !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, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200}


; 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.2 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.expr_paramref = external hidden unnamed_addr constant [14 x i8], align 1

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

declare i32 @ast_id(ptr noundef) local_unnamed_addr #0

declare ptr @ast_type(ptr noundef) local_unnamed_addr #0

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

declare ptr @consume_type(ptr noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

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

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

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

declare ptr @ast_parent(ptr noundef) local_unnamed_addr #0

declare ptr @ast_data(ptr noundef) local_unnamed_addr #0

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

declare zeroext i1 @is_method_return(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @expr_paramref(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 @ast_id(ptr noundef %1) #2
  %4 = icmp eq i32 %3, 198
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.2, i64 noundef 556, ptr noundef nonnull @__func__.expr_paramref) #2
  br label %6

6:                                                ; preds = %2, %5
  %7 = tail call ptr @ast_data(ptr noundef %1) #2
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %9

8:                                                ; preds = %6
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.2, i64 noundef 559, ptr noundef nonnull @__func__.expr_paramref) #2
  br label %9

9:                                                ; preds = %6, %8
  %10 = tail call ptr @ast_type(ptr noundef %7) #2
  %11 = tail call zeroext i1 @is_typecheck_error(ptr noundef %10) #2
  br i1 %11, label %33, label %12

12:                                               ; preds = %9
  %13 = tail call ptr @typeparam_current(ptr noundef %0, ptr noundef %10, ptr noundef %1) #2
  %14 = tail call zeroext i1 @sendable(ptr noundef %13) #2
  br i1 %14, label %27, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 176
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 160
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %.not23 = icmp eq ptr %19, null
  br i1 %.not23, label %27, label %20

20:                                               ; preds = %15
  %21 = tail call ptr @ast_parent(ptr noundef %1) #2
  %22 = tail call i32 @ast_id(ptr noundef %21) #2
  %.not24 = icmp eq i32 %22, 19
  br i1 %.not24, label %27, label %23

23:                                               ; preds = %20
  %24 = tail call i32 @ast_id(ptr noundef %21) #2
  %.not25 = icmp eq i32 %24, 21
  br i1 %.not25, label %27, label %25

25:                                               ; preds = %23
  %26 = tail call ptr @set_cap_and_ephemeral(ptr noundef %13, i32 noundef 96, i32 noundef 2) #2
  br label %27

27:                                               ; preds = %20, %23, %25, %15, %12
  %.1 = phi ptr [ %13, %12 ], [ %13, %15 ], [ %26, %25 ], [ %13, %23 ], [ %13, %20 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 176
  %29 = tail call zeroext i1 @is_method_return(ptr noundef nonnull %28, ptr noundef %1) #2
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = tail call ptr @consume_type(ptr noundef %.1, i32 noundef 2, i1 noundef zeroext false) #2
  br label %32

32:                                               ; preds = %30, %27
  %.0 = phi ptr [ %31, %30 ], [ %.1, %27 ]
  tail call void @ast_settype(ptr noundef %1, ptr noundef %.0) #2
  br label %33

33:                                               ; preds = %9, %32
  %.021 = xor i1 %11, true
  ret i1 %.021
}

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 = !{!6, !12, i64 176}
!6 = !{!"pass_opt_t", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !10, i64 12, !10, i64 13, !10, i64 14, !10, i64 15, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !10, i64 20, !10, i64 21, !7, i64 24, !11, i64 32, !10, i64 40, !10, i64 41, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !13, i64 176, !12, i64 224, !12, i64 232}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"typecheck_t", !12, i64 0, !14, i64 8, !12, i64 40}
!14 = !{!"typecheck_stats_t", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!15 = !{!16, !12, i64 160}
!16 = !{!"typecheck_frame_t", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200}


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