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

; 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.RClass = type { i32, ptr, ptr, ptr, ptr, ptr }

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @mrb_obj_iv_get(ptr noundef, ptr noundef, i32 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: nounwind uwtable
declare hidden zeroext i8 @iv_get(ptr noundef, 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

; 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 @iv_new(ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mrb_mod_cv_set(ptr noundef %0, ptr noundef %1, i32 noundef %2, i64 %3, i32 %4) #0 {
  %6 = alloca %struct.mrb_value, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.mrb_value, align 8
  %14 = alloca %struct.mrb_value, align 8
  %15 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  store i64 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  store i32 %4, ptr %16, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %17, ptr %10, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %46, %5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %47

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.RClass, ptr %22, i32 0, i32 3
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  store ptr %24, ptr %11, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = call zeroext i8 @iv_get(ptr noundef %25, ptr noundef %26, i32 noundef %27, ptr noundef null)
  %29 = icmp ne i8 %28, 0
  br i1 %29, label %30, label %40

30:                                               ; preds = %21
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  %35 = load i64, ptr %34, align 8
  %36 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  %37 = load i32, ptr %36, align 8
  call void @iv_put(ptr noundef %31, ptr noundef %32, i32 noundef %33, i64 %35, i32 %37)
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mrb_write_barrier(ptr noundef %38, ptr noundef %39)
  store i32 1, ptr %12, align 4
  br label %44

40:                                               ; preds = %21
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.RClass, ptr %41, i32 0, i32 5
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  store ptr %43, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %44

44:                                               ; preds = %40, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %45 = load i32, ptr %12, align 4
  switch i32 %45, label %97 [
    i32 0, label %46
  ]

46:                                               ; preds = %44
  br label %18, !llvm.loop !14

47:                                               ; preds = %18
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %73

50:                                               ; preds = %47
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = load i32, ptr %51, align 8
  %53 = and i32 %52, 255
  %54 = icmp eq i32 %53, 12
  br i1 %54, label %55, label %73

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = call i32 @mrb_intern_static(ptr noundef %58, ptr noundef @.str.8, i64 noundef 12)
  %60 = call { i64, i32 } @mrb_obj_iv_get(ptr noundef %56, ptr noundef %57, i32 noundef %59)
  %61 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 0
  %62 = extractvalue { i64, i32 } %60, 0
  store i64 %62, ptr %61, align 8
  %63 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 1
  %64 = extractvalue { i64, i32 } %60, 1
  store i32 %64, ptr %63, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %14, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  %65 = getelementptr inbounds %struct.mrb_value, ptr %13, i32 0, i32 1
  %66 = load i32, ptr %65, align 8, !tbaa !18
  switch i32 %66, label %70 [
    i32 9, label %67
    i32 10, label %67
    i32 12, label %67
  ]

67:                                               ; preds = %55, %55, %55
  %68 = getelementptr inbounds %struct.mrb_value, ptr %13, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  store ptr %69, ptr %8, align 8, !tbaa !5
  br label %72

70:                                               ; preds = %55
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %71, ptr %8, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %70, %67
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  br label %75

73:                                               ; preds = %50, %47
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %74, ptr %8, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %73, %72
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.RClass, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  %79 = icmp ne ptr %78, null
  br i1 %79, label %85, label %80

80:                                               ; preds = %75
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = call ptr @iv_new(ptr noundef %81)
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.RClass, ptr %83, i32 0, i32 3
  store ptr %82, ptr %84, align 8, !tbaa !11
  br label %85

85:                                               ; preds = %80, %75
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.RClass, ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !11
  %90 = load i32, ptr %9, align 4, !tbaa !9
  %91 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  %92 = load i64, ptr %91, align 8
  %93 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  %94 = load i32, ptr %93, align 8
  call void @iv_put(ptr noundef %86, ptr noundef %89, i32 noundef %90, i64 %92, i32 %94)
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mrb_write_barrier(ptr noundef %95, ptr noundef %96)
  store i32 0, ptr %12, align 4
  br label %97

97:                                               ; preds = %85, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %98 = load i32, ptr %12, align 4
  switch i32 %98, label %100 [
    i32 0, label %99
    i32 1, label %99
  ]

99:                                               ; preds = %97, %97
  ret void

100:                                              ; preds = %97
  unreachable
}

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 24}
!12 = !{!"RClass", !10, i64 0, !10, i64 1, !10, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!12, !6, i64 40}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 8, !17, i64 8, i64 4, !9}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !10, i64 8}
!19 = !{!"mrb_value", !7, i64 0, !10, i64 8}


; 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 [13 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @mrb_obj_iv_get(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

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

declare void @mrb_write_barrier(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @mrb_mod_cv_set(ptr noundef %0, ptr noundef %1, i32 noundef %2, i64 %3, i32 %4) local_unnamed_addr #0 {
  %.not39 = icmp eq ptr %1, null
  br i1 %.not39, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %9
  %.040 = phi ptr [ %11, %9 ], [ %1, %5 ]
  %6 = getelementptr inbounds i8, ptr %.040, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call zeroext i8 @iv_get(ptr noundef %0, ptr noundef %7, i32 noundef %2, ptr noundef null)
  %.not36 = icmp eq i8 %8, 0
  br i1 %.not36, label %9, label %.thread

9:                                                ; preds = %.lr.ph
  %10 = getelementptr inbounds i8, ptr %.040, i64 40
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %9, %5
  %.not34 = icmp ne ptr %1, null
  tail call void @llvm.assume(i1 %.not34)
  %12 = load i32, ptr %1, align 8
  %13 = and i32 %12, 255
  %14 = icmp eq i32 %13, 12
  br i1 %14, label %15, label %22

15:                                               ; preds = %._crit_edge
  %16 = tail call i32 @mrb_intern_static(ptr noundef %0, ptr noundef nonnull @.str.8, i64 noundef 12) #3
  %17 = tail call { i64, i32 } @mrb_obj_iv_get(ptr noundef %0, ptr noundef nonnull %1, i32 noundef %16)
  %18 = extractvalue { i64, i32 } %17, 1
  switch i32 %18, label %22 [
    i32 9, label %19
    i32 10, label %19
    i32 12, label %19
  ]

19:                                               ; preds = %15, %15, %15
  %20 = extractvalue { i64, i32 } %17, 0
  %21 = inttoptr i64 %20 to ptr
  br label %22

22:                                               ; preds = %19, %15, %._crit_edge
  %.3 = phi ptr [ %1, %._crit_edge ], [ %21, %19 ], [ %1, %15 ]
  %23 = getelementptr inbounds i8, ptr %.3, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %.not35 = icmp eq ptr %24, null
  br i1 %.not35, label %25, label %.thread

25:                                               ; preds = %22
  %26 = tail call ptr @iv_new(ptr noundef %0)
  store ptr %26, ptr %23, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %.lr.ph, %22, %25
  %.lcssa.sink = phi ptr [ %26, %25 ], [ %24, %22 ], [ %7, %.lr.ph ]
  %.040.lcssa.sink = phi ptr [ %.3, %25 ], [ %.3, %22 ], [ %.040, %.lr.ph ]
  tail call void @iv_put(ptr noundef %0, ptr noundef %.lcssa.sink, i32 noundef %2, i64 %3, i32 %4)
  tail call void @mrb_write_barrier(ptr noundef %0, ptr noundef nonnull %.040.lcssa.sink) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
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 24}
!6 = !{!"RClass", !7, i64 0, !7, i64 1, !7, i64 1, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 40}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass