; LLVM IR from ponylang/ponyc :: src/libponyc/ast (symtab)

; 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.symbol_t = type { ptr, ptr, i32, i64 }

; 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

; Function Attrs: nounwind uwtable
declare dso_local ptr @symtab_get(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @symtab_putindex(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @sym_dup(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @symtab_add(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %struct.symbol_t, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca %struct.symbol_t, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call ptr @name_without_case(ptr noundef %18)
  store ptr %19, ptr %10, align 8, !tbaa !5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr %20, %21
  br i1 %22, label %23, label %42

23:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #2
  %24 = getelementptr inbounds %struct.symbol_t, ptr %11, i32 0, i32 0
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %25, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.symbol_t, ptr %11, i32 0, i32 1
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %27, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds %struct.symbol_t, ptr %11, i32 0, i32 2
  store i32 1, ptr %28, align 8, !tbaa !15
  %29 = getelementptr inbounds %struct.symbol_t, ptr %11, i32 0, i32 3
  store i64 0, ptr %29, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 -1, ptr %12, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call ptr @symtab_get(ptr noundef %30, ptr noundef %11, ptr noundef %12)
  store ptr %31, ptr %13, align 8, !tbaa !5
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %23
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %39

35:                                               ; preds = %23
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call ptr @sym_dup(ptr noundef %11)
  %38 = load i64, ptr %12, align 8, !tbaa !17
  call void @symtab_putindex(ptr noundef %36, ptr noundef %37, i64 noundef %38)
  store i32 0, ptr %14, align 4
  br label %39

39:                                               ; preds = %35, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #2
  %40 = load i32, ptr %14, align 4
  switch i32 %40, label %60 [
    i32 0, label %41
  ]

41:                                               ; preds = %39
  br label %42

42:                                               ; preds = %41, %4
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #2
  %43 = getelementptr inbounds %struct.symbol_t, ptr %15, i32 0, i32 0
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %44, ptr %43, align 8, !tbaa !11
  %45 = getelementptr inbounds %struct.symbol_t, ptr %15, i32 0, i32 1
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %46, ptr %45, align 8, !tbaa !14
  %47 = getelementptr inbounds %struct.symbol_t, ptr %15, i32 0, i32 2
  %48 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %48, ptr %47, align 8, !tbaa !15
  %49 = getelementptr inbounds %struct.symbol_t, ptr %15, i32 0, i32 3
  store i64 0, ptr %49, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  store i64 -1, ptr %16, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call ptr @symtab_get(ptr noundef %50, ptr noundef %15, ptr noundef %16)
  store ptr %51, ptr %17, align 8, !tbaa !5
  %52 = load ptr, ptr %17, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %42
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %59

55:                                               ; preds = %42
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = call ptr @sym_dup(ptr noundef %15)
  %58 = load i64, ptr %16, align 8, !tbaa !17
  call void @symtab_putindex(ptr noundef %56, ptr noundef %57, i64 noundef %58)
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %59

59:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #2
  br label %60

60:                                               ; preds = %59, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %61 = load i1, ptr %5, align 1
  ret i1 %61
}

; Function Attrs: nounwind uwtable
declare hidden ptr @name_without_case(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"symbol_t", !6, i64 0, !6, i64 8, !10, i64 16, !13, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !13, i64 24}
!17 = !{!13, !13, i64 0}


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

%struct.symbol_t = type { ptr, ptr, i32, i64 }

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @symtab_get(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @symtab_putindex(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @sym_dup(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @symtab_add(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.symbol_t, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.symbol_t, align 8
  %8 = alloca i64, align 8
  %9 = tail call ptr @name_without_case(ptr noundef %1)
  %.not = icmp eq ptr %9, %1
  br i1 %.not, label %18, label %10

10:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #2
  store ptr %9, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %2, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 1, ptr %12, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %5, i64 24
  store i64 0, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #2
  store i64 -1, ptr %6, align 8, !tbaa !15
  %14 = call ptr @symtab_get(ptr noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %.not16 = icmp eq ptr %14, null
  br i1 %.not16, label %15, label %.critedge

15:                                               ; preds = %10
  %16 = call ptr @sym_dup(ptr noundef nonnull %5)
  %17 = load i64, ptr %6, align 8, !tbaa !15
  call void @symtab_putindex(ptr noundef %0, ptr noundef %16, i64 noundef %17)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #2
  br label %18

18:                                               ; preds = %15, %4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #2
  store ptr %1, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %2, ptr %19, align 8, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %3, ptr %20, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %7, i64 24
  store i64 0, ptr %21, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #2
  store i64 -1, ptr %8, align 8, !tbaa !15
  %22 = call ptr @symtab_get(ptr noundef %0, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %.not17 = icmp eq ptr %22, null
  br i1 %.not17, label %23, label %26

23:                                               ; preds = %18
  %24 = call ptr @sym_dup(ptr noundef nonnull %7)
  %25 = load i64, ptr %8, align 8, !tbaa !15
  call void @symtab_putindex(ptr noundef %0, ptr noundef %24, i64 noundef %25)
  br label %26

26:                                               ; preds = %18, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #2
  br label %27

.critedge:                                        ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #2
  br label %27

27:                                               ; preds = %.critedge, %26
  %.2 = phi i1 [ %.not17, %26 ], [ false, %.critedge ]
  ret i1 %.2
}

; Function Attrs: nounwind uwtable
declare hidden ptr @name_without_case(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"symbol_t", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !11, i64 24}
!15 = !{!11, !11, i64 0}


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