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

; 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_state = type { ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.mrb_gc, i32, ptr, [256 x i32], i64, [8 x i8], ptr, ptr, ptr, ptr, ptr, ptr, i16, i16 }
%struct.mrb_gc = type { ptr, ptr, ptr, i64, ptr, i32, i32, i32, i32, ptr, ptr, i64, i64, i32, i32, i8, i64 }
%struct.mrb_context = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i16, ptr, i16, i16, i32, i8, ptr }
%struct.mrb_callinfo = type { i32, ptr, ptr, i16, i16, ptr, ptr, ptr, i32, i32, ptr }
%struct.RProc = type { i32, ptr, ptr, %union.anon, ptr, %union.anon.0 }
%union.anon = type { ptr }
%union.anon.0 = type { ptr }
%struct.REnv = type { i32, ptr, ptr, ptr, ptr, i32 }

; Function Attrs: nounwind uwtable
define dso_local ptr @mrb_proc_new(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mrb_state, ptr %8, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.mrb_context, ptr %10, i32 0, i32 4
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  store ptr %12, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mrb_state, ptr %14, i32 0, i32 12
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %17 = call ptr @mrb_obj_alloc(ptr noundef %13, i32 noundef 13, ptr noundef %16)
  store ptr %17, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %65

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mrb_callinfo, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %49

25:                                               ; preds = %20
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mrb_callinfo, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = load i32, ptr %28, align 8
  %30 = lshr i32 %29, 11
  %31 = and i32 %30, 1024
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %41

33:                                               ; preds = %25
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mrb_callinfo, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = getelementptr inbounds %struct.RProc, ptr %36, i32 0, i32 5
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = getelementptr inbounds %struct.REnv, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !21
  br label %47

41:                                               ; preds = %25
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.mrb_callinfo, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = getelementptr inbounds %struct.RProc, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !20
  br label %47

47:                                               ; preds = %41, %33
  %48 = phi ptr [ %40, %33 ], [ %46, %41 ]
  store ptr %48, ptr %7, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %47, %20
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %56

52:                                               ; preds = %49
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mrb_callinfo, ptr %53, i32 0, i32 10
  %55 = load ptr, ptr %54, align 8, !tbaa !23
  store ptr %55, ptr %7, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %52, %49
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mrb_callinfo, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.RProc, ptr %60, i32 0, i32 4
  store ptr %59, ptr %61, align 8, !tbaa !24
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.RProc, ptr %63, i32 0, i32 5
  store ptr %62, ptr %64, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %65

65:                                               ; preds = %56, %2
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.RProc, ptr %67, i32 0, i32 3
  store ptr %66, ptr %68, align 8, !tbaa !20
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mrb_irep_incref(ptr noundef %69, ptr noundef %70)
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %71
}

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

declare ptr @mrb_obj_alloc(ptr noundef, i32 noundef, ptr noundef) #2

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

declare void @mrb_irep_incref(ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"mrb_state", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !12, i64 200, !11, i64 312, !6, i64 320, !7, i64 328, !13, i64 1352, !7, i64 1360, !6, i64 1368, !6, i64 1376, !6, i64 1384, !6, i64 1392, !6, i64 1400, !6, i64 1408, !14, i64 1416, !14, i64 1418}
!11 = !{!"int", !7, i64 0}
!12 = !{!"mrb_gc", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !6, i64 56, !6, i64 64, !13, i64 72, !13, i64 80, !11, i64 88, !11, i64 92, !7, i64 96, !7, i64 96, !7, i64 96, !7, i64 96, !7, i64 96, !13, i64 104}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !6, i64 32}
!16 = !{!"mrb_context", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !14, i64 64, !6, i64 72, !14, i64 80, !14, i64 82, !11, i64 84, !7, i64 88, !6, i64 96}
!17 = !{!10, !6, i64 96}
!18 = !{!19, !6, i64 8}
!19 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !14, i64 26, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !6, i64 64}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !6, i64 8}
!22 = !{!"REnv", !11, i64 0, !11, i64 1, !11, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40}
!23 = !{!19, !6, i64 64}
!24 = !{!25, !6, i64 32}
!25 = !{!"RProc", !11, i64 0, !11, i64 1, !11, i64 1, !6, i64 8, !6, i64 16, !7, i64 24, !6, i64 32, !7, i64 40}


; 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
define dso_local ptr @mrb_proc_new(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = load ptr, ptr %7, align 8, !tbaa !16
  %9 = tail call ptr @mrb_obj_alloc(ptr noundef %0, i32 noundef 13, ptr noundef %8) #2
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %28, label %10

10:                                               ; preds = %2
  %11 = getelementptr inbounds i8, ptr %6, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !17
  %.not21 = icmp eq ptr %12, null
  br i1 %.not21, label %.thread, label %13

13:                                               ; preds = %10
  %14 = load i32, ptr %12, align 8
  %15 = and i32 %14, 2097152
  %.not22 = icmp eq i32 %15, 0
  %16 = getelementptr inbounds i8, ptr %12, i64 40
  br i1 %.not22, label %20, label %17

17:                                               ; preds = %13
  %18 = load ptr, ptr %16, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  br label %20

20:                                               ; preds = %13, %17
  %.in = phi ptr [ %19, %17 ], [ %16, %13 ]
  %21 = load ptr, ptr %.in, align 8, !tbaa !19
  %22 = icmp eq ptr %21, null
  br i1 %22, label %.thread, label %25

.thread:                                          ; preds = %10, %20
  %23 = getelementptr inbounds i8, ptr %6, i64 64
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  br label %25

25:                                               ; preds = %.thread, %20
  %.1 = phi ptr [ %24, %.thread ], [ %21, %20 ]
  %26 = getelementptr inbounds i8, ptr %9, i64 32
  store ptr %12, ptr %26, align 8, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %9, i64 40
  store ptr %.1, ptr %27, align 8, !tbaa !19
  br label %28

28:                                               ; preds = %25, %2
  %29 = getelementptr inbounds i8, ptr %9, i64 24
  store ptr %1, ptr %29, align 8, !tbaa !19
  tail call void @mrb_irep_incref(ptr noundef nonnull %0, ptr noundef %1) #2
  ret ptr %9
}

declare ptr @mrb_obj_alloc(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @mrb_irep_incref(ptr noundef, ptr noundef) 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 = { "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)"}
!5 = !{!6, !7, i64 32}
!6 = !{!"mrb_state", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !11, i64 200, !10, i64 312, !7, i64 320, !8, i64 328, !12, i64 1352, !8, i64 1360, !7, i64 1368, !7, i64 1376, !7, i64 1384, !7, i64 1392, !7, i64 1400, !7, i64 1408, !13, i64 1416, !13, i64 1418}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"mrb_gc", !7, i64 0, !7, i64 8, !7, i64 16, !12, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !12, i64 72, !12, i64 80, !10, i64 88, !10, i64 92, !8, i64 96, !8, i64 96, !8, i64 96, !8, i64 96, !8, i64 96, !12, i64 104}
!12 = !{!"long", !8, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!15, !7, i64 32}
!15 = !{!"mrb_context", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !13, i64 64, !7, i64 72, !13, i64 80, !13, i64 82, !10, i64 84, !8, i64 88, !7, i64 96}
!16 = !{!6, !7, i64 96}
!17 = !{!18, !7, i64 8}
!18 = !{!"", !10, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !13, i64 26, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !7, i64 64}
!19 = !{!8, !8, i64 0}
!20 = !{!18, !7, i64 64}
!21 = !{!22, !7, i64 32}
!22 = !{!"RProc", !10, i64 0, !10, i64 1, !10, i64 1, !7, i64 8, !7, i64 16, !8, i64 24, !7, i64 32, !8, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass