; LLVM IR from devantler/software-engineering-f22-shared :: IOT/BudgetManagementExcercise-03-28/ESP-Project/components/components/nghttp (merge)

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

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

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

; 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 @ht_copy(ptr 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

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

; Function Attrs: nounwind uwtable
define dso_local void @mrb_hash_merge(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4) #0 {
  %6 = alloca %struct.mrb_value, align 8
  %7 = alloca %struct.mrb_value, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.mrb_value, align 8
  %12 = alloca i32, align 4
  %13 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  store i64 %1, ptr %13, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  store i32 %2, ptr %14, align 8
  %15 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  store i64 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  store i32 %4, ptr %16, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  %21 = load i32, ptr %20, align 8
  call void @mrb_hash_modify(ptr noundef %17, i64 %19, i32 %21)
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %24 = load i64, ptr %23, align 8
  %25 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %26 = load i32, ptr %25, align 8
  %27 = call { i64, i32 } @mrb_ensure_hash_type(ptr noundef %22, i64 %24, i32 %26)
  %28 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %29 = extractvalue { i64, i32 } %27, 0
  store i64 %29, ptr %28, align 8
  %30 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %31 = extractvalue { i64, i32 } %27, 1
  store i32 %31, ptr %30, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  %32 = getelementptr inbounds %struct.mrb_value, ptr %6, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !10
  %34 = getelementptr inbounds %struct.RHash, ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  store ptr %35, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.mrb_value, ptr %7, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !10
  %38 = getelementptr inbounds %struct.RHash, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  store ptr %39, ptr %10, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %5
  store i32 1, ptr %12, align 4
  br label %60

43:                                               ; preds = %5
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %53, label %46

46:                                               ; preds = %43
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = call ptr @ht_copy(ptr noundef %47, ptr noundef %48)
  %50 = getelementptr inbounds %struct.mrb_value, ptr %6, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !10
  %52 = getelementptr inbounds %struct.RHash, ptr %51, i32 0, i32 4
  store ptr %49, ptr %52, align 8, !tbaa !13
  store i32 1, ptr %12, align 4
  br label %60

53:                                               ; preds = %43
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  call void @ht_foreach(ptr noundef %54, ptr noundef %55, ptr noundef @merge_i, ptr noundef %56)
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mrb_value, ptr %6, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !10
  call void @mrb_write_barrier(ptr noundef %57, ptr noundef %59)
  store i32 1, ptr %12, align 4
  br label %60

60:                                               ; preds = %53, %46, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

declare { i64, i32 } @mrb_ensure_hash_type(ptr noundef, i64, i32) #3

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

declare void @mrb_write_barrier(ptr noundef, ptr noundef) #3

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 = { "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 = !{i64 0, i64 8, !10, i64 8, i64 4, !11}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 32}
!14 = !{!"RHash", !12, i64 0, !12, i64 1, !12, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}


; 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
declare hidden void @ht_foreach(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mrb_hash_merge(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4) local_unnamed_addr #0 {
  tail call void @mrb_hash_modify(ptr noundef %0, i64 %1, i32 %2)
  %6 = tail call { i64, i32 } @mrb_ensure_hash_type(ptr noundef %0, i64 %3, i32 %4) #2
  %7 = extractvalue { i64, i32 } %6, 0
  %.sroa.013.0..sroa.013.0..cast = inttoptr i64 %1 to ptr
  %8 = getelementptr inbounds i8, ptr %.sroa.013.0..sroa.013.0..cast, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.sroa.010.0..sroa.010.0..cast = inttoptr i64 %7 to ptr
  %10 = getelementptr inbounds i8, ptr %.sroa.010.0..sroa.010.0..cast, i64 32
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %16, label %12

12:                                               ; preds = %5
  %.not21 = icmp eq ptr %9, null
  br i1 %.not21, label %13, label %15

13:                                               ; preds = %12
  %14 = tail call ptr @ht_copy(ptr noundef %0, ptr noundef nonnull %11)
  store ptr %14, ptr %8, align 8, !tbaa !5
  br label %16

15:                                               ; preds = %12
  tail call void @ht_foreach(ptr noundef %0, ptr noundef nonnull %11, ptr noundef nonnull @merge_i, ptr noundef nonnull %9)
  tail call void @mrb_write_barrier(ptr noundef %0, ptr noundef nonnull %.sroa.013.0..sroa.013.0..cast) #2
  br label %16

16:                                               ; preds = %5, %15, %13
  ret void
}

declare { i64, i32 } @mrb_ensure_hash_type(ptr noundef, i64, i32) local_unnamed_addr #1

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

declare void @mrb_write_barrier(ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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, !10, i64 32}
!6 = !{!"RHash", !7, i64 0, !7, i64 1, !7, i64 1, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}


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