; LLVM IR from evanxg852000/rockstartdev :: clox (table)

; 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.Value = type { i32, %union.anon }
%union.anon = type { double }
%struct.Table = type { i32, i32, ptr }
%struct.Entry = type { ptr, %struct.Value }

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @tableSet(ptr noundef %0, ptr noundef %1, i32 %2, i64 %3) #0 {
  %5 = alloca %struct.Value, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = getelementptr inbounds { i32, i64 }, ptr %5, i32 0, i32 0
  store i32 %2, ptr %11, align 8
  %12 = getelementptr inbounds { i32, i64 }, ptr %5, i32 0, i32 1
  store i64 %3, ptr %12, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Table, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = add nsw i32 %15, 1
  %17 = sitofp i32 %16 to double
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Table, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = sitofp i32 %20 to double
  %22 = fmul double %21, 7.500000e-01
  %23 = fcmp ogt double %17, %22
  br i1 %23, label %24, label %39

24:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Table, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = icmp slt i32 %27, 8
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  br label %35

30:                                               ; preds = %24
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Table, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = mul nsw i32 %33, 2
  br label %35

35:                                               ; preds = %30, %29
  %36 = phi i32 [ 8, %29 ], [ %34, %30 ]
  store i32 %36, ptr %8, align 4, !tbaa !13
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !13
  call void @adjustCapacity(ptr noundef %37, i32 noundef %38)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %39

39:                                               ; preds = %35, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Table, ptr %40, i32 0, i32 2
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Table, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !12
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call ptr @findEntry(ptr noundef %42, i32 noundef %45, ptr noundef %46)
  store ptr %47, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Entry, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = icmp eq ptr %50, null
  %52 = zext i1 %51 to i8
  store i8 %52, ptr %10, align 1, !tbaa !18
  %53 = load i8, ptr %10, align 1, !tbaa !18, !range !20, !noundef !21
  %54 = trunc i8 %53 to i1
  br i1 %54, label %55, label %66

55:                                               ; preds = %39
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Entry, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %struct.Value, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !22
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %66

61:                                               ; preds = %55
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Table, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %63, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %61, %55, %39
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.Entry, ptr %68, i32 0, i32 0
  store ptr %67, ptr %69, align 8, !tbaa !15
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Entry, ptr %70, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %71, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !23
  %72 = load i8, ptr %10, align 1, !tbaa !18, !range !20, !noundef !21
  %73 = trunc i8 %72 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret i1 %73
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @findEntry(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !6, i64 0}
!16 = !{!"", !6, i64 0, !17, i64 8}
!17 = !{!"", !11, i64 0, !7, i64 8}
!18 = !{!19, !19, i64 0}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!16, !11, i64 8}
!23 = !{i64 0, i64 4, !13, i64 8, i64 8, !24}
!24 = !{!7, !7, 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"

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @tableSet(ptr noundef %0, ptr noundef %1, i32 %2, i64 %3) local_unnamed_addr #0 {
  %5 = load i32, ptr %0, align 8, !tbaa !5
  %6 = add nsw i32 %5, 1
  %7 = sitofp i32 %6 to double
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = sitofp i32 %9 to double
  %11 = fmul double %10, 7.500000e-01
  %12 = fcmp olt double %11, %7
  br i1 %12, label %13, label %16

13:                                               ; preds = %4
  %14 = icmp slt i32 %9, 8
  %15 = shl nuw nsw i32 %9, 1
  %spec.select = select i1 %14, i32 8, i32 %15
  tail call void @adjustCapacity(ptr noundef nonnull %0, i32 noundef %spec.select)
  %.pre = load i32, ptr %8, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %13, %4
  %17 = phi i32 [ %.pre, %13 ], [ %9, %4 ]
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = tail call ptr @findEntry(ptr noundef %19, i32 noundef %17, ptr noundef %1)
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %30

23:                                               ; preds = %16
  %24 = getelementptr inbounds i8, ptr %20, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !16
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %30

27:                                               ; preds = %23
  %28 = load i32, ptr %0, align 8, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %0, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %27, %23, %16
  store ptr %1, ptr %20, align 8, !tbaa !13
  %31 = getelementptr inbounds i8, ptr %20, i64 8
  store i32 %2, ptr %31, align 8, !tbaa !17
  %.sroa.216.0..sroa_idx = getelementptr inbounds i8, ptr %20, i64 16
  store i64 %3, ptr %.sroa.216.0..sroa_idx, align 8, !tbaa !18
  ret i1 %22
}

; Function Attrs: nounwind uwtable
declare hidden void @adjustCapacity(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @findEntry(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

!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 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 8}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !15, i64 8}
!15 = !{!"", !7, i64 0, !8, i64 8}
!16 = !{!14, !7, i64 8}
!17 = !{!7, !7, i64 0}
!18 = !{!8, !8, i64 0}


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