; LLVM IR from marcobambini/gravity :: src/compiler (gravity_symboltable)

; 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.symboltable_t = type { ptr, i16, i16, i16, i16, i32 }
%struct.ghash_r = type { i64, i64, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @symboltable_create(i32 noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 4
  %10 = zext i1 %9 to i8
  store i8 %10, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %11 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 24)
  store ptr %11, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %12 = load i8, ptr %4, align 1, !tbaa !9, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, ptr @symboltable_keyvalue_free, ptr @symboltable_hash_free
  %16 = call ptr @gravity_hash_create(i32 noundef 0, ptr noundef @gravity_value_hash, ptr noundef @gravity_value_equals, ptr noundef %15, ptr noundef null)
  store ptr %16, ptr %6, align 8, !tbaa !11
  %17 = load ptr, ptr %5, align 8, !tbaa !11
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %108

20:                                               ; preds = %1
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.symboltable_t, ptr %22, i32 0, i32 5
  store i32 %21, ptr %23, align 8, !tbaa !15
  %24 = load ptr, ptr %5, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.symboltable_t, ptr %24, i32 0, i32 1
  store i16 0, ptr %25, align 8, !tbaa !18
  %26 = load ptr, ptr %5, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.symboltable_t, ptr %26, i32 0, i32 2
  store i16 0, ptr %27, align 2, !tbaa !19
  %28 = load ptr, ptr %5, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.symboltable_t, ptr %28, i32 0, i32 3
  store i16 0, ptr %29, align 4, !tbaa !20
  %30 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 24)
  %31 = load ptr, ptr %5, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.symboltable_t, ptr %31, i32 0, i32 0
  store ptr %30, ptr %32, align 8, !tbaa !21
  %33 = load ptr, ptr %5, align 8, !tbaa !11
  %34 = getelementptr inbounds %struct.symboltable_t, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = getelementptr inbounds %struct.ghash_r, ptr %35, i32 0, i32 1
  store i64 0, ptr %36, align 8, !tbaa !22
  %37 = load ptr, ptr %5, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.symboltable_t, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !21
  %40 = getelementptr inbounds %struct.ghash_r, ptr %39, i32 0, i32 0
  store i64 0, ptr %40, align 8, !tbaa !25
  %41 = load ptr, ptr %5, align 8, !tbaa !11
  %42 = getelementptr inbounds %struct.symboltable_t, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = getelementptr inbounds %struct.ghash_r, ptr %43, i32 0, i32 2
  store ptr null, ptr %44, align 8, !tbaa !26
  %45 = load ptr, ptr %5, align 8, !tbaa !11
  %46 = getelementptr inbounds %struct.symboltable_t, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = getelementptr inbounds %struct.ghash_r, ptr %47, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !25
  %50 = load ptr, ptr %5, align 8, !tbaa !11
  %51 = getelementptr inbounds %struct.symboltable_t, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !21
  %53 = getelementptr inbounds %struct.ghash_r, ptr %52, i32 0, i32 1
  %54 = load i64, ptr %53, align 8, !tbaa !22
  %55 = icmp eq i64 %49, %54
  br i1 %55, label %56, label %93

56:                                               ; preds = %20
  %57 = load ptr, ptr %5, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct.symboltable_t, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = getelementptr inbounds %struct.ghash_r, ptr %59, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !22
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %70

63:                                               ; preds = %56
  %64 = load ptr, ptr %5, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.symboltable_t, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !21
  %67 = getelementptr inbounds %struct.ghash_r, ptr %66, i32 0, i32 1
  %68 = load i64, ptr %67, align 8, !tbaa !22
  %69 = shl i64 %68, 1
  br label %71

70:                                               ; preds = %56
  br label %71

71:                                               ; preds = %70, %63
  %72 = phi i64 [ %69, %63 ], [ 8, %70 ]
  %73 = load ptr, ptr %5, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.symboltable_t, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !21
  %76 = getelementptr inbounds %struct.ghash_r, ptr %75, i32 0, i32 1
  store i64 %72, ptr %76, align 8, !tbaa !22
  %77 = load ptr, ptr %5, align 8, !tbaa !11
  %78 = getelementptr inbounds %struct.symboltable_t, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !21
  %80 = getelementptr inbounds %struct.ghash_r, ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %80, align 8, !tbaa !26
  %82 = load ptr, ptr %5, align 8, !tbaa !11
  %83 = getelementptr inbounds %struct.symboltable_t, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = getelementptr inbounds %struct.ghash_r, ptr %84, i32 0, i32 1
  %86 = load i64, ptr %85, align 8, !tbaa !22
  %87 = mul i64 8, %86
  %88 = call ptr @realloc(ptr noundef %81, i64 noundef %87) #5
  %89 = load ptr, ptr %5, align 8, !tbaa !11
  %90 = getelementptr inbounds %struct.symboltable_t, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !21
  %92 = getelementptr inbounds %struct.ghash_r, ptr %91, i32 0, i32 2
  store ptr %88, ptr %92, align 8, !tbaa !26
  br label %93

93:                                               ; preds = %71, %20
  %94 = load ptr, ptr %6, align 8, !tbaa !11
  %95 = load ptr, ptr %5, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct.symboltable_t, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !21
  %98 = getelementptr inbounds %struct.ghash_r, ptr %97, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !26
  %100 = load ptr, ptr %5, align 8, !tbaa !11
  %101 = getelementptr inbounds %struct.symboltable_t, ptr %100, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8, !tbaa !21
  %103 = getelementptr inbounds %struct.ghash_r, ptr %102, i32 0, i32 0
  %104 = load i64, ptr %103, align 8, !tbaa !25
  %105 = add i64 %104, 1
  store i64 %105, ptr %103, align 8, !tbaa !25
  %106 = getelementptr inbounds ptr, ptr %99, i64 %104
  store ptr %94, ptr %106, align 8, !tbaa !11
  %107 = load ptr, ptr %5, align 8, !tbaa !11
  store ptr %107, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %108

108:                                              ; preds = %93, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  %109 = load ptr, ptr %2, align 8
  ret ptr %109
}

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

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) #2

declare ptr @gravity_hash_create(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @gravity_value_hash(ptr, i64) #2

declare zeroext i1 @gravity_value_equals(ptr, i64, ptr, i64) #2

; Function Attrs: nounwind uwtable
declare hidden void @symboltable_keyvalue_free(ptr noundef, ptr, i64, ptr, i64, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @symboltable_hash_free(ptr noundef, ptr, i64, ptr, i64, ptr noundef) #0

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 allocsize(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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(1) }

!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 = !{!"int", !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, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 16}
!16 = !{!"symboltable_t", !12, i64 0, !17, i64 8, !17, i64 10, !17, i64 12, !17, i64 14, !6, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!16, !17, i64 8}
!19 = !{!16, !17, i64 10}
!20 = !{!16, !17, i64 12}
!21 = !{!16, !12, i64 0}
!22 = !{!23, !24, i64 8}
!23 = !{!"", !24, i64 0, !24, i64 8, !12, i64 16}
!24 = !{!"long", !7, i64 0}
!25 = !{!23, !24, i64 0}
!26 = !{!23, !12, i64 16}


; 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: nounwind uwtable
define dso_local ptr @symboltable_create(i32 noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq i32 %0, 4
  %3 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 24) #3
  %4 = select i1 %2, ptr @symboltable_keyvalue_free, ptr @symboltable_hash_free
  %5 = tail call ptr @gravity_hash_create(i32 noundef 0, ptr noundef nonnull @gravity_value_hash, ptr noundef nonnull @gravity_value_equals, ptr noundef nonnull %4, ptr noundef null) #3
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %14, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 %0, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  store i16 0, ptr %8, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %3, i64 10
  store i16 0, ptr %9, align 2, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %3, i64 12
  store i16 0, ptr %10, align 4, !tbaa !14
  %11 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef 24) #3
  store ptr %11, ptr %3, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = getelementptr inbounds i8, ptr %11, i64 16
  store i64 8, ptr %12, align 8, !tbaa !16
  %malloc = tail call dereferenceable_or_null(64) ptr @malloc(i64 64)
  store ptr %malloc, ptr %13, align 8, !tbaa !19
  store i64 1, ptr %11, align 8, !tbaa !20
  store ptr %5, ptr %malloc, align 8, !tbaa !21
  br label %14

14:                                               ; preds = %1, %6
  ret ptr %3
}

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare ptr @gravity_hash_create(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @gravity_value_hash(ptr, i64) #1

declare zeroext i1 @gravity_value_equals(ptr, i64, ptr, i64) #1

; Function Attrs: nounwind uwtable
declare hidden void @symboltable_keyvalue_free(ptr noundef, ptr, i64, ptr, i64, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @symboltable_hash_free(ptr noundef, ptr, i64, ptr, i64, ptr noundef) #0

; Function Attrs: nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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, !11, i64 16}
!6 = !{!"symboltable_t", !7, i64 0, !10, i64 8, !10, i64 10, !10, i64 12, !10, i64 14, !11, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 10}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !18, i64 8}
!17 = !{!"", !18, i64 0, !18, i64 8, !7, i64 16}
!18 = !{!"long", !8, i64 0}
!19 = !{!17, !7, i64 16}
!20 = !{!17, !18, i64 0}
!21 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass