; LLVM IR from boschglobal/dse.network :: tests/benchmark (bench_net)

; 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.timespec = type { i64, i64 }
%struct.signal_t = type { i32, ptr, ptr, ptr, ptr, ptr, [8 x i8], [16 x i8] }

@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @get_timespec_now() #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @get_elapsedtime_ns(i64, i64) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @ns_to_us_to_sec(i64 noundef) #0

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local void @run_bench_ct(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.timespec, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  %16 = call { i64, i64 } @get_timespec_now()
  %17 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %18 = extractvalue { i64, i64 } %16, 0
  store i64 %18, ptr %17, align 8
  %19 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %20 = extractvalue { i64, i64 } %16, 1
  store i64 %20, ptr %19, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %144, %4
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %147

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %140, %26
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %143

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  store double %37, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %38 = load double, ptr %13, align 8, !tbaa !11
  %39 = fadd double %38, 1.000000e+00
  store double %39, ptr %14, align 8, !tbaa !11
  %40 = load double, ptr %14, align 8, !tbaa !11
  %41 = fcmp ogt double %40, 1.000000e+02
  br i1 %41, label %42, label %43

42:                                               ; preds = %32
  store double 0.000000e+00, ptr %14, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %42, %32
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i32, ptr %12, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.signal_t, ptr %44, i64 %46
  %48 = getelementptr inbounds %struct.signal_t, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = load double, ptr %14, align 8, !tbaa !11
  %51 = call zeroext i8 %49(double noundef %50)
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.signal_t, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.signal_t, ptr %55, i32 0, i32 6
  %57 = getelementptr inbounds [8 x i8], ptr %56, i64 0, i64 0
  store i8 %51, ptr %57, align 8, !tbaa !15
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.signal_t, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.signal_t, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.signal_t, ptr %64, i64 %66
  %68 = getelementptr inbounds %struct.signal_t, ptr %67, i32 0, i32 7
  %69 = getelementptr inbounds [16 x i8], ptr %68, i64 0, i64 0
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.signal_t, ptr %70, i64 %72
  %74 = getelementptr inbounds %struct.signal_t, ptr %73, i32 0, i32 6
  %75 = getelementptr inbounds [8 x i8], ptr %74, i64 0, i64 0
  %76 = call i32 %63(ptr noundef %69, ptr noundef %75, i64 noundef 8)
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.signal_t, ptr %77, i64 %79
  %81 = getelementptr inbounds %struct.signal_t, ptr %80, i32 0, i32 6
  %82 = getelementptr inbounds [8 x i8], ptr %81, i64 0, i64 0
  store i8 0, ptr %82, align 8, !tbaa !15
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load i32, ptr %12, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds %struct.signal_t, ptr %83, i64 %85
  %87 = getelementptr inbounds %struct.signal_t, ptr %86, i32 0, i32 2
  %88 = load ptr, ptr %87, align 8, !tbaa !17
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds %struct.signal_t, ptr %89, i64 %91
  %93 = getelementptr inbounds %struct.signal_t, ptr %92, i32 0, i32 6
  %94 = getelementptr inbounds [8 x i8], ptr %93, i64 0, i64 0
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = load i32, ptr %12, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds %struct.signal_t, ptr %95, i64 %97
  %99 = getelementptr inbounds %struct.signal_t, ptr %98, i32 0, i32 7
  %100 = getelementptr inbounds [16 x i8], ptr %99, i64 0, i64 0
  %101 = call i32 %88(ptr noundef %94, ptr noundef %100, i64 noundef 8)
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds %struct.signal_t, ptr %102, i64 %104
  %106 = getelementptr inbounds %struct.signal_t, ptr %105, i32 0, i32 3
  %107 = load ptr, ptr %106, align 8, !tbaa !18
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = load i32, ptr %12, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds %struct.signal_t, ptr %108, i64 %110
  %112 = getelementptr inbounds %struct.signal_t, ptr %111, i32 0, i32 6
  %113 = getelementptr inbounds [8 x i8], ptr %112, i64 0, i64 0
  %114 = load i8, ptr %113, align 8, !tbaa !15
  %115 = call zeroext i1 %107(i8 noundef zeroext %114)
  br i1 %115, label %116, label %131

116:                                              ; preds = %43
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = load i32, ptr %12, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.signal_t, ptr %117, i64 %119
  %121 = getelementptr inbounds %struct.signal_t, ptr %120, i32 0, i32 4
  %122 = load ptr, ptr %121, align 8, !tbaa !19
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = load i32, ptr %12, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds %struct.signal_t, ptr %123, i64 %125
  %127 = getelementptr inbounds %struct.signal_t, ptr %126, i32 0, i32 6
  %128 = getelementptr inbounds [8 x i8], ptr %127, i64 0, i64 0
  %129 = load i8, ptr %128, align 8, !tbaa !15
  %130 = call double %122(i8 noundef zeroext %129)
  store double %130, ptr %14, align 8, !tbaa !11
  br label %134

131:                                              ; preds = %43
  %132 = load double, ptr %14, align 8, !tbaa !11
  %133 = fadd double %132, 1.000000e+00
  store double %133, ptr %14, align 8, !tbaa !11
  br label %134

134:                                              ; preds = %131, %116
  %135 = load double, ptr %14, align 8, !tbaa !11
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = load i32, ptr %12, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds double, ptr %136, i64 %138
  store double %135, ptr %139, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %140

140:                                              ; preds = %134
  %141 = load i32, ptr %12, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %12, align 4, !tbaa !9
  br label %27, !llvm.loop !20

143:                                              ; preds = %31
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %10, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %10, align 4, !tbaa !9
  br label %21, !llvm.loop !22

147:                                              ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %148 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %149 = load i64, ptr %148, align 8
  %150 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %151 = load i64, ptr %150, align 8
  %152 = call i64 @get_elapsedtime_ns(i64 %149, i64 %151)
  store i64 %152, ptr %15, align 8, !tbaa !23
  %153 = load i64, ptr %15, align 8, !tbaa !23
  %154 = call double @ns_to_us_to_sec(i64 noundef %153)
  %155 = load i32, ptr %8, align 4, !tbaa !9
  %156 = load i32, ptr %7, align 4, !tbaa !9
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %154, i32 noundef %155, i32 noundef %156)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  ret void
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 40}
!14 = !{!"signal_t", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 56}
!15 = !{!7, !7, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !6, i64 16}
!18 = !{!14, !6, i64 24}
!19 = !{!14, !6, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = !{!24, !24, i64 0}
!24 = !{!"long", !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"

%struct.signal_t = type { i32, ptr, ptr, ptr, ptr, ptr, [8 x i8], [16 x i8] }

@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @get_timespec_now() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @get_elapsedtime_ns(i64, i64) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @ns_to_us_to_sec(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @run_bench_ct(ptr nocapture noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call { i64, i64 } @get_timespec_now()
  %6 = icmp sgt i32 %3, 0
  %7 = icmp sgt i32 %2, 0
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge49

.preheader.us.preheader:                          ; preds = %4
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.048.us = phi i32 [ %37, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  br label %8

8:                                                ; preds = %.preheader.us, %36
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %36 ]
  %9 = getelementptr inbounds double, ptr %0, i64 %indvars.iv
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fadd double %10, 1.000000e+00
  %12 = fcmp ogt double %11, 1.000000e+02
  %.043.us = select i1 %12, double 0.000000e+00, double %11
  %13 = getelementptr inbounds %struct.signal_t, ptr %1, i64 %indvars.iv
  %14 = getelementptr inbounds i8, ptr %13, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = tail call zeroext i8 %15(double noundef %.043.us) #2
  %17 = getelementptr inbounds i8, ptr %13, i64 48
  store i8 %16, ptr %17, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %13, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %13, i64 56
  %21 = tail call i32 %19(ptr noundef nonnull %20, ptr noundef nonnull %17, i64 noundef 8) #2
  store i8 0, ptr %17, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %13, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = tail call i32 %23(ptr noundef nonnull %17, ptr noundef nonnull %20, i64 noundef 8) #2
  %25 = getelementptr inbounds i8, ptr %13, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = load i8, ptr %17, align 8, !tbaa !13
  %28 = tail call zeroext i1 %26(i8 noundef zeroext %27) #2
  br i1 %28, label %31, label %29

29:                                               ; preds = %8
  %30 = fadd double %.043.us, 1.000000e+00
  br label %36

31:                                               ; preds = %8
  %32 = getelementptr inbounds i8, ptr %13, i64 32
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = load i8, ptr %17, align 8, !tbaa !13
  %35 = tail call double %33(i8 noundef zeroext %34) #2
  br label %36

36:                                               ; preds = %31, %29
  %.1.us = phi double [ %35, %31 ], [ %30, %29 ]
  store double %.1.us, ptr %9, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %8, !llvm.loop !18

._crit_edge.us:                                   ; preds = %36
  %37 = add nuw nsw i32 %.048.us, 1
  %exitcond52.not = icmp eq i32 %37, %3
  br i1 %exitcond52.not, label %._crit_edge49, label %.preheader.us, !llvm.loop !20

._crit_edge49:                                    ; preds = %._crit_edge.us, %4
  %38 = extractvalue { i64, i64 } %5, 1
  %39 = extractvalue { i64, i64 } %5, 0
  %40 = tail call i64 @get_elapsedtime_ns(i64 %39, i64 %38)
  %41 = tail call double @ns_to_us_to_sec(i64 noundef %40)
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %41, i32 noundef %3, i32 noundef %2)
  ret void
}

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


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