; LLVM IR from tommasocerruti/algolab-2024 :: src/week13/fighting_pits_of_meereen (solution)

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

@m = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8distinct2fqi(i64, i32, i32 noundef) #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.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solveiRSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EERS1_R2fqSB_i(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.fq, align 4
  %21 = alloca %struct.fq, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca %struct.fq, align 4
  %25 = alloca { i64, i32 }, align 4
  %26 = alloca i32, align 4
  %27 = alloca %struct.fq, align 4
  %28 = alloca { i64, i32 }, align 4
  %29 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = icmp eq i32 %30, -1
  br i1 %31, label %32, label %33

32:                                               ; preds = %6
  store i32 0, ptr %7, align 4
  br label %176

33:                                               ; preds = %6
  %34 = load i32, ptr %13, align 4, !tbaa !5
  %35 = icmp sgt i32 %34, 12
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  store i32 -2147483648, ptr %7, align 4
  br label %176

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.fq, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = mul nsw i32 %40, 5
  %42 = load ptr, ptr %11, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.fq, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !13
  %45 = add nsw i32 %41, %44
  store i32 %45, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %46 = load ptr, ptr %12, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.fq, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = mul nsw i32 %48, 5
  %50 = load ptr, ptr %12, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.fq, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !13
  %53 = add nsw i32 %49, %52
  store i32 %53, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %54 = load i32, ptr %13, align 4, !tbaa !5
  %55 = add nsw i32 %54, 12
  store i32 %55, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %56 = load ptr, ptr %9, align 8, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %56, i64 noundef %58) #7
  %60 = load i32, ptr %14, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %59, i64 noundef %61) #7
  %63 = load i32, ptr %15, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %64) #7
  %66 = load i32, ptr %16, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %65, i64 noundef %67) #7
  %69 = load i32, ptr %68, align 4, !tbaa !5
  store i32 %69, ptr %17, align 4, !tbaa !5
  %70 = load i32, ptr %17, align 4, !tbaa !5
  %71 = icmp ne i32 %70, -1
  br i1 %71, label %72, label %74

72:                                               ; preds = %37
  %73 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %73, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %175

74:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  %75 = load ptr, ptr %10, align 8, !tbaa !9
  %76 = load i32, ptr %8, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %75, i64 noundef %77) #7
  %79 = load i32, ptr %78, align 4, !tbaa !5
  store i32 %79, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %20) #7
  %80 = getelementptr inbounds %struct.fq, ptr %20, i32 0, i32 0
  %81 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %81, ptr %80, align 4, !tbaa !11
  %82 = getelementptr inbounds %struct.fq, ptr %20, i32 0, i32 1
  %83 = load ptr, ptr %11, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.fq, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 4, !tbaa !11
  store i32 %85, ptr %82, align 4, !tbaa !13
  %86 = getelementptr inbounds %struct.fq, ptr %20, i32 0, i32 2
  %87 = load ptr, ptr %11, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.fq, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !13
  store i32 %89, ptr %86, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 12, ptr %21) #7
  %90 = getelementptr inbounds %struct.fq, ptr %21, i32 0, i32 0
  %91 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %91, ptr %90, align 4, !tbaa !11
  %92 = getelementptr inbounds %struct.fq, ptr %21, i32 0, i32 1
  %93 = load ptr, ptr %12, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.fq, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 4, !tbaa !11
  store i32 %95, ptr %92, align 4, !tbaa !13
  %96 = getelementptr inbounds %struct.fq, ptr %21, i32 0, i32 2
  %97 = load ptr, ptr %12, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.fq, ptr %97, i32 0, i32 1
  %99 = load i32, ptr %98, align 4, !tbaa !13
  store i32 %99, ptr %96, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %20, i64 12, i1 false), !tbaa.struct !15
  %100 = load i32, ptr @m, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %24, i64 12, i1 false)
  %101 = getelementptr inbounds { i64, i32 }, ptr %25, i32 0, i32 0
  %102 = load i64, ptr %101, align 4
  %103 = getelementptr inbounds { i64, i32 }, ptr %25, i32 0, i32 1
  %104 = load i32, ptr %103, align 4
  %105 = call noundef i32 @_Z8distinct2fqi(i64 %102, i32 %104, i32 noundef %100)
  %106 = mul nsw i32 1000, %105
  %107 = sitofp i32 %106 to double
  %108 = load i32, ptr %13, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  %110 = call i32 @llvm.abs.i32(i32 %109, i1 true)
  %111 = sitofp i32 %110 to double
  %112 = call double @pow(double noundef 2.000000e+00, double noundef %111) #7
  %113 = fsub double %107, %112
  %114 = fptosi double %113 to i32
  store i32 %114, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %21, i64 12, i1 false), !tbaa.struct !15
  %115 = load i32, ptr @m, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %27, i64 12, i1 false)
  %116 = getelementptr inbounds { i64, i32 }, ptr %28, i32 0, i32 0
  %117 = load i64, ptr %116, align 4
  %118 = getelementptr inbounds { i64, i32 }, ptr %28, i32 0, i32 1
  %119 = load i32, ptr %118, align 4
  %120 = call noundef i32 @_Z8distinct2fqi(i64 %117, i32 %119, i32 noundef %115)
  %121 = mul nsw i32 1000, %120
  %122 = sitofp i32 %121 to double
  %123 = load i32, ptr %13, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 1
  %125 = call i32 @llvm.abs.i32(i32 %124, i1 true)
  %126 = sitofp i32 %125 to double
  %127 = call double @pow(double noundef 2.000000e+00, double noundef %126) #7
  %128 = fsub double %122, %127
  %129 = fptosi double %128 to i32
  store i32 %129, ptr %26, align 4, !tbaa !5
  %130 = load i32, ptr %23, align 4, !tbaa !5
  %131 = icmp sgt i32 %130, 0
  br i1 %131, label %132, label %143

132:                                              ; preds = %74
  %133 = load i32, ptr %23, align 4, !tbaa !5
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = load ptr, ptr %9, align 8, !tbaa !9
  %137 = load ptr, ptr %10, align 8, !tbaa !9
  %138 = load ptr, ptr %12, align 8, !tbaa !9
  %139 = load i32, ptr %13, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  %141 = call noundef i32 @_Z5solveiRSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EERS1_R2fqSB_i(i32 noundef %135, ptr noundef nonnull align 8 dereferenceable(24) %136, ptr noundef nonnull align 8 dereferenceable(24) %137, ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %138, i32 noundef %140)
  %142 = add nsw i32 %133, %141
  store i32 %142, ptr %22, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %132, %74
  %144 = load i32, ptr %26, align 4, !tbaa !5
  %145 = icmp sgt i32 %144, 0
  br i1 %145, label %146, label %159

146:                                              ; preds = %143
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #7
  %147 = load i32, ptr %26, align 4, !tbaa !5
  %148 = load i32, ptr %8, align 4, !tbaa !5
  %149 = sub nsw i32 %148, 1
  %150 = load ptr, ptr %9, align 8, !tbaa !9
  %151 = load ptr, ptr %10, align 8, !tbaa !9
  %152 = load ptr, ptr %11, align 8, !tbaa !9
  %153 = load i32, ptr %13, align 4, !tbaa !5
  %154 = sub nsw i32 %153, 1
  %155 = call noundef i32 @_Z5solveiRSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EERS1_R2fqSB_i(i32 noundef %149, ptr noundef nonnull align 8 dereferenceable(24) %150, ptr noundef nonnull align 8 dereferenceable(24) %151, ptr noundef nonnull align 4 dereferenceable(12) %152, ptr noundef nonnull align 4 dereferenceable(12) %21, i32 noundef %154)
  %156 = add nsw i32 %147, %155
  store i32 %156, ptr %29, align 4, !tbaa !5
  %157 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %29)
  %158 = load i32, ptr %157, align 4, !tbaa !5
  store i32 %158, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #7
  br label %159

159:                                              ; preds = %146, %143
  %160 = load i32, ptr %22, align 4, !tbaa !5
  %161 = load ptr, ptr %9, align 8, !tbaa !9
  %162 = load i32, ptr %8, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %161, i64 noundef %163) #7
  %165 = load i32, ptr %14, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %164, i64 noundef %166) #7
  %168 = load i32, ptr %15, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %167, i64 noundef %169) #7
  %171 = load i32, ptr %16, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %170, i64 noundef %172) #7
  store i32 %160, ptr %173, align 4, !tbaa !5
  %174 = load i32, ptr %22, align 4, !tbaa !5
  store i32 %174, ptr %7, align 4
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %175

175:                                              ; preds = %159, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %176

176:                                              ; preds = %175, %36, %32
  %177 = load i32, ptr %7, align 4
  ret i32 %177
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6

attributes #0 = { mustprogress 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { inlinehint mustprogress 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 #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS2fq", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}


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

@m = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8distinct2fqi(i64, i32, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solveiRSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EERS1_R2fqSB_i(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %3, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca %struct.fq, align 8
  %8 = alloca %struct.fq, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = icmp eq i32 %0, -1
  br i1 %11, label %85, label %12

12:                                               ; preds = %6
  %13 = icmp sgt i32 %5, 12
  br i1 %13, label %85, label %14

14:                                               ; preds = %12
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = mul nsw i32 %15, 5
  %17 = getelementptr inbounds i8, ptr %3, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !10
  %19 = add nsw i32 %16, %18
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = mul nsw i32 %20, 5
  %22 = getelementptr inbounds i8, ptr %4, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !10
  %24 = add nsw i32 %21, %23
  %25 = add nsw i32 %5, 12
  %26 = sext i32 %0 to i64
  %27 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %26) #5
  %28 = sext i32 %19 to i64
  %29 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %27, i64 noundef %28) #5
  %30 = sext i32 %24 to i64
  %31 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %30) #5
  %32 = sext i32 %25 to i64
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %32) #5
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %.not = icmp eq i32 %34, -1
  br i1 %.not, label %35, label %85

35:                                               ; preds = %14
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %26) #5
  %37 = load i32, ptr %36, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #5
  store i32 %37, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %7, i64 4
  %39 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %39, ptr %38, align 4, !tbaa !10
  %40 = getelementptr inbounds i8, ptr %7, i64 8
  %41 = load i32, ptr %17, align 4, !tbaa !10
  store i32 %41, ptr %40, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #5
  store i32 %37, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %8, i64 4
  %43 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %43, ptr %42, align 4, !tbaa !10
  %44 = getelementptr inbounds i8, ptr %8, i64 8
  %45 = load i32, ptr %22, align 4, !tbaa !10
  store i32 %45, ptr %44, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #5
  store i32 0, ptr %9, align 4, !tbaa !11
  %.sroa.06.0.copyload = load i64, ptr %7, align 8
  %46 = load i32, ptr @m, align 4, !tbaa !11
  %47 = tail call noundef i32 @_Z8distinct2fqi(i64 %.sroa.06.0.copyload, i32 %41, i32 noundef %46)
  %48 = mul nsw i32 %47, 1000
  %49 = sitofp i32 %48 to double
  %50 = add nsw i32 %5, 1
  %51 = tail call i32 @llvm.abs.i32(i32 %50, i1 true)
  %52 = uitofp nneg i32 %51 to double
  %exp2 = tail call double @exp2(double %52)
  %53 = fsub double %49, %exp2
  %54 = fptosi double %53 to i32
  %.sroa.01.0.copyload = load i64, ptr %8, align 8
  %55 = load i32, ptr @m, align 4, !tbaa !11
  %56 = tail call noundef i32 @_Z8distinct2fqi(i64 %.sroa.01.0.copyload, i32 %45, i32 noundef %55)
  %57 = mul nsw i32 %56, 1000
  %58 = sitofp i32 %57 to double
  %59 = add nsw i32 %5, -1
  %60 = tail call i32 @llvm.abs.i32(i32 %59, i1 true)
  %61 = uitofp nneg i32 %60 to double
  %exp254 = tail call double @exp2(double %61)
  %62 = fsub double %58, %exp254
  %63 = fptosi double %62 to i32
  %64 = icmp sgt i32 %54, 0
  br i1 %64, label %65, label %69

65:                                               ; preds = %35
  %66 = add nsw i32 %0, -1
  %67 = call noundef i32 @_Z5solveiRSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EERS1_R2fqSB_i(i32 noundef %66, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef %50)
  %68 = add nsw i32 %67, %54
  store i32 %68, ptr %9, align 4, !tbaa !11
  br label %69

69:                                               ; preds = %65, %35
  %70 = phi i32 [ %68, %65 ], [ 0, %35 ]
  %71 = icmp sgt i32 %63, 0
  br i1 %71, label %72, label %78

72:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #5
  %73 = add nsw i32 %0, -1
  %74 = call noundef i32 @_Z5solveiRSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EERS1_R2fqSB_i(i32 noundef %73, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %8, i32 noundef %59)
  %75 = add nsw i32 %74, %63
  store i32 %75, ptr %10, align 4, !tbaa !11
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %77 = load i32, ptr %76, align 4, !tbaa !11
  store i32 %77, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #5
  br label %78

78:                                               ; preds = %72, %69
  %79 = phi i32 [ %77, %72 ], [ %70, %69 ]
  %80 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %26) #5
  %81 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %80, i64 noundef %28) #5
  %82 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %81, i64 noundef %30) #5
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %82, i64 noundef %32) #5
  store i32 %79, ptr %83, align 4, !tbaa !11
  %84 = load i32, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #5
  br label %85

85:                                               ; preds = %78, %14, %12, %6
  %.1 = phi i32 [ 0, %6 ], [ -2147483648, %12 ], [ %84, %78 ], [ %34, %14 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IS_IiSaIiEESaIS1_EESaIS3_EESaIS5_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

declare double @exp2(double) local_unnamed_addr

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { inlinehint mustprogress 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 #5 = { 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 0}
!6 = !{!"_ZTS2fq", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass