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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mrb_const_set(ptr noundef %0, i64 %1, i32 %2, i32 noundef %3, i64 %4, i32 %5) #0 {
  %7 = alloca %struct.mrb_value, align 8
  %8 = alloca %struct.mrb_value, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  store i64 %1, ptr %11, align 8
  %12 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  store i32 %2, ptr %12, align 8
  %13 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  store i64 %4, ptr %13, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  store i32 %5, ptr %14, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %19 = load i32, ptr %18, align 8
  call void @mod_const_check(ptr noundef %15, i64 %17, i32 %19)
  %20 = getelementptr inbounds %struct.mrb_value, ptr %8, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = icmp eq i32 %21, 9
  br i1 %22, label %27, label %23

23:                                               ; preds = %6
  %24 = getelementptr inbounds %struct.mrb_value, ptr %8, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp eq i32 %25, 10
  br i1 %26, label %27, label %34

27:                                               ; preds = %23, %6
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mrb_value, ptr %7, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = getelementptr inbounds %struct.mrb_value, ptr %8, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load i32, ptr %10, align 4, !tbaa !9
  call void @mrb_class_name_class(ptr noundef %28, ptr noundef %30, ptr noundef %32, i32 noundef %33)
  br label %34

34:                                               ; preds = %27, %23
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %38 = load i64, ptr %37, align 8
  %39 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %40 = load i32, ptr %39, align 8
  %41 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %42 = load i64, ptr %41, align 8
  %43 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %44 = load i32, ptr %43, align 8
  call void @mrb_iv_set(ptr noundef %35, i64 %38, i32 %40, i32 noundef %36, i64 %42, i32 %44)
  ret void
}

declare void @mrb_class_name_class(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #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" }

!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, !10, i64 8}
!12 = !{!"mrb_value", !7, i64 0, !10, i64 8}
!13 = !{!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
declare dso_local void @mrb_iv_set(ptr noundef, i64, i32, i32 noundef, i64, i32) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @mrb_const_set(ptr noundef %0, i64 %1, i32 %2, i32 noundef %3, i64 %4, i32 %5) local_unnamed_addr #0 {
  tail call void @mod_const_check(ptr noundef %0, i64 %1, i32 %2)
  %7 = add i32 %5, -9
  %or.cond = icmp ult i32 %7, 2
  br i1 %or.cond, label %8, label %11

8:                                                ; preds = %6
  %9 = inttoptr i64 %4 to ptr
  %10 = inttoptr i64 %1 to ptr
  tail call void @mrb_class_name_class(ptr noundef %0, ptr noundef %10, ptr noundef %9, i32 noundef %3) #2
  br label %11

11:                                               ; preds = %6, %8
  tail call void @mrb_iv_set(ptr noundef %0, i64 %1, i32 %2, i32 noundef %3, i64 %4, i32 %5)
  ret void
}

declare void @mrb_class_name_class(ptr noundef, ptr noundef, ptr noundef, i32 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)"}


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