; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_map)

; 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.HandleList = type { %struct.MList, i32, i32, i32, i32 }
%struct.MList = type { i32, ptr }

@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1

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

declare ptr @m_Malloc(i32 noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @MapOverWrite(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @mMapCreate() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %3 = call ptr @m_Malloc(i32 noundef 2048)
  store ptr %3, ptr %1, align 8, !tbaa !5
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 2048, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = ptrtoint ptr %5 to i64
  %7 = add nsw i64 %6, 0
  %8 = icmp sle i64 %7, 16384
  br i1 %8, label %9, label %20

9:                                                ; preds = %0
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = ptrtoint ptr %10 to i64
  %12 = add nsw i64 %11, 0
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %9
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = ptrtoint ptr %15 to i64
  %17 = add nsw i64 %16, 0
  %18 = trunc i64 %17 to i32
  %19 = call ptr @m_ObjectCreate(ptr noundef null, i32 noundef %18)
  br label %26

20:                                               ; preds = %9, %0
  %21 = load ptr, ptr %1, align 8, !tbaa !5
  %22 = ptrtoint ptr %21 to i64
  %23 = add nsw i64 %22, 0
  %24 = inttoptr i64 %23 to ptr
  %25 = call ptr @m_ObjectCreate(ptr noundef %24, i32 noundef -1)
  br label %26

26:                                               ; preds = %20, %14
  %27 = phi ptr [ %19, %14 ], [ %25, %20 ]
  store ptr %27, ptr %2, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.HandleList, ptr %28, i64 -1
  %30 = getelementptr inbounds %struct.HandleList, ptr %29, i32 0, i32 4
  store i32 427716643, ptr %30, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_PropertyFunction(ptr noundef %32, ptr noundef @.str.8, ptr noundef @MapOverWrite, ptr noundef %33)
  br label %34

34:                                               ; preds = %31
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret ptr %36
}

declare ptr @m_ObjectCreate(ptr noundef, i32 noundef) #1

declare void @m_PropertyFunction(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { 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, !12, i64 28}
!10 = !{!"HandleList", !11, i64 0, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!11 = !{!"MList", !12, i64 0, !6, i64 8}
!12 = !{!"int", !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"

@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local void @MapOverWrite(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @mMapCreate() local_unnamed_addr #2 {
  %1 = tail call ptr @m_Malloc(i32 noundef 2048) #3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(2048) %1, i8 0, i64 2048, i1 false)
  %2 = icmp slt ptr %1, inttoptr (i64 16385 to ptr)
  %3 = icmp sgt ptr %1, null
  %or.cond = and i1 %2, %3
  br i1 %or.cond, label %4, label %8

4:                                                ; preds = %0
  %5 = ptrtoint ptr %1 to i64
  %6 = trunc nuw nsw i64 %5 to i32
  %7 = tail call ptr @m_ObjectCreate(ptr noundef null, i32 noundef %6) #3
  br label %10

8:                                                ; preds = %0
  %9 = tail call ptr @m_ObjectCreate(ptr noundef nonnull %1, i32 noundef -1) #3
  br label %10

10:                                               ; preds = %8, %4
  %11 = phi ptr [ %7, %4 ], [ %9, %8 ]
  %12 = getelementptr inbounds i8, ptr %11, i64 -4
  store i32 427716643, ptr %12, align 4, !tbaa !5
  tail call void @m_PropertyFunction(ptr noundef %11, ptr noundef nonnull @.str.8, ptr noundef nonnull @MapOverWrite, ptr noundef %11) #3
  ret ptr %11
}

declare ptr @m_ObjectCreate(ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @m_PropertyFunction(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !8, i64 28}
!6 = !{!"HandleList", !7, i64 0, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28}
!7 = !{!"MList", !8, i64 0, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}


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