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

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

@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [25 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_exc_get(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @mrb_obj_is_kind_of(ptr noundef %0, i64 %1, i32 %2, ptr noundef %3) #2 {
  %5 = alloca i8, align 1
  %6 = alloca %struct.mrb_value, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  store i64 %1, ptr %11, align 8
  %12 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  store i32 %2, ptr %12, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  %17 = load i32, ptr %16, align 8
  %18 = call ptr @mrb_class(ptr noundef %13, i64 %15, i32 %17)
  store ptr %18, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 8
  %21 = and i32 %20, 255
  switch i32 %21, label %23 [
    i32 10, label %22
    i32 9, label %22
    i32 11, label %22
    i32 12, label %22
  ]

22:                                               ; preds = %4, %4, %4, %4
  br label %27

23:                                               ; preds = %4
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call ptr @mrb_exc_get(ptr noundef %25, ptr noundef @.str.11)
  call void @mrb_raise(ptr noundef %24, ptr noundef %26, ptr noundef @.str.21) #6
  unreachable

27:                                               ; preds = %22
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 8
  %31 = lshr i32 %30, 11
  %32 = and i32 %31, 524288
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %50

34:                                               ; preds = %28
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.RClass, ptr %35, i32 0, i32 5
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  store ptr %37, ptr %8, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %45, %34
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load i32, ptr %39, align 8
  %41 = lshr i32 %40, 11
  %42 = and i32 %41, 262144
  %43 = icmp ne i32 %42, 0
  %44 = xor i1 %43, true
  br i1 %44, label %45, label %49

45:                                               ; preds = %38
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.RClass, ptr %46, i32 0, i32 5
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  store ptr %48, ptr %8, align 8, !tbaa !5
  br label %38, !llvm.loop !12

49:                                               ; preds = %38
  br label %50

50:                                               ; preds = %49, %28
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %69, %52
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %73

56:                                               ; preds = %53
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = icmp eq ptr %57, %58
  br i1 %59, label %68, label %60

60:                                               ; preds = %56
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.RClass, ptr %61, i32 0, i32 4
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.RClass, ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = icmp eq ptr %63, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %60, %56
  store i8 1, ptr %5, align 1
  store i32 1, ptr %10, align 4
  br label %74

69:                                               ; preds = %60
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.RClass, ptr %70, i32 0, i32 5
  %72 = load ptr, ptr %71, align 8, !tbaa !9
  store ptr %72, ptr %9, align 8, !tbaa !5
  br label %53, !llvm.loop !15

73:                                               ; preds = %53
  store i8 0, ptr %5, align 1
  store i32 1, ptr %10, align 4
  br label %74

74:                                               ; preds = %73, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %75 = load i8, ptr %5, align 1
  ret i8 %75
}

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

; Function Attrs: noreturn
declare void @mrb_raise(ptr noundef, ptr noundef, ptr noundef) #4

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 = { 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 = { 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 #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, !6, i64 40}
!10 = !{!"RClass", !11, i64 0, !11, i64 1, !11, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 32}
!15 = distinct !{!15, !13}


; 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.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @mrb_obj_is_kind_of(ptr noundef %0, i64 %1, i32 %2, ptr noundef readonly %3) local_unnamed_addr #1 {
  %5 = tail call ptr @mrb_class(ptr noundef %0, i64 %1, i32 %2)
  %6 = load i32, ptr %3, align 8
  %trunc = trunc i32 %6 to i8
  %trunc.off = add i8 %trunc, -9
  %switch = icmp ult i8 %trunc.off, 4
  br i1 %switch, label %9, label %7

7:                                                ; preds = %4
  %8 = tail call ptr @mrb_exc_get(ptr noundef %0, ptr noundef nonnull @.str.11) #4
  tail call void @mrb_raise(ptr noundef %0, ptr noundef %8, ptr noundef nonnull @.str.21) #5
  unreachable

9:                                                ; preds = %4
  %10 = and i32 %6, 1073741824
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %9, %.preheader
  %.pn = phi ptr [ %.014, %.preheader ], [ %3, %9 ]
  %.014.in = getelementptr inbounds i8, ptr %.pn, i64 40
  %.014 = load ptr, ptr %.014.in, align 8, !tbaa !5
  %11 = load i32, ptr %.014, align 8
  %12 = and i32 %11, 536870912
  %.not16 = icmp eq i32 %12, 0
  br i1 %.not16, label %.preheader, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %.preheader, %9
  %.1 = phi ptr [ %3, %9 ], [ %.014, %.preheader ]
  %.not1718 = icmp eq ptr %5, null
  br i1 %.not1718, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.loopexit
  %13 = getelementptr inbounds i8, ptr %.1, i64 32
  br label %14

14:                                               ; preds = %.lr.ph, %21
  %.019 = phi ptr [ %5, %.lr.ph ], [ %23, %21 ]
  %15 = icmp eq ptr %.019, %.1
  br i1 %15, label %._crit_edge, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %.019, i64 32
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load ptr, ptr %13, align 8, !tbaa !13
  %20 = icmp eq ptr %18, %19
  br i1 %20, label %._crit_edge, label %21

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %.019, i64 40
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %.not17 = icmp eq ptr %23, null
  br i1 %.not17, label %._crit_edge, label %14, !llvm.loop !14

._crit_edge:                                      ; preds = %16, %14, %21, %.loopexit
  %.015 = phi i8 [ 0, %.loopexit ], [ 0, %21 ], [ 1, %14 ], [ 1, %16 ]
  ret i8 %.015
}

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

; Function Attrs: noreturn
declare void @mrb_raise(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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 = { 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 = { 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 = { 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 40}
!6 = !{!"RClass", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 32}
!14 = distinct !{!14, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass