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

; 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 i32 @ast_id(ptr noundef) #1

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

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

28:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  store i32 1, ptr %14, align 4
  br label %55

29:                                               ; preds = %2
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call zeroext i1 @coerce_literals(ptr noundef %12, ptr noundef %30, ptr noundef %31)
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i1 false, ptr %3, align 1
  store i32 1, ptr %14, align 4
  br label %55

34:                                               ; preds = %29
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call i32 @ast_id(ptr noundef %35)
  switch i32 %36, label %53 [
    i32 88, label %37
    i32 89, label %49
  ]

37:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  store i8 1, ptr %15, align 1, !tbaa !9
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = call zeroext i1 @is_machine_word(ptr noundef %38)
  br i1 %39, label %40, label %46

40:                                               ; preds = %37
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call zeroext i1 @check_return_type(ptr noundef %41, ptr noundef %42)
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i8 0, ptr %15, align 1, !tbaa !9
  br label %45

45:                                               ; preds = %44, %40
  br label %46

46:                                               ; preds = %45, %37
  %47 = load i8, ptr %15, align 1, !tbaa !9, !range !11, !noundef !12
  %48 = trunc i8 %47 to i1
  store i1 %48, ptr %3, align 1
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  br label %55

49:                                               ; preds = %34
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call zeroext i1 @check_return_type(ptr noundef %50, ptr noundef %51)
  store i1 %52, ptr %3, align 1
  store i32 1, ptr %14, align 4
  br label %55

53:                                               ; preds = %34
  br label %54

54:                                               ; preds = %53
  store i1 true, ptr %3, align 1
  store i32 1, ptr %14, align 4
  br label %55

55:                                               ; preds = %54, %49, %46, %33, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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
  %56 = load i1, ptr %3, align 1
  ret i1 %56
}

declare zeroext i1 @is_machine_word(ptr noundef) #1

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

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 = !{i8 0, i8 2}
!12 = !{}


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

; 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 i32 @ast_id(ptr noundef) local_unnamed_addr #1

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

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

21:                                               ; preds = %2
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call zeroext i1 @coerce_literals(ptr noundef nonnull %9, ptr noundef %22, ptr noundef %0) #3
  br i1 %23, label %24, label %30

24:                                               ; preds = %21
  %25 = call i32 @ast_id(ptr noundef %1) #3
  switch i32 %25, label %30 [
    i32 88, label %26
    i32 89, label %.sink.split
  ]

26:                                               ; preds = %24
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = call zeroext i1 @is_machine_word(ptr noundef %27) #3
  br i1 %28, label %.sink.split, label %30

.sink.split:                                      ; preds = %24, %26
  %29 = call zeroext i1 @check_return_type(ptr noundef %0, ptr noundef %1)
  br label %30

30:                                               ; preds = %.sink.split, %24, %26, %21, %2
  %.08 = phi i1 [ true, %2 ], [ false, %21 ], [ true, %26 ], [ true, %24 ], [ %29, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #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
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  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 %.08
}

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

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

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


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