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

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @convert_type(ptr noundef, i64, i32, ptr noundef, ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_check_convert_type(ptr noundef %0, i64 %1, i32 %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %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 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.mrb_value, align 8
  %14 = alloca i32, align 4
  %15 = alloca %struct.mrb_value, align 8
  %16 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  store i64 %1, ptr %16, align 8
  %17 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  store i32 %2, ptr %17, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %18 = getelementptr inbounds %struct.mrb_value, ptr %8, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = icmp eq i32 %19, %20
  br i1 %21, label %22, label %29

22:                                               ; preds = %6
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 21
  br i1 %24, label %25, label %29

25:                                               ; preds = %22
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 23
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !13
  store i32 1, ptr %14, align 4
  br label %61

29:                                               ; preds = %25, %22, %6
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %34 = load i64, ptr %33, align 8
  %35 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %36 = load i32, ptr %35, align 8
  %37 = call { i64, i32 } @convert_type(ptr noundef %30, i64 %34, i32 %36, ptr noundef %31, ptr noundef %32, i8 noundef zeroext 0)
  %38 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %39 = extractvalue { i64, i32 } %37, 0
  store i64 %39, ptr %38, align 8
  %40 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %41 = extractvalue { i64, i32 } %37, 1
  store i32 %41, ptr %40, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %15, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  %42 = getelementptr inbounds %struct.mrb_value, ptr %13, i32 0, i32 1
  %43 = load i32, ptr %42, align 8, !tbaa !11
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %49

45:                                               ; preds = %29
  %46 = getelementptr inbounds %struct.mrb_value, ptr %13, i32 0, i32 0
  %47 = load i64, ptr %46, align 8, !tbaa !14
  %48 = icmp ne i64 %47, 0
  br i1 %48, label %49, label %54

49:                                               ; preds = %45, %29
  %50 = getelementptr inbounds %struct.mrb_value, ptr %13, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !11
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = icmp ne i32 %51, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %49, %45
  %55 = call { i64, i32 } @mrb_nil_value()
  %56 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %57 = extractvalue { i64, i32 } %55, 0
  store i64 %57, ptr %56, align 8
  %58 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %59 = extractvalue { i64, i32 } %55, 1
  store i32 %59, ptr %58, align 8
  store i32 1, ptr %14, align 4
  br label %61

60:                                               ; preds = %49
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %13, i64 16, i1 false), !tbaa.struct !13
  store i32 1, ptr %14, align 4
  br label %61

61:                                               ; preds = %60, %54, %28
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  %62 = load { i64, i32 }, ptr %7, align 8
  ret { i64, i32 } %62
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden { i64, i32 } @mrb_nil_value() #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }

!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 = !{i64 0, i64 8, !14, i64 8, i64 4, !9}
!14 = !{!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 hidden { i64, i32 } @convert_type(ptr noundef, i64, i32, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_check_convert_type(ptr noundef %0, i64 %1, i32 %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = icmp eq i32 %2, %3
  %8 = and i32 %3, -3
  %9 = icmp ne i32 %8, 21
  %or.cond3 = and i1 %7, %9
  br i1 %or.cond3, label %20, label %10

10:                                               ; preds = %6
  %11 = tail call { i64, i32 } @convert_type(ptr noundef %0, i64 %1, i32 %2, ptr noundef %4, ptr noundef %5, i8 noundef zeroext 0)
  %12 = extractvalue { i64, i32 } %11, 0
  %13 = extractvalue { i64, i32 } %11, 1
  %14 = icmp ne i32 %13, 0
  %15 = icmp ne i64 %12, 0
  %or.cond6 = select i1 %14, i1 true, i1 %15
  %.not = icmp eq i32 %13, %3
  %or.cond = and i1 %.not, %or.cond6
  br i1 %or.cond, label %20, label %16

16:                                               ; preds = %10
  %17 = tail call { i64, i32 } @mrb_nil_value()
  %18 = extractvalue { i64, i32 } %17, 0
  %19 = extractvalue { i64, i32 } %17, 1
  br label %20

20:                                               ; preds = %10, %6, %16
  %.sroa.017.0 = phi i64 [ %18, %16 ], [ %1, %6 ], [ %12, %10 ]
  %.sroa.418.0 = phi i32 [ %19, %16 ], [ %2, %6 ], [ %3, %10 ]
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.017.0, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.sroa.418.0, 1
  ret { i64, i32 } %.fca.1.insert
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden { i64, i32 } @mrb_nil_value() 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 = { 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" }

!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: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass