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

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@__func__.expr_param = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [56 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

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

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

declare void @ast_error_frame(ptr noundef, ptr noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_param(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 i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  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
  %15 = getelementptr inbounds ptr, ptr %9, i64 1
  store ptr %7, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds ptr, ptr %9, i64 2
  store ptr %8, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds ptr, ptr %9, i64 3
  store ptr null, ptr %17, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 0
  call void @ast_get_children(ptr noundef %18, i64 noundef 3, ptr noundef %19)
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #3
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %20, ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  store i8 1, ptr %10, align 1, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = call i32 @ast_id(ptr noundef %22)
  %24 = icmp ne i32 %23, 2
  br i1 %24, label %25, label %66

25:                                               ; preds = %2
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call zeroext i1 @coerce_literals(ptr noundef %8, ptr noundef %26, ptr noundef %27)
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i1 false, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %69

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = call ptr @ast_type(ptr noundef %31)
  store ptr %32, ptr %12, align 8, !tbaa !5
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = call zeroext i1 @is_typecheck_error(ptr noundef %33)
  br i1 %34, label %35, label %36

35:                                               ; preds = %30
  store i1 false, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %63

36:                                               ; preds = %30
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call ptr @consume_type(ptr noundef %37, i32 noundef 2, i1 noundef zeroext false)
  store ptr %38, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store ptr null, ptr %14, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %49

41:                                               ; preds = %36
  call void @ponyint_assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i64 noundef 178, ptr noundef @__func__.expr_param)
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call ptr @ast_print_type(ptr noundef %43)
  call void (ptr, ptr, ptr, ...) @ast_error_frame(ptr noundef %14, ptr noundef %42, ptr noundef @.str.3, ptr noundef %44)
  call void @errorframe_append(ptr noundef %14, ptr noundef %13)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.pass_opt_t, ptr %45, i32 0, i32 36
  %47 = getelementptr inbounds %struct.typecheck_t, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  call void @errorframe_report(ptr noundef %14, ptr noundef %48)
  store i8 0, ptr %10, align 1, !tbaa !9
  br label %61

49:                                               ; preds = %36
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call zeroext i1 @is_subtype(ptr noundef %50, ptr noundef %51, ptr noundef %13, ptr noundef %52)
  br i1 %53, label %60, label %54

54:                                               ; preds = %49
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error_frame(ptr noundef %14, ptr noundef %55, ptr noundef @.str.4)
  call void @errorframe_append(ptr noundef %14, ptr noundef %13)
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.pass_opt_t, ptr %56, i32 0, i32 36
  %58 = getelementptr inbounds %struct.typecheck_t, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  call void @errorframe_report(ptr noundef %14, ptr noundef %59)
  store i8 0, ptr %10, align 1, !tbaa !9
  br label %60

60:                                               ; preds = %54, %49
  br label %61

61:                                               ; preds = %60, %41
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ast_free_unattached(ptr noundef %62)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  store i32 0, ptr %11, align 4
  br label %63

63:                                               ; preds = %61, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %64 = load i32, ptr %11, align 4
  switch i32 %64, label %69 [
    i32 0, label %65
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65, %2
  %67 = load i8, ptr %10, align 1, !tbaa !9, !range !17, !noundef !18
  %68 = trunc i8 %67 to i1
  store i1 %68, ptr %3, align 1
  store i32 1, ptr %11, align 4
  br label %69

69:                                               ; preds = %66, %63, %29
  call void @llvm.lifetime.end.p0(i64 1, 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
  %70 = load i1, ptr %3, align 1
  ret i1 %70
}

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

declare i32 @ast_id(ptr noundef) #1

declare zeroext i1 @coerce_literals(ptr noundef, ptr noundef, 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 @ast_print_type(ptr noundef) #1

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

declare void @ast_free_unattached(ptr noundef) #1

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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !6, i64 216}
!12 = !{!"pass_opt_t", !13, i64 0, !13, 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, !13, i64 24, !14, i64 32, !10, i64 40, !10, 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, !15, i64 176, !6, i64 224, !6, i64 232}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"typecheck_t", !6, i64 0, !16, i64 8, !6, i64 40}
!16 = !{!"typecheck_stats_t", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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 [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@__func__.expr_param = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [56 x i8], align 1

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

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

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

declare void @ast_error_frame(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @errorframe_append(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @errorframe_report(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @expr_param(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 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  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
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %4, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %5, ptr %10, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr null, ptr %11, 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
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %1, ptr noundef %12) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call i32 @ast_id(ptr noundef %13) #3
  %.not = icmp eq i32 %14, 2
  br i1 %.not, label %38, label %15

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call zeroext i1 @coerce_literals(ptr noundef nonnull %5, ptr noundef %16, ptr noundef %0) #3
  br i1 %17, label %18, label %38

18:                                               ; preds = %15
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call ptr @ast_type(ptr noundef %19) #3
  %21 = call zeroext i1 @is_typecheck_error(ptr noundef %20) #3
  br i1 %21, label %37, label %22

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call ptr @consume_type(ptr noundef %23, i32 noundef 2, i1 noundef zeroext false) #3
  store ptr %24, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %29

26:                                               ; preds = %22
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i64 noundef 178, ptr noundef nonnull @__func__.expr_param) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call ptr @ast_print_type(ptr noundef %27) #3
  call void (ptr, ptr, ptr, ...) @ast_error_frame(ptr noundef nonnull %8, ptr noundef %27, ptr noundef nonnull @.str.3, ptr noundef %28) #3
  br label %.sink.split

29:                                               ; preds = %22
  %30 = call zeroext i1 @is_subtype(ptr noundef %20, ptr noundef nonnull %24, ptr noundef nonnull %7, ptr noundef %0) #3
  br i1 %30, label %35, label %31

31:                                               ; preds = %29
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error_frame(ptr noundef nonnull %8, ptr noundef %32, ptr noundef nonnull @.str.4) #3
  br label %.sink.split

.sink.split:                                      ; preds = %26, %31
  call void @errorframe_append(ptr noundef nonnull %8, ptr noundef nonnull %7) #3
  %33 = getelementptr inbounds i8, ptr %0, i64 216
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  call void @errorframe_report(ptr noundef nonnull %8, ptr noundef %34) #3
  br label %35

35:                                               ; preds = %.sink.split, %29
  %.011 = phi i1 [ true, %29 ], [ false, %.sink.split ]
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ast_free_unattached(ptr noundef %36) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  br label %37

37:                                               ; preds = %18, %35
  %.112 = phi i1 [ %.011, %35 ], [ true, %18 ]
  %not. = xor i1 %21, true
  %spec.select = and i1 %.112, %not.
  br label %38

38:                                               ; preds = %37, %2, %15
  %.1 = phi i1 [ false, %15 ], [ true, %2 ], [ %spec.select, %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 %.1
}

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

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @coerce_literals(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_type(ptr noundef) local_unnamed_addr #1

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

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

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

declare ptr @ast_print_type(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @is_subtype(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ast_free_unattached(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 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,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass