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

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

declare i32 @ast_id(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_get_children(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_call(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 i32, align 4
  %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 [5 x ptr], align 16
  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
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call zeroext i1 @literal_call(ptr noundef %16, ptr noundef %17)
  br i1 %18, label %20, label %19

19:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %58

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call ptr @ast_type(ptr noundef %21)
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %30

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call i32 @ast_id(ptr noundef %26)
  %28 = icmp ne i32 %27, 157
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %57

30:                                               ; preds = %25, %20
  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 40, ptr %13) #3
  store ptr %9, ptr %13, align 8, !tbaa !5
  %31 = getelementptr inbounds ptr, ptr %13, i64 1
  store ptr %10, ptr %31, align 8, !tbaa !5
  %32 = getelementptr inbounds ptr, ptr %13, i64 2
  store ptr %11, ptr %32, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %13, i64 3
  store ptr %12, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds ptr, ptr %13, i64 4
  store ptr null, ptr %34, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds [5 x ptr], ptr %13, i64 0, i64 0
  call void @ast_get_children(ptr noundef %35, i64 noundef 4, ptr noundef %36)
  call void @llvm.lifetime.end.p0(i64 40, ptr %13) #3
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call i32 @ast_id(ptr noundef %37)
  switch i32 %38, label %51 [
    i32 188, label %39
    i32 189, label %39
    i32 190, label %39
    i32 191, label %39
    i32 200, label %43
    i32 201, label %43
    i32 202, label %43
    i32 203, label %47
    i32 204, label %47
  ]

39:                                               ; preds = %30, %30, %30, %30
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call zeroext i1 @method_call(ptr noundef %40, ptr noundef %41)
  store i1 %42, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %56

43:                                               ; preds = %30, %30, %30
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call zeroext i1 @partial_application(ptr noundef %44, ptr noundef %45)
  store i1 %46, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %56

47:                                               ; preds = %30, %30
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call zeroext i1 @method_chain(ptr noundef %48, ptr noundef %49)
  store i1 %50, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %56

51:                                               ; preds = %30
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call zeroext i1 @insert_apply(ptr noundef %53, ptr noundef %54)
  store i1 %55, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %56

56:                                               ; preds = %52, %47, %43, %39
  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
  br label %57

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

58:                                               ; preds = %57, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %59 = load i1, ptr %3, align 1
  ret i1 %59
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @insert_apply(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"}


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

declare i32 @ast_id(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_get_children(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_call(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 [5 x ptr], align 16
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = tail call zeroext i1 @literal_call(ptr noundef %8, ptr noundef %0) #3
  br i1 %9, label %10, label %30

10:                                               ; preds = %2
  %11 = tail call ptr @ast_type(ptr noundef %8) #3
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %14, label %12

12:                                               ; preds = %10
  %13 = tail call i32 @ast_id(ptr noundef nonnull %11) #3
  %.not17 = icmp eq i32 %13, 157
  br i1 %.not17, label %14, label %30

14:                                               ; preds = %12, %10
  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 40, ptr nonnull %7) #3
  store ptr %3, ptr %7, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %4, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr %5, ptr %16, align 16, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr %6, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr null, ptr %18, align 16, !tbaa !5
  call void @ast_get_children(ptr noundef %8, i64 noundef 4, ptr noundef nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %7) #3
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 @ast_id(ptr noundef %19) #3
  switch i32 %20, label %27 [
    i32 188, label %21
    i32 189, label %21
    i32 190, label %21
    i32 191, label %21
    i32 200, label %23
    i32 201, label %23
    i32 202, label %23
    i32 203, label %25
    i32 204, label %25
  ]

21:                                               ; preds = %14, %14, %14, %14
  %22 = call zeroext i1 @method_call(ptr noundef %0, ptr noundef %8)
  br label %29

23:                                               ; preds = %14, %14, %14
  %24 = call zeroext i1 @partial_application(ptr noundef %0, ptr noundef nonnull %1)
  br label %29

25:                                               ; preds = %14, %14
  %26 = call zeroext i1 @method_chain(ptr noundef %0, ptr noundef %8)
  br label %29

27:                                               ; preds = %14
  %28 = call zeroext i1 @insert_apply(ptr noundef %0, ptr noundef nonnull %1)
  br label %29

29:                                               ; preds = %27, %25, %23, %21
  %.0 = phi i1 [ %28, %27 ], [ %26, %25 ], [ %24, %23 ], [ %22, %21 ]
  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
  br label %30

30:                                               ; preds = %29, %12, %2
  %.2 = phi i1 [ false, %2 ], [ %.0, %29 ], [ true, %12 ]
  ret i1 %.2
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @insert_apply(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,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass