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

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

@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [2 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

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

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_any_to_s(ptr noundef %0, i64 %1, i32 %2) #2 {
  %4 = alloca %struct.mrb_value, align 8
  %5 = alloca %struct.mrb_value, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.mrb_value, 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 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  store i64 %1, ptr %13, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  store i32 %2, ptr %14, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call { i64, i32 } @mrb_str_new_capa(ptr noundef %15, i64 noundef 20)
  %17 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0
  %18 = extractvalue { i64, i32 } %16, 0
  store i64 %18, ptr %17, align 8
  %19 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1
  %20 = extractvalue { i64, i32 } %16, 1
  store i32 %20, ptr %19, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  %25 = load i32, ptr %24, align 8
  %26 = call ptr @mrb_obj_classname(ptr noundef %21, i64 %23, i32 %25)
  store ptr %26, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0
  %29 = load i64, ptr %28, align 8
  %30 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1
  %31 = load i32, ptr %30, align 8
  %32 = call { i64, i32 } @mrb_str_cat(ptr noundef %27, i64 %29, i32 %31, ptr noundef @.str.18, i64 noundef 2)
  %33 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %34 = extractvalue { i64, i32 } %32, 0
  store i64 %34, ptr %33, align 8
  %35 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %36 = extractvalue { i64, i32 } %32, 1
  store i32 %36, ptr %35, align 8
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0
  %40 = load i64, ptr %39, align 8
  %41 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1
  %42 = load i32, ptr %41, align 8
  %43 = call { i64, i32 } @mrb_str_cat_cstr(ptr noundef %37, i64 %40, i32 %42, ptr noundef %38)
  %44 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %45 = extractvalue { i64, i32 } %43, 0
  store i64 %45, ptr %44, align 8
  %46 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %47 = extractvalue { i64, i32 } %43, 1
  store i32 %47, ptr %46, align 8
  %48 = getelementptr inbounds %struct.mrb_value, ptr %5, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = icmp ult i32 %49, 8
  br i1 %50, label %79, label %51

51:                                               ; preds = %3
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0
  %54 = load i64, ptr %53, align 8
  %55 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1
  %56 = load i32, ptr %55, align 8
  %57 = call { i64, i32 } @mrb_str_cat(ptr noundef %52, i64 %54, i32 %56, ptr noundef @.str.19, i64 noundef 1)
  %58 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 0
  %59 = extractvalue { i64, i32 } %57, 0
  store i64 %59, ptr %58, align 8
  %60 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 1
  %61 = extractvalue { i64, i32 } %57, 1
  store i32 %61, ptr %60, align 8
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mrb_value, ptr %5, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !12
  %66 = call { i64, i32 } @mrb_ptr_to_str(ptr noundef %63, ptr noundef %65)
  %67 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %68 = extractvalue { i64, i32 } %66, 0
  store i64 %68, ptr %67, align 8
  %69 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %70 = extractvalue { i64, i32 } %66, 1
  store i32 %70, ptr %69, align 8
  %71 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0
  %72 = load i64, ptr %71, align 8
  %73 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1
  %74 = load i32, ptr %73, align 8
  %75 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %76 = load i64, ptr %75, align 8
  %77 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %78 = load i32, ptr %77, align 8
  call void @mrb_str_concat(ptr noundef %62, i64 %72, i32 %74, i64 %76, i32 %78)
  br label %79

79:                                               ; preds = %51, %3
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 0
  %82 = load i64, ptr %81, align 8
  %83 = getelementptr inbounds { i64, i32 }, ptr %4, i32 0, i32 1
  %84 = load i32, ptr %83, align 8
  %85 = call { i64, i32 } @mrb_str_cat(ptr noundef %80, i64 %82, i32 %84, ptr noundef @.str.20, i64 noundef 1)
  %86 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %87 = extractvalue { i64, i32 } %85, 0
  store i64 %87, ptr %86, align 8
  %88 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %89 = extractvalue { i64, i32 } %85, 1
  store i32 %89, ptr %88, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %90 = load { i64, i32 }, ptr %4, align 8
  ret { i64, i32 } %90
}

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

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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, !11, i64 8}
!10 = !{!"mrb_value", !7, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!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"

@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_any_to_s(ptr noundef %0, i64 %1, i32 %2) local_unnamed_addr #1 {
  %4 = tail call { i64, i32 } @mrb_str_new_capa(ptr noundef %0, i64 noundef 20) #2
  %5 = extractvalue { i64, i32 } %4, 0
  %6 = extractvalue { i64, i32 } %4, 1
  %7 = tail call ptr @mrb_obj_classname(ptr noundef %0, i64 %1, i32 %2) #2
  %8 = tail call { i64, i32 } @mrb_str_cat(ptr noundef %0, i64 %5, i32 %6, ptr noundef nonnull @.str.18, i64 noundef 2) #2
  %9 = tail call { i64, i32 } @mrb_str_cat_cstr(ptr noundef %0, i64 %5, i32 %6, ptr noundef %7) #2
  %10 = icmp ult i32 %2, 8
  br i1 %10, label %17, label %11

11:                                               ; preds = %3
  %12 = inttoptr i64 %1 to ptr
  %13 = tail call { i64, i32 } @mrb_str_cat(ptr noundef %0, i64 %5, i32 %6, ptr noundef nonnull @.str.19, i64 noundef 1) #2
  %14 = tail call { i64, i32 } @mrb_ptr_to_str(ptr noundef %0, ptr noundef %12) #2
  %15 = extractvalue { i64, i32 } %14, 0
  %16 = extractvalue { i64, i32 } %14, 1
  tail call void @mrb_str_concat(ptr noundef %0, i64 %5, i32 %6, i64 %15, i32 %16) #2
  br label %17

17:                                               ; preds = %11, %3
  %18 = tail call { i64, i32 } @mrb_str_cat(ptr noundef %0, i64 %5, i32 %6, ptr noundef nonnull @.str.20, i64 noundef 1) #2
  ret { i64, i32 } %4
}

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

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

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

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

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

attributes #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 = { 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 = { 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,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass