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

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

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden i64 @iv_size(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: inlinehint nounwind uwtable
declare hidden { i64, i32 } @mrb_obj_value(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_obj_iv_inspect(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca %struct.mrb_value, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.mrb_value, align 8
  %10 = alloca %struct.mrb_value, align 8
  %11 = alloca %struct.mrb_value, align 8
  %12 = alloca %struct.mrb_value, align 8
  %13 = alloca %struct.mrb_value, align 8
  %14 = alloca %struct.mrb_value, align 8
  %15 = alloca i32, align 4
  %16 = alloca %struct.mrb_value, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.RObject, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call i64 @iv_size(ptr noundef %20, ptr noundef %21)
  store i64 %22, ptr %7, align 8, !tbaa !12
  %23 = load i64, ptr %7, align 8, !tbaa !12
  %24 = icmp ugt i64 %23, 0
  br i1 %24, label %25, label %103

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call { i64, i32 } @mrb_obj_value(ptr noundef %27)
  %29 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %30 = extractvalue { i64, i32 } %28, 0
  store i64 %30, ptr %29, align 8
  %31 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %32 = extractvalue { i64, i32 } %28, 1
  store i32 %32, ptr %31, align 8
  %33 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %34 = load i64, ptr %33, align 8
  %35 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %36 = load i32, ptr %35, align 8
  %37 = call ptr @mrb_obj_classname(ptr noundef %26, i64 %34, i32 %36)
  store ptr %37, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call { i64, i32 } @mrb_str_new_capa(ptr noundef %38, i64 noundef 30)
  %40 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %41 = extractvalue { i64, i32 } %39, 0
  store i64 %41, ptr %40, align 8
  %42 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %43 = extractvalue { i64, i32 } %39, 1
  store i32 %43, ptr %42, align 8
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %46 = load i64, ptr %45, align 8
  %47 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %48 = load i32, ptr %47, align 8
  %49 = call { i64, i32 } @mrb_str_cat(ptr noundef %44, i64 %46, i32 %48, ptr noundef @.str.5, i64 noundef 2)
  %50 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 0
  %51 = extractvalue { i64, i32 } %49, 0
  store i64 %51, ptr %50, align 8
  %52 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 1
  %53 = extractvalue { i64, i32 } %49, 1
  store i32 %53, ptr %52, align 8
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %57 = load i64, ptr %56, align 8
  %58 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %59 = load i32, ptr %58, align 8
  %60 = call { i64, i32 } @mrb_str_cat_cstr(ptr noundef %54, i64 %57, i32 %59, ptr noundef %55)
  %61 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %62 = extractvalue { i64, i32 } %60, 0
  store i64 %62, ptr %61, align 8
  %63 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %64 = extractvalue { i64, i32 } %60, 1
  store i32 %64, ptr %63, align 8
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %67 = load i64, ptr %66, align 8
  %68 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %69 = load i32, ptr %68, align 8
  %70 = call { i64, i32 } @mrb_str_cat(ptr noundef %65, i64 %67, i32 %69, ptr noundef @.str.6, i64 noundef 1)
  %71 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %72 = extractvalue { i64, i32 } %70, 0
  store i64 %72, ptr %71, align 8
  %73 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %74 = extractvalue { i64, i32 } %70, 1
  store i32 %74, ptr %73, align 8
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = call { i64, i32 } @mrb_ptr_to_str(ptr noundef %76, ptr noundef %77)
  %79 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 0
  %80 = extractvalue { i64, i32 } %78, 0
  store i64 %80, ptr %79, align 8
  %81 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 1
  %82 = extractvalue { i64, i32 } %78, 1
  store i32 %82, ptr %81, align 8
  %83 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %84 = load i64, ptr %83, align 8
  %85 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %86 = load i32, ptr %85, align 8
  %87 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 0
  %88 = load i64, ptr %87, align 8
  %89 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 1
  %90 = load i32, ptr %89, align 8
  call void @mrb_str_concat(ptr noundef %75, i64 %84, i32 %86, i64 %88, i32 %90)
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  call void @iv_foreach(ptr noundef %91, ptr noundef %92, ptr noundef @inspect_i, ptr noundef %3)
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %95 = load i64, ptr %94, align 8
  %96 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %97 = load i32, ptr %96, align 8
  %98 = call { i64, i32 } @mrb_str_cat(ptr noundef %93, i64 %95, i32 %97, ptr noundef @.str.7, i64 noundef 1)
  %99 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 0
  %100 = extractvalue { i64, i32 } %98, 0
  store i64 %100, ptr %99, align 8
  %101 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 1
  %102 = extractvalue { i64, i32 } %98, 1
  store i32 %102, ptr %101, align 8
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %120

103:                                              ; preds = %2
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = call { i64, i32 } @mrb_obj_value(ptr noundef %105)
  %107 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %108 = extractvalue { i64, i32 } %106, 0
  store i64 %108, ptr %107, align 8
  %109 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %110 = extractvalue { i64, i32 } %106, 1
  store i32 %110, ptr %109, align 8
  %111 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %112 = load i64, ptr %111, align 8
  %113 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %114 = load i32, ptr %113, align 8
  %115 = call { i64, i32 } @mrb_any_to_s(ptr noundef %104, i64 %112, i32 %114)
  %116 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 0
  %117 = extractvalue { i64, i32 } %115, 0
  store i64 %117, ptr %116, align 8
  %118 = getelementptr inbounds { i64, i32 }, ptr %3, i32 0, i32 1
  %119 = extractvalue { i64, i32 } %115, 1
  store i32 %119, ptr %118, align 8
  store i32 1, ptr %15, align 4
  br label %120

120:                                              ; preds = %103, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %121 = load { i64, i32 }, ptr %3, align 8
  ret { i64, i32 } %121
}

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

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

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

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

declare void @mrb_str_concat(ptr noundef, i64, i32, i64, i32) #3

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

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

declare { i64, i32 } @mrb_any_to_s(ptr noundef, i64, i32) #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 = { inlinehint 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 = { "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, !6, i64 24}
!10 = !{!"RObject", !11, i64 0, !11, i64 1, !11, i64 1, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !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"

%struct.mrb_value = type { %union.anon, i32 }
%union.anon = type { double }

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_obj_iv_inspect(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mrb_value, align 8
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call i64 @iv_size(ptr noundef %0, ptr noundef %5)
  %.not = icmp eq i64 %6, 0
  %7 = tail call { i64, i32 } @mrb_obj_value(ptr noundef nonnull %1)
  %8 = extractvalue { i64, i32 } %7, 0
  %9 = extractvalue { i64, i32 } %7, 1
  br i1 %.not, label %25, label %10

10:                                               ; preds = %2
  %11 = tail call ptr @mrb_obj_classname(ptr noundef %0, i64 %8, i32 %9) #3
  %12 = tail call { i64, i32 } @mrb_str_new_capa(ptr noundef %0, i64 noundef 30) #3
  %13 = extractvalue { i64, i32 } %12, 0
  store i64 %13, ptr %3, align 8
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  %15 = extractvalue { i64, i32 } %12, 1
  store i32 %15, ptr %14, align 8
  %16 = tail call { i64, i32 } @mrb_str_cat(ptr noundef %0, i64 %13, i32 %15, ptr noundef nonnull @.str.5, i64 noundef 2) #3
  %17 = tail call { i64, i32 } @mrb_str_cat_cstr(ptr noundef %0, i64 %13, i32 %15, ptr noundef %11) #3
  %18 = tail call { i64, i32 } @mrb_str_cat(ptr noundef %0, i64 %13, i32 %15, ptr noundef nonnull @.str.6, i64 noundef 1) #3
  %19 = tail call { i64, i32 } @mrb_ptr_to_str(ptr noundef %0, ptr noundef nonnull %1) #3
  %20 = extractvalue { i64, i32 } %19, 0
  %21 = extractvalue { i64, i32 } %19, 1
  tail call void @mrb_str_concat(ptr noundef %0, i64 %13, i32 %15, i64 %20, i32 %21) #3
  call void @iv_foreach(ptr noundef %0, ptr noundef %5, ptr noundef nonnull @inspect_i, ptr noundef nonnull %3)
  %22 = load i64, ptr %3, align 8
  %23 = load i32, ptr %14, align 8
  %24 = call { i64, i32 } @mrb_str_cat(ptr noundef %0, i64 %22, i32 %23, ptr noundef nonnull @.str.7, i64 noundef 1) #3
  %.fca.0.load.pre = load i64, ptr %3, align 8
  %.fca.1.load.pre = load i32, ptr %14, align 8
  br label %29

25:                                               ; preds = %2
  %26 = tail call { i64, i32 } @mrb_any_to_s(ptr noundef %0, i64 %8, i32 %9) #3
  %27 = extractvalue { i64, i32 } %26, 0
  %28 = extractvalue { i64, i32 } %26, 1
  br label %29

29:                                               ; preds = %25, %10
  %.fca.1.load = phi i32 [ %28, %25 ], [ %.fca.1.load.pre, %10 ]
  %.fca.0.load = phi i64 [ %27, %25 ], [ %.fca.0.load.pre, %10 ]
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.fca.0.load, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.fca.1.load, 1
  ret { i64, i32 } %.fca.1.insert
}

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

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

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

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

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

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

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

declare { i64, i32 } @mrb_any_to_s(ptr noundef, i64, i32) local_unnamed_addr #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 = { inlinehint 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 24}
!6 = !{!"RObject", !7, i64 0, !7, i64 1, !7, i64 1, !10, i64 8, !10, i64 16, !10, i64 24}
!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: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass