; LLVM IR from introlab/odas :: src/system (hop2hop)

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @hop2hop_buffer_construct_zero(i32 noundef %0, i32 noundef %1, i32 noundef %2, double noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %11 = call noalias ptr @malloc(i64 noundef 88) #6
  store ptr %11, ptr %9, align 8, !tbaa !11
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = load ptr, ptr %9, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %13, i32 0, i32 0
  store i32 %12, ptr %14, align 8, !tbaa !13
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !11
  %17 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %16, i32 0, i32 1
  store i32 %15, ptr %17, align 4, !tbaa !15
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %19, i32 0, i32 2
  store i32 %18, ptr %20, align 8, !tbaa !16
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = uitofp i32 %21 to double
  %23 = load ptr, ptr %9, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %23, i32 0, i32 3
  store double %22, ptr %24, align 8, !tbaa !17
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = uitofp i32 %25 to double
  %27 = load double, ptr %8, align 8, !tbaa !9
  %28 = fdiv double %26, %27
  %29 = load ptr, ptr %9, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %29, i32 0, i32 4
  store double %28, ptr %30, align 8, !tbaa !18
  %31 = load ptr, ptr %9, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %31, i32 0, i32 5
  store double 0.000000e+00, ptr %32, align 8, !tbaa !19
  %33 = load double, ptr %8, align 8, !tbaa !9
  %34 = load ptr, ptr %9, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %34, i32 0, i32 7
  store double %33, ptr %35, align 8, !tbaa !20
  %36 = load double, ptr %8, align 8, !tbaa !9
  %37 = fdiv double 1.000000e+00, %36
  %38 = load ptr, ptr %9, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %38, i32 0, i32 8
  store double %37, ptr %39, align 8, !tbaa !21
  %40 = load ptr, ptr %9, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %40, i32 0, i32 3
  %42 = load double, ptr %41, align 8, !tbaa !17
  %43 = load ptr, ptr %9, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %43, i32 0, i32 4
  %45 = load double, ptr %44, align 8, !tbaa !18
  %46 = fcmp oge double %42, %45
  br i1 %46, label %47, label %57

47:                                               ; preds = %4
  %48 = load ptr, ptr %9, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %48, i32 0, i32 3
  %50 = load double, ptr %49, align 8, !tbaa !17
  %51 = fmul double 2.000000e+00, %50
  %52 = fptrunc double %51 to float
  %53 = call float @llvm.ceil.f32(float %52)
  %54 = fptoui float %53 to i32
  %55 = load ptr, ptr %9, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %55, i32 0, i32 6
  store i32 %54, ptr %56, align 8, !tbaa !22
  br label %67

57:                                               ; preds = %4
  %58 = load ptr, ptr %9, align 8, !tbaa !11
  %59 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %58, i32 0, i32 4
  %60 = load double, ptr %59, align 8, !tbaa !18
  %61 = fmul double 2.000000e+00, %60
  %62 = fptrunc double %61 to float
  %63 = call float @llvm.ceil.f32(float %62)
  %64 = fptoui float %63 to i32
  %65 = load ptr, ptr %9, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %65, i32 0, i32 6
  store i32 %64, ptr %66, align 8, !tbaa !22
  br label %67

67:                                               ; preds = %57, %47
  %68 = load ptr, ptr %9, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %68, i32 0, i32 10
  store double 0.000000e+00, ptr %69, align 8, !tbaa !23
  %70 = load ptr, ptr %9, align 8, !tbaa !11
  %71 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %70, i32 0, i32 9
  store double 0.000000e+00, ptr %71, align 8, !tbaa !24
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = zext i32 %72 to i64
  %74 = mul i64 8, %73
  %75 = call noalias ptr @malloc(i64 noundef %74) #6
  %76 = load ptr, ptr %9, align 8, !tbaa !11
  %77 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %76, i32 0, i32 11
  store ptr %75, ptr %77, align 8, !tbaa !25
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %109, %67
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 8, !tbaa !13
  %83 = icmp ult i32 %79, %82
  br i1 %83, label %84, label %112

84:                                               ; preds = %78
  %85 = load ptr, ptr %9, align 8, !tbaa !11
  %86 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %85, i32 0, i32 6
  %87 = load i32, ptr %86, align 8, !tbaa !22
  %88 = zext i32 %87 to i64
  %89 = mul i64 4, %88
  %90 = call noalias ptr @malloc(i64 noundef %89) #6
  %91 = load ptr, ptr %9, align 8, !tbaa !11
  %92 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %91, i32 0, i32 11
  %93 = load ptr, ptr %92, align 8, !tbaa !25
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds ptr, ptr %93, i64 %95
  store ptr %90, ptr %96, align 8, !tbaa !11
  %97 = load ptr, ptr %9, align 8, !tbaa !11
  %98 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %97, i32 0, i32 11
  %99 = load ptr, ptr %98, align 8, !tbaa !25
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds ptr, ptr %99, i64 %101
  %103 = load ptr, ptr %102, align 8, !tbaa !11
  %104 = load ptr, ptr %9, align 8, !tbaa !11
  %105 = getelementptr inbounds %struct.hop2hop_buffer_obj, ptr %104, i32 0, i32 6
  %106 = load i32, ptr %105, align 8, !tbaa !22
  %107 = zext i32 %106 to i64
  %108 = mul i64 4, %107
  call void @llvm.memset.p0.i64(ptr align 4 %103, i8 0, i64 %108, i1 false)
  br label %109

109:                                              ; preds = %84
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = add i32 %110, 1
  store i32 %111, ptr %10, align 4, !tbaa !5
  br label %78, !llvm.loop !26

112:                                              ; preds = %78
  %113 = load ptr, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret ptr %113
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.ceil.f32(float) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"hop2hop_buffer_obj", !6, i64 0, !6, i64 4, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !12, i64 80}
!15 = !{!14, !6, i64 4}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !10, i64 16}
!18 = !{!14, !10, i64 24}
!19 = !{!14, !10, i64 32}
!20 = !{!14, !10, i64 48}
!21 = !{!14, !10, i64 56}
!22 = !{!14, !6, i64 40}
!23 = !{!14, !10, i64 72}
!24 = !{!14, !10, i64 64}
!25 = !{!14, !12, i64 80}
!26 = distinct !{!26, !27}
!27 = !{!"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"

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nofree nounwind memory(write, argmem: none, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @hop2hop_buffer_construct_zero(i32 noundef %0, i32 noundef %1, i32 noundef %2, double noundef %3) local_unnamed_addr #2 {
  %5 = tail call noalias dereferenceable_or_null(88) ptr @malloc(i64 noundef 88) #5
  store i32 %0, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %1, ptr %6, align 4, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %2, ptr %7, align 8, !tbaa !13
  %8 = uitofp i32 %1 to double
  %9 = getelementptr inbounds i8, ptr %5, i64 16
  store double %8, ptr %9, align 8, !tbaa !14
  %10 = uitofp i32 %2 to double
  %11 = fdiv double %10, %3
  %12 = getelementptr inbounds i8, ptr %5, i64 24
  store double %11, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %5, i64 32
  store double 0.000000e+00, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %5, i64 48
  store double %3, ptr %14, align 8, !tbaa !17
  %15 = fdiv double 1.000000e+00, %3
  %16 = getelementptr inbounds i8, ptr %5, i64 56
  store double %15, ptr %16, align 8, !tbaa !18
  %.inv = fcmp ole double %11, %8
  %. = select i1 %.inv, double %8, double %11
  %17 = fmul double %., 2.000000e+00
  %18 = fptrunc double %17 to float
  %19 = tail call float @llvm.ceil.f32(float %18)
  %20 = fptoui float %19 to i32
  %21 = getelementptr inbounds i8, ptr %5, i64 40
  store i32 %20, ptr %21, align 8
  %22 = getelementptr inbounds i8, ptr %5, i64 64
  %23 = zext i32 %0 to i64
  %24 = shl nuw nsw i64 %23, 3
  %25 = tail call noalias ptr @malloc(i64 noundef %24) #5
  %26 = getelementptr inbounds i8, ptr %5, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %22, i8 0, i64 16, i1 false)
  store ptr %25, ptr %26, align 8, !tbaa !19
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %27 = zext i32 %20 to i64
  %28 = shl nuw nsw i64 %27, 2
  br label %29

29:                                               ; preds = %.lr.ph, %29
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %29 ]
  %calloc = tail call ptr @calloc(i64 1, i64 %28)
  %30 = getelementptr inbounds ptr, ptr %25, i64 %indvars.iv
  store ptr %calloc, ptr %30, align 8, !tbaa !20
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %23
  br i1 %exitcond.not, label %._crit_edge, label %29, !llvm.loop !21

._crit_edge:                                      ; preds = %29, %4
  ret ptr %5
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.ceil.f32(float) #3

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nofree nounwind memory(write, argmem: none, inaccessiblemem: readwrite) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #5 = { nounwind allocsize(0) }

!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 0}
!6 = !{!"hop2hop_buffer_obj", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !11, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !10, i64 32}
!17 = !{!6, !10, i64 48}
!18 = !{!6, !10, i64 56}
!19 = !{!6, !11, i64 80}
!20 = !{!11, !11, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass