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

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

@.str.10 = external hidden unnamed_addr constant [3 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 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 void @iv_foreach(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare { i64, i32 } @mrb_ary_new(ptr noundef) #3

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

22:                                               ; preds = %43, %3
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %44

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.RClass, ptr %27, i32 0, i32 3
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  call void @iv_foreach(ptr noundef %26, ptr noundef %29, ptr noundef @const_i, ptr noundef %4)
  %30 = load i8, ptr %7, align 1, !tbaa !9
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %25
  br label %44

33:                                               ; preds = %25
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.RClass, ptr %34, i32 0, i32 5
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  store ptr %36, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mrb_state, ptr %38, i32 0, i32 9
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = icmp eq ptr %37, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %33
  br label %44

43:                                               ; preds = %33
  br label %22, !llvm.loop !21

44:                                               ; preds = %42, %32, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  %45 = load { i64, i32 }, ptr %4, align 8
  ret { i64, i32 } %45
}

declare i64 @mrb_get_args(ptr noundef, ptr noundef, ...) #3

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

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 = { "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 = !{!7, !7, i64 0}
!10 = !{i64 0, i64 8, !9, i64 8, i64 4, !11}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"RClass", !12, i64 0, !12, i64 1, !12, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!14, !6, i64 40}
!16 = !{!17, !6, i64 72}
!17 = !{!"mrb_state", !6, i64 0, !12, 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, !18, i64 200, !12, i64 312, !6, i64 320, !7, i64 328, !19, i64 1352, !7, i64 1360, !6, i64 1368, !6, i64 1376, !6, i64 1384, !6, i64 1392, !6, i64 1400, !6, i64 1408, !20, i64 1416, !20, i64 1418}
!18 = !{!"mrb_gc", !6, i64 0, !6, i64 8, !6, i64 16, !19, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !19, i64 72, !19, i64 80, !12, i64 88, !12, i64 92, !7, i64 96, !7, i64 96, !7, i64 96, !7, i64 96, !7, i64 96, !19, i64 104}
!19 = !{!"long", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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.10 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: mustprogress 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 void @iv_foreach(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @mrb_mod_constants(ptr noundef %0, i64 %1, i32 %2) local_unnamed_addr #1 {
  %4 = alloca %struct.mrb_value, align 8
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #3
  store i8 1, ptr %5, align 1, !tbaa !5
  %6 = call i64 (ptr, ptr, ...) @mrb_get_args(ptr noundef %0, ptr noundef nonnull @.str.10, ptr noundef nonnull %5) #3
  %7 = call { i64, i32 } @mrb_ary_new(ptr noundef %0) #3
  %8 = extractvalue { i64, i32 } %7, 0
  %9 = extractvalue { i64, i32 } %7, 1
  store i64 %8, ptr %4, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %9, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !8
  %.old1.not = icmp eq i64 %1, 0
  br i1 %.old1.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %3
  %.sroa.09.0..sroa.09.0..cast = inttoptr i64 %1 to ptr
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  br label %11

11:                                               ; preds = %.preheader, %15
  %.0 = phi ptr [ %17, %15 ], [ %.sroa.09.0..sroa.09.0..cast, %.preheader ]
  %12 = getelementptr inbounds i8, ptr %.0, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  call void @iv_foreach(ptr noundef %0, ptr noundef %13, ptr noundef nonnull @const_i, ptr noundef nonnull %4)
  %14 = load i8, ptr %5, align 1, !tbaa !5
  %.not = icmp eq i8 %14, 0
  br i1 %.not, label %.loopexit.loopexit, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %.0, i64 40
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = load ptr, ptr %10, align 8, !tbaa !14
  %19 = icmp ne ptr %17, %18
  %20 = icmp ne ptr %17, null
  %or.cond = and i1 %20, %19
  br i1 %or.cond, label %11, label %.loopexit.loopexit, !llvm.loop !19

.loopexit.loopexit:                               ; preds = %11, %15
  %.fca.0.load.pre = load i64, ptr %4, align 8
  %.fca.1.load.pre = load i32, ptr %.sroa.4.0..sroa_idx, align 8
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %3
  %.fca.1.load = phi i32 [ %.fca.1.load.pre, %.loopexit.loopexit ], [ %9, %3 ]
  %.fca.0.load = phi i64 [ %.fca.0.load.pre, %.loopexit.loopexit ], [ %8, %3 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #3
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.fca.0.load, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.fca.1.load, 1
  ret { i64, i32 } %.fca.1.insert
}

declare i64 @mrb_get_args(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @const_i(ptr noundef, i32 noundef, i64, i32, ptr noundef) #1

attributes #0 = { mustprogress 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !12, i64 24}
!11 = !{!"RClass", !9, i64 0, !9, i64 1, !9, i64 1, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!11, !12, i64 40}
!14 = !{!15, !12, i64 72}
!15 = !{!"mrb_state", !12, i64 0, !9, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !16, i64 200, !9, i64 312, !12, i64 320, !6, i64 328, !17, i64 1352, !6, i64 1360, !12, i64 1368, !12, i64 1376, !12, i64 1384, !12, i64 1392, !12, i64 1400, !12, i64 1408, !18, i64 1416, !18, i64 1418}
!16 = !{!"mrb_gc", !12, i64 0, !12, i64 8, !12, i64 16, !17, i64 24, !12, i64 32, !9, i64 40, !9, i64 44, !9, i64 48, !9, i64 52, !12, i64 56, !12, i64 64, !17, i64 72, !17, i64 80, !9, i64 88, !9, i64 92, !6, i64 96, !6, i64 96, !6, i64 96, !6, i64 96, !6, i64 96, !17, i64 104}
!17 = !{!"long", !6, i64 0}
!18 = !{!"short", !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass