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

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

@.str = external hidden unnamed_addr constant [8 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

; 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
define dso_local { i64, i32 } @mrb_hash_get(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4) #1 {
  %6 = alloca %struct.mrb_value, align 8
  %7 = alloca %struct.mrb_value, align 8
  %8 = alloca %struct.mrb_value, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.mrb_value, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  store i64 %1, ptr %13, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  store i32 %2, ptr %14, align 8
  %15 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  store i64 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  store i32 %4, ptr %16, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mrb_value, ptr %7, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.RHash, ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !10
  %22 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %25 = load i32, ptr %24, align 8
  %26 = call zeroext i8 @ht_get(ptr noundef %17, ptr noundef %21, i64 %23, i32 %25, ptr noundef %10)
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !13
  store i32 1, ptr %12, align 4
  br label %67

29:                                               ; preds = %5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = call i32 @mrb_intern_static(ptr noundef %30, ptr noundef @.str, i64 noundef 7)
  store i32 %31, ptr %11, align 4, !tbaa !14
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load i32, ptr %11, align 4, !tbaa !14
  %34 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %35 = load i64, ptr %34, align 8
  %36 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %37 = load i32, ptr %36, align 8
  %38 = call zeroext i8 @mrb_func_basic_p(ptr noundef %32, i64 %35, i32 %37, i32 noundef %33, ptr noundef @mrb_hash_default)
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %55

40:                                               ; preds = %29
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %43 = load i64, ptr %42, align 8
  %44 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %45 = load i32, ptr %44, align 8
  %46 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %47 = load i64, ptr %46, align 8
  %48 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %49 = load i32, ptr %48, align 8
  %50 = call { i64, i32 } @hash_default(ptr noundef %41, i64 %43, i32 %45, i64 %47, i32 %49)
  %51 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  %52 = extractvalue { i64, i32 } %50, 0
  store i64 %52, ptr %51, align 8
  %53 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  %54 = extractvalue { i64, i32 } %50, 1
  store i32 %54, ptr %53, align 8
  store i32 1, ptr %12, align 4
  br label %67

55:                                               ; preds = %29
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = load i32, ptr %11, align 4, !tbaa !14
  %58 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %59 = load i64, ptr %58, align 8
  %60 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %61 = load i32, ptr %60, align 8
  %62 = call { i64, i32 } @mrb_funcall_argv(ptr noundef %56, i64 %59, i32 %61, i32 noundef %57, i64 noundef 1, ptr noundef %8)
  %63 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  %64 = extractvalue { i64, i32 } %62, 0
  store i64 %64, ptr %63, align 8
  %65 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  %66 = extractvalue { i64, i32 } %62, 1
  store i32 %66, ptr %65, align 8
  store i32 1, ptr %12, align 4
  br label %67

67:                                               ; preds = %55, %40, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  %68 = load { i64, i32 }, ptr %6, align 8
  ret { i64, i32 } %68
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @ht_get(ptr noundef, ptr noundef, i64, i32, ptr noundef) #1

; 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

declare i32 @mrb_intern_static(ptr noundef, ptr noundef, i64 noundef) #3

declare zeroext i8 @mrb_func_basic_p(ptr noundef, i64, i32, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @mrb_hash_default(ptr noundef, i64, i32) #1

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @hash_default(ptr noundef, i64, i32, i64, i32) #1

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

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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 32}
!11 = !{!"RHash", !12, i64 0, !12, i64 1, !12, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 8, !9, i64 8, i64 4, !14}
!14 = !{!12, !12, 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.mrb_value = type { %union.anon, i32 }
%union.anon = type { double }

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

; 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
define dso_local { i64, i32 } @mrb_hash_get(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4) local_unnamed_addr #1 {
  %6 = alloca %struct.mrb_value, align 8
  %7 = alloca %struct.mrb_value, align 8
  store i64 %3, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %4, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #3
  %.sroa.0.0..sroa.0.0..cast = inttoptr i64 %1 to ptr
  %9 = getelementptr inbounds i8, ptr %.sroa.0.0..sroa.0.0..cast, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = call zeroext i8 @ht_get(ptr noundef %0, ptr noundef %10, i64 %3, i32 %4, ptr noundef nonnull %7)
  %.not = icmp eq i8 %11, 0
  br i1 %.not, label %13, label %12

12:                                               ; preds = %5
  %.sroa.011.0.copyload = load i64, ptr %7, align 8, !tbaa !11
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !12
  br label %24

13:                                               ; preds = %5
  %14 = call i32 @mrb_intern_static(ptr noundef %0, ptr noundef nonnull @.str, i64 noundef 7) #3
  %15 = call zeroext i8 @mrb_func_basic_p(ptr noundef %0, i64 %1, i32 %2, i32 noundef %14, ptr noundef nonnull @mrb_hash_default) #3
  %.not13 = icmp eq i8 %15, 0
  br i1 %.not13, label %20, label %16

16:                                               ; preds = %13
  %17 = call { i64, i32 } @hash_default(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4)
  %18 = extractvalue { i64, i32 } %17, 0
  %19 = extractvalue { i64, i32 } %17, 1
  br label %24

20:                                               ; preds = %13
  %21 = call { i64, i32 } @mrb_funcall_argv(ptr noundef %0, i64 %1, i32 %2, i32 noundef %14, i64 noundef 1, ptr noundef nonnull %6) #3
  %22 = extractvalue { i64, i32 } %21, 0
  %23 = extractvalue { i64, i32 } %21, 1
  br label %24

24:                                               ; preds = %20, %16, %12
  %.sroa.011.0 = phi i64 [ %.sroa.011.0.copyload, %12 ], [ %18, %16 ], [ %22, %20 ]
  %.sroa.4.0 = phi i32 [ %.sroa.4.0.copyload, %12 ], [ %19, %16 ], [ %23, %20 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #3
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.011.0, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.sroa.4.0, 1
  ret { i64, i32 } %.fca.1.insert
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @ht_get(ptr noundef, ptr noundef, i64, i32, ptr noundef) local_unnamed_addr #1

declare i32 @mrb_intern_static(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare zeroext i8 @mrb_func_basic_p(ptr noundef, i64, i32, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @mrb_hash_default(ptr noundef, i64, i32) #1

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @hash_default(ptr noundef, i64, i32, i64, i32) local_unnamed_addr #1

declare { i64, i32 } @mrb_funcall_argv(ptr noundef, i64, i32, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

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 = { "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, !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}
!11 = !{!8, !8, i64 0}
!12 = !{!7, !7, i64 0}


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