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

; 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.RData = type { i32, ptr, ptr, ptr, ptr, ptr }
%struct.mrb_data_type = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 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: nounwind uwtable
define dso_local void @mrb_data_check_type(ptr noundef %0, i64 %1, i32 %2, ptr noundef %3) #1 {
  %5 = alloca %struct.mrb_value, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.mrb_value, align 8
  %10 = alloca %struct.mrb_value, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %struct.mrb_value, align 8
  %13 = alloca %struct.mrb_value, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  store i64 %1, ptr %14, align 8
  %15 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  store i32 %2, ptr %15, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %3, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mrb_value, ptr %5, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = icmp ne i32 %17, 21
  br i1 %18, label %19, label %25

19:                                               ; preds = %4
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  %22 = load i64, ptr %21, align 8
  %23 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  %24 = load i32, ptr %23, align 8
  call void @mrb_check_type(ptr noundef %20, i64 %22, i32 %24, i32 noundef 21)
  br label %25

25:                                               ; preds = %19, %4
  %26 = getelementptr inbounds %struct.mrb_value, ptr %5, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = getelementptr inbounds %struct.RData, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = icmp ne ptr %29, %30
  br i1 %31, label %32, label %94

32:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %33 = getelementptr inbounds %struct.mrb_value, ptr %5, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = getelementptr inbounds %struct.RData, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  store ptr %36, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %65

39:                                               ; preds = %32
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call ptr @mrb_exc_get(ptr noundef %41, ptr noundef @.str)
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mrb_data_type, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = call { i64, i32 } @mrb_str_new_cstr(ptr noundef %43, ptr noundef %46)
  %48 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %49 = extractvalue { i64, i32 } %47, 0
  store i64 %49, ptr %48, align 8
  %50 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %51 = extractvalue { i64, i32 } %47, 1
  store i32 %51, ptr %50, align 8
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mrb_data_type, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = call { i64, i32 } @mrb_str_new_cstr(ptr noundef %52, ptr noundef %55)
  %57 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 0
  %58 = extractvalue { i64, i32 } %56, 0
  store i64 %58, ptr %57, align 8
  %59 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 1
  %60 = extractvalue { i64, i32 } %56, 1
  store i32 %60, ptr %59, align 8
  %61 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %62 = load i64, ptr %61, align 8
  %63 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %64 = load i32, ptr %63, align 8
  call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %40, ptr noundef %42, ptr noundef @.str.1, i64 %62, i32 %64, ptr noundef byval(%struct.mrb_value) align 8 %10) #6
  unreachable

65:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  %68 = load i64, ptr %67, align 8
  %69 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  %70 = load i32, ptr %69, align 8
  %71 = call ptr @mrb_class(ptr noundef %66, i64 %68, i32 %70)
  store ptr %71, ptr %11, align 8, !tbaa !5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = call ptr @mrb_exc_get(ptr noundef %73, ptr noundef @.str)
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = call { i64, i32 } @mrb_obj_value(ptr noundef %75)
  %77 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %78 = extractvalue { i64, i32 } %76, 0
  store i64 %78, ptr %77, align 8
  %79 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %80 = extractvalue { i64, i32 } %76, 1
  store i32 %80, ptr %79, align 8
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.mrb_data_type, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !15
  %85 = call { i64, i32 } @mrb_str_new_cstr(ptr noundef %81, ptr noundef %84)
  %86 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 0
  %87 = extractvalue { i64, i32 } %85, 0
  store i64 %87, ptr %86, align 8
  %88 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 1
  %89 = extractvalue { i64, i32 } %85, 1
  store i32 %89, ptr %88, align 8
  %90 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %91 = load i64, ptr %90, align 8
  %92 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %93 = load i32, ptr %92, align 8
  call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %72, ptr noundef %74, ptr noundef @.str.2, i64 %91, i32 %93, ptr noundef byval(%struct.mrb_value) align 8 %13) #6
  unreachable

94:                                               ; preds = %25
  ret void
}

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

; Function Attrs: noreturn
declare void @mrb_raisef(ptr noundef, ptr noundef, ptr noundef, ...) #3

declare ptr @mrb_exc_get(ptr noundef, ptr noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mrb_class(ptr noundef, i64, i32) #4

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

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 = { "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 = { noreturn "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn }

!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}
!13 = !{!14, !6, i64 32}
!14 = !{!"RData", !11, i64 0, !11, i64 1, !11, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!16, !6, i64 0}
!16 = !{!"mrb_data_type", !6, i64 0, !6, 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"

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

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @mrb_data_check_type(ptr noundef %0, i64 %1, i32 %2, ptr noundef readonly %3) local_unnamed_addr #0 {
  %5 = alloca %struct.mrb_value, align 8
  %6 = alloca %struct.mrb_value, align 8
  %.not = icmp eq i32 %2, 21
  %7 = inttoptr i64 %1 to ptr
  br i1 %.not, label %9, label %8

8:                                                ; preds = %4
  tail call void @mrb_check_type(ptr noundef %0, i64 %1, i32 %2, i32 noundef 21) #4
  br label %9

9:                                                ; preds = %8, %4
  %10 = getelementptr inbounds i8, ptr %7, i64 32
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %.not25 = icmp eq ptr %11, %3
  br i1 %.not25, label %35, label %12

12:                                               ; preds = %9
  %.not26 = icmp eq ptr %11, null
  br i1 %.not26, label %24, label %13

13:                                               ; preds = %12
  %14 = tail call ptr @mrb_exc_get(ptr noundef %0, ptr noundef nonnull @.str) #4
  %15 = load ptr, ptr %11, align 8, !tbaa !11
  %16 = tail call { i64, i32 } @mrb_str_new_cstr(ptr noundef %0, ptr noundef %15) #4
  %17 = extractvalue { i64, i32 } %16, 0
  %18 = extractvalue { i64, i32 } %16, 1
  %19 = load ptr, ptr %3, align 8, !tbaa !11
  %20 = tail call { i64, i32 } @mrb_str_new_cstr(ptr noundef %0, ptr noundef %19) #4
  %21 = extractvalue { i64, i32 } %20, 0
  store i64 %21, ptr %5, align 8
  %22 = getelementptr inbounds i8, ptr %5, i64 8
  %23 = extractvalue { i64, i32 } %20, 1
  store i32 %23, ptr %22, align 8
  tail call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %0, ptr noundef %14, ptr noundef nonnull @.str.1, i64 %17, i32 %18, ptr noundef nonnull byval(%struct.mrb_value) align 8 %5) #5
  unreachable

24:                                               ; preds = %12
  %25 = tail call ptr @mrb_class(ptr noundef %0, i64 %1, i32 %2)
  %26 = tail call ptr @mrb_exc_get(ptr noundef %0, ptr noundef nonnull @.str) #4
  %27 = tail call { i64, i32 } @mrb_obj_value(ptr noundef %25)
  %28 = extractvalue { i64, i32 } %27, 0
  %29 = extractvalue { i64, i32 } %27, 1
  %30 = load ptr, ptr %3, align 8, !tbaa !11
  %31 = tail call { i64, i32 } @mrb_str_new_cstr(ptr noundef %0, ptr noundef %30) #4
  %32 = extractvalue { i64, i32 } %31, 0
  store i64 %32, ptr %6, align 8
  %33 = getelementptr inbounds i8, ptr %6, i64 8
  %34 = extractvalue { i64, i32 } %31, 1
  store i32 %34, ptr %33, align 8
  tail call void (ptr, ptr, ptr, ...) @mrb_raisef(ptr noundef %0, ptr noundef %26, ptr noundef nonnull @.str.2, i64 %28, i32 %29, ptr noundef nonnull byval(%struct.mrb_value) align 8 %6) #5
  unreachable

35:                                               ; preds = %9
  ret void
}

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

; Function Attrs: noreturn
declare void @mrb_raisef(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #2

declare ptr @mrb_exc_get(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mrb_class(ptr noundef, i64, i32) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden { i64, i32 } @mrb_obj_value(ptr noundef) local_unnamed_addr #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 = { "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 = { noreturn "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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"RData", !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 = !{!12, !10, i64 0}
!12 = !{!"mrb_data_type", !10, i64 0, !10, i64 8}


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