; LLVM IR from attractivechaos/klib :: test (krmq_test)

; 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.my_node = type { i32, i32, %struct.anon }
%struct.anon = type { [2 x ptr], ptr, i8, i32 }
%struct.krmq_itr_my = type { [64 x ptr], ptr }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @krmq_insert_my(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @krmq_erase_my(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @krmq_itr_first_my(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @krmq_itr_next_bidir_my(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check_rmq(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @check_and_print(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @shuffle(i32 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare double @drand48() #3

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca [256 x i8], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.my_node, align 8
  %11 = alloca %struct.krmq_itr_my, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 520, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @srand48(i64 noundef 123) #5
  store i32 33, ptr %3, align 4, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %41, %0
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 126
  br i1 %20, label %21, label %44

21:                                               ; preds = %18
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 40
  br i1 %23, label %24, label %40

24:                                               ; preds = %21
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 41
  br i1 %26, label %27, label %40

27:                                               ; preds = %24
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 46
  br i1 %29, label %30, label %40

30:                                               ; preds = %27
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 59
  br i1 %32, label %33, label %40

33:                                               ; preds = %30
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = trunc i32 %34 to i8
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %4, align 4, !tbaa !9
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds [256 x i8], ptr %2, i64 0, i64 %38
  store i8 %35, ptr %39, align 1, !tbaa !11
  br label %40

40:                                               ; preds = %33, %30, %27, %24, %21
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !9
  br label %18, !llvm.loop !12

44:                                               ; preds = %18
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = getelementptr inbounds [256 x i8], ptr %2, i64 0, i64 0
  call void @shuffle(i32 noundef %45, ptr noundef %46)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %73, %44
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %51, label %76

51:                                               ; preds = %47
  %52 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 40) #6
  store ptr %52, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [256 x i8], ptr %2, i64 0, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !11
  %57 = sext i8 %56 to i32
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.my_node, ptr %58, i32 0, i32 0
  store i32 %57, ptr %59, align 8, !tbaa !14
  %60 = load i32, ptr %3, align 4, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.my_node, ptr %61, i32 0, i32 1
  store i32 %60, ptr %62, align 4, !tbaa !17
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = call ptr @krmq_insert_my(ptr noundef %7, ptr noundef %63, ptr noundef %12)
  store ptr %64, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = icmp ne ptr %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %51
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %69) #5
  br label %70

70:                                               ; preds = %68, %51
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = call i32 @check(ptr noundef %71, ptr noundef %5, ptr noundef %6)
  br label %73

73:                                               ; preds = %70
  %74 = load i32, ptr %3, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %3, align 4, !tbaa !9
  br label %47, !llvm.loop !18

76:                                               ; preds = %47
  %77 = load i32, ptr %4, align 4, !tbaa !9
  %78 = getelementptr inbounds [256 x i8], ptr %2, i64 0, i64 0
  call void @shuffle(i32 noundef %77, ptr noundef %78)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %99, %76
  %80 = load i32, ptr %3, align 4, !tbaa !9
  %81 = load i32, ptr %4, align 4, !tbaa !9
  %82 = sdiv i32 %81, 2
  %83 = icmp slt i32 %80, %82
  br i1 %83, label %84, label %102

84:                                               ; preds = %79
  %85 = load i32, ptr %3, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [256 x i8], ptr %2, i64 0, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !11
  %89 = sext i8 %88 to i32
  %90 = getelementptr inbounds %struct.my_node, ptr %10, i32 0, i32 0
  store i32 %89, ptr %90, align 8, !tbaa !14
  %91 = call ptr @krmq_erase_my(ptr noundef %7, ptr noundef %10, ptr noundef null)
  store ptr %91, ptr %9, align 8, !tbaa !5
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = icmp ne ptr %92, null
  br i1 %93, label %94, label %96

94:                                               ; preds = %84
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %95) #5
  br label %96

96:                                               ; preds = %94, %84
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = call i32 @check(ptr noundef %97, ptr noundef %5, ptr noundef %6)
  br label %99

99:                                               ; preds = %96
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %3, align 4, !tbaa !9
  br label %79, !llvm.loop !19

102:                                              ; preds = %79
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  call void @check_and_print(ptr noundef %103)
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = call i32 @check_rmq(ptr noundef %104, i32 noundef 48, i32 noundef 57)
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = call i32 @check_rmq(ptr noundef %106, i32 noundef 33, i32 noundef 126)
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = call i32 @check_rmq(ptr noundef %108, i32 noundef 65, i32 noundef 90)
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = call i32 @check_rmq(ptr noundef %110, i32 noundef 70, i32 noundef 71)
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = call i32 @check_rmq(ptr noundef %112, i32 noundef 97, i32 noundef 122)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %114

114:                                              ; preds = %133, %102
  %115 = load i32, ptr %3, align 4, !tbaa !9
  %116 = load i32, ptr %4, align 4, !tbaa !9
  %117 = icmp slt i32 %115, %116
  br i1 %117, label %118, label %136

118:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %119 = call double @drand48() #5
  %120 = load i32, ptr %4, align 4, !tbaa !9
  %121 = sitofp i32 %120 to double
  %122 = fmul double %119, %121
  %123 = fptosi double %122 to i32
  store i32 %123, ptr %13, align 4, !tbaa !9
  %124 = call double @drand48() #5
  %125 = load i32, ptr %4, align 4, !tbaa !9
  %126 = sitofp i32 %125 to double
  %127 = fmul double %124, %126
  %128 = fptosi double %127 to i32
  store i32 %128, ptr %14, align 4, !tbaa !9
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = load i32, ptr %13, align 4, !tbaa !9
  %131 = load i32, ptr %14, align 4, !tbaa !9
  %132 = call i32 @check_rmq(ptr noundef %129, i32 noundef %130, i32 noundef %131)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %133

133:                                              ; preds = %118
  %134 = load i32, ptr %3, align 4, !tbaa !9
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %3, align 4, !tbaa !9
  br label %114, !llvm.loop !20

136:                                              ; preds = %114
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  call void @krmq_itr_first_my(ptr noundef %137, ptr noundef %11)
  br label %138

138:                                              ; preds = %155, %136
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %139 = getelementptr inbounds %struct.krmq_itr_my, ptr %11, i32 0, i32 1
  %140 = load ptr, ptr %139, align 8, !tbaa !21
  %141 = getelementptr inbounds %struct.krmq_itr_my, ptr %11, i32 0, i32 0
  %142 = getelementptr inbounds [64 x ptr], ptr %141, i64 0, i64 0
  %143 = icmp ult ptr %140, %142
  br i1 %143, label %144, label %145

144:                                              ; preds = %138
  br label %149

145:                                              ; preds = %138
  %146 = getelementptr inbounds %struct.krmq_itr_my, ptr %11, i32 0, i32 1
  %147 = load ptr, ptr %146, align 8, !tbaa !21
  %148 = load ptr, ptr %147, align 8, !tbaa !5
  br label %149

149:                                              ; preds = %145, %144
  %150 = phi ptr [ null, %144 ], [ %148, %145 ]
  store ptr %150, ptr %15, align 8, !tbaa !5
  %151 = load ptr, ptr %15, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.my_node, ptr %151, i32 0, i32 0
  %153 = load i32, ptr %152, align 8, !tbaa !14
  %154 = call i32 @putchar(i32 noundef %153)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %155

155:                                              ; preds = %149
  %156 = call i32 @krmq_itr_next_bidir_my(ptr noundef %11, i32 noundef 1)
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %138, label %158, !llvm.loop !23

158:                                              ; preds = %155
  %159 = call i32 @putchar(i32 noundef 10)
  br label %160

160:                                              ; preds = %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %161 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %161, ptr %16, align 8, !tbaa !5
  br label %162

162:                                              ; preds = %200, %160
  %163 = load ptr, ptr %16, align 8, !tbaa !5
  %164 = icmp ne ptr %163, null
  br i1 %164, label %165, label %202

165:                                              ; preds = %162
  %166 = load ptr, ptr %16, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.my_node, ptr %166, i32 0, i32 2
  %168 = getelementptr inbounds %struct.anon, ptr %167, i32 0, i32 0
  %169 = getelementptr inbounds [2 x ptr], ptr %168, i64 0, i64 0
  %170 = load ptr, ptr %169, align 8, !tbaa !5
  %171 = icmp eq ptr %170, null
  br i1 %171, label %172, label %179

172:                                              ; preds = %165
  %173 = load ptr, ptr %16, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.my_node, ptr %173, i32 0, i32 2
  %175 = getelementptr inbounds %struct.anon, ptr %174, i32 0, i32 0
  %176 = getelementptr inbounds [2 x ptr], ptr %175, i64 0, i64 1
  %177 = load ptr, ptr %176, align 8, !tbaa !5
  store ptr %177, ptr %17, align 8, !tbaa !5
  %178 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %178) #5
  br label %199

179:                                              ; preds = %165
  %180 = load ptr, ptr %16, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.my_node, ptr %180, i32 0, i32 2
  %182 = getelementptr inbounds %struct.anon, ptr %181, i32 0, i32 0
  %183 = getelementptr inbounds [2 x ptr], ptr %182, i64 0, i64 0
  %184 = load ptr, ptr %183, align 8, !tbaa !5
  store ptr %184, ptr %17, align 8, !tbaa !5
  %185 = load ptr, ptr %17, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.my_node, ptr %185, i32 0, i32 2
  %187 = getelementptr inbounds %struct.anon, ptr %186, i32 0, i32 0
  %188 = getelementptr inbounds [2 x ptr], ptr %187, i64 0, i64 1
  %189 = load ptr, ptr %188, align 8, !tbaa !5
  %190 = load ptr, ptr %16, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.my_node, ptr %190, i32 0, i32 2
  %192 = getelementptr inbounds %struct.anon, ptr %191, i32 0, i32 0
  %193 = getelementptr inbounds [2 x ptr], ptr %192, i64 0, i64 0
  store ptr %189, ptr %193, align 8, !tbaa !5
  %194 = load ptr, ptr %16, align 8, !tbaa !5
  %195 = load ptr, ptr %17, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.my_node, ptr %195, i32 0, i32 2
  %197 = getelementptr inbounds %struct.anon, ptr %196, i32 0, i32 0
  %198 = getelementptr inbounds [2 x ptr], ptr %197, i64 0, i64 1
  store ptr %194, ptr %198, align 8, !tbaa !5
  br label %199

199:                                              ; preds = %179, %172
  br label %200

200:                                              ; preds = %199
  %201 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %201, ptr %16, align 8, !tbaa !5
  br label %162, !llvm.loop !24

202:                                              ; preds = %162
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %203

203:                                              ; preds = %202
  br label %204

204:                                              ; preds = %203
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 520, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %2) #5
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand48(i64 noundef) #3

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

attributes #0 = { 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 = { inlinehint 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 = { 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 #4 = { nounwind allocsize(0,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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 0}
!15 = !{!"my_node", !10, i64 0, !10, i64 4, !16, i64 8}
!16 = !{!"", !7, i64 0, !6, i64 16, !7, i64 24, !10, i64 28}
!17 = !{!15, !10, i64 4}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}
!21 = !{!22, !6, i64 512}
!22 = !{!"krmq_itr_my", !7, i64 0, !6, i64 512}
!23 = distinct !{!23, !13}
!24 = distinct !{!24, !13}


; 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.my_node = type { i32, i32, %struct.anon }
%struct.anon = type { [2 x ptr], ptr, i8, i32 }
%struct.krmq_itr_my = type { [64 x ptr], ptr }

; 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 dso_local ptr @krmq_insert_my(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @krmq_erase_my(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @krmq_itr_first_my(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @krmq_itr_next_bidir_my(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check_rmq(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @check_and_print(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @shuffle(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare double @drand48() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca [256 x i8], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %struct.my_node, align 8
  %6 = alloca %struct.krmq_itr_my, align 8
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  tail call void @srand48(i64 noundef 123) #7
  br label %8

8:                                                ; preds = %21, %0
  %.05061 = phi i32 [ 33, %0 ], [ %22, %21 ]
  %.05160 = phi i32 [ 0, %0 ], [ %.152.1, %21 ]
  switch i32 %.05061, label %9 [
    i32 59, label %14
    i32 46, label %14
    i32 41, label %14
    i32 40, label %14
  ]

9:                                                ; preds = %8
  %10 = trunc nuw i32 %.05061 to i8
  %11 = add nsw i32 %.05160, 1
  %12 = sext i32 %.05160 to i64
  %13 = getelementptr inbounds [256 x i8], ptr %1, i64 0, i64 %12
  store i8 %10, ptr %13, align 1, !tbaa !9
  br label %14

14:                                               ; preds = %8, %8, %8, %8, %9
  %.152 = phi i32 [ %11, %9 ], [ %.05160, %8 ], [ %.05160, %8 ], [ %.05160, %8 ], [ %.05160, %8 ]
  switch i32 %.05061, label %15 [
    i32 58, label %21
    i32 45, label %21
    i32 40, label %21
    i32 39, label %21
  ]

15:                                               ; preds = %14
  %16 = trunc i32 %.05061 to i8
  %17 = add i8 %16, 1
  %18 = add nsw i32 %.152, 1
  %19 = sext i32 %.152 to i64
  %20 = getelementptr inbounds [256 x i8], ptr %1, i64 0, i64 %19
  store i8 %17, ptr %20, align 1, !tbaa !9
  br label %21

21:                                               ; preds = %15, %14, %14, %14, %14
  %.152.1 = phi i32 [ %18, %15 ], [ %.152, %14 ], [ %.152, %14 ], [ %.152, %14 ], [ %.152, %14 ]
  %22 = add nuw nsw i32 %.05061, 2
  %exitcond.not.1 = icmp eq i32 %22, 127
  br i1 %exitcond.not.1, label %23, label %8, !llvm.loop !10

23:                                               ; preds = %21
  call void @shuffle(i32 noundef %.152.1, ptr noundef nonnull %1)
  %24 = icmp sgt i32 %.152.1, 0
  br i1 %24, label %.lr.ph.preheader, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %23
  call void @shuffle(i32 noundef %.152.1, ptr noundef nonnull %1)
  br label %._crit_edge66

.lr.ph.preheader:                                 ; preds = %23
  %wide.trip.count = zext nneg i32 %.152.1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %33
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %33 ]
  %25 = call noalias dereferenceable_or_null(40) ptr @calloc(i64 noundef 1, i64 noundef 40) #8
  %26 = getelementptr inbounds [256 x i8], ptr %1, i64 0, i64 %indvars.iv
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  store i32 %28, ptr %25, align 8, !tbaa !12
  %29 = getelementptr inbounds i8, ptr %25, i64 4
  %30 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %30, ptr %29, align 4, !tbaa !16
  %31 = call ptr @krmq_insert_my(ptr noundef nonnull %4, ptr noundef nonnull %25, ptr noundef nonnull %7)
  %.not59 = icmp eq ptr %25, %31
  br i1 %.not59, label %33, label %32

32:                                               ; preds = %.lr.ph
  call void @free(ptr noundef nonnull %25) #7
  br label %33

33:                                               ; preds = %32, %.lr.ph
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = call i32 @check(ptr noundef %34, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond77.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond77.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %33
  call void @shuffle(i32 noundef %.152.1, ptr noundef nonnull %1)
  %.not84 = icmp eq i32 %.152.1, 1
  br i1 %.not84, label %._crit_edge66, label %.lr.ph65.preheader

.lr.ph65.preheader:                               ; preds = %._crit_edge
  %36 = lshr i32 %.152.1, 1
  %wide.trip.count81 = zext nneg i32 %36 to i64
  br label %.lr.ph65

.lr.ph65:                                         ; preds = %.lr.ph65.preheader, %42
  %indvars.iv78 = phi i64 [ 0, %.lr.ph65.preheader ], [ %indvars.iv.next79, %42 ]
  %37 = getelementptr inbounds [256 x i8], ptr %1, i64 0, i64 %indvars.iv78
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = sext i8 %38 to i32
  store i32 %39, ptr %5, align 8, !tbaa !12
  %40 = call ptr @krmq_erase_my(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef null)
  %.not58 = icmp eq ptr %40, null
  br i1 %.not58, label %42, label %41

41:                                               ; preds = %.lr.ph65
  call void @free(ptr noundef nonnull %40) #7
  br label %42

42:                                               ; preds = %41, %.lr.ph65
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call i32 @check(ptr noundef %43, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond82.not = icmp eq i64 %indvars.iv.next79, %wide.trip.count81
  br i1 %exitcond82.not, label %._crit_edge66, label %.lr.ph65, !llvm.loop !18

._crit_edge66:                                    ; preds = %42, %._crit_edge.thread, %._crit_edge
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @check_and_print(ptr noundef %45)
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = call i32 @check_rmq(ptr noundef %46, i32 noundef 48, i32 noundef 57)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = call i32 @check_rmq(ptr noundef %48, i32 noundef 33, i32 noundef 126)
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call i32 @check_rmq(ptr noundef %50, i32 noundef 65, i32 noundef 90)
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call i32 @check_rmq(ptr noundef %52, i32 noundef 70, i32 noundef 71)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call i32 @check_rmq(ptr noundef %54, i32 noundef 97, i32 noundef 122)
  br i1 %24, label %.lr.ph69, label %._crit_edge70

.lr.ph69:                                         ; preds = %._crit_edge66
  %56 = uitofp nneg i32 %.152.1 to double
  br label %57

57:                                               ; preds = %.lr.ph69, %57
  %.367 = phi i32 [ 0, %.lr.ph69 ], [ %66, %57 ]
  %58 = call double @drand48() #7
  %59 = fmul double %58, %56
  %60 = fptosi double %59 to i32
  %61 = call double @drand48() #7
  %62 = fmul double %61, %56
  %63 = fptosi double %62 to i32
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @check_rmq(ptr noundef %64, i32 noundef %60, i32 noundef %63)
  %66 = add nuw nsw i32 %.367, 1
  %exitcond83.not = icmp eq i32 %66, %.152.1
  br i1 %exitcond83.not, label %._crit_edge70, label %57, !llvm.loop !19

._crit_edge70:                                    ; preds = %57, %._crit_edge66
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  call void @krmq_itr_first_my(ptr noundef %67, ptr noundef nonnull %6)
  %68 = getelementptr inbounds i8, ptr %6, i64 512
  br label %69

69:                                               ; preds = %69, %._crit_edge70
  %70 = load ptr, ptr %68, align 8, !tbaa !20
  %71 = icmp uge ptr %70, %6
  call void @llvm.assume(i1 %71)
  %72 = load ptr, ptr %70, align 8, !tbaa !5
  %73 = load i32, ptr %72, align 8, !tbaa !12
  %74 = call i32 @putchar(i32 noundef %73)
  %75 = call i32 @krmq_itr_next_bidir_my(ptr noundef nonnull %6, i32 noundef 1)
  %.not = icmp eq i32 %75, 0
  br i1 %.not, label %76, label %69, !llvm.loop !22

76:                                               ; preds = %69
  %77 = call i32 @putchar(i32 noundef 10)
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %.not5771 = icmp eq ptr %78, null
  br i1 %.not5771, label %._crit_edge75, label %.lr.ph74

.lr.ph74:                                         ; preds = %76, %88
  %.04972 = phi ptr [ %.0, %88 ], [ %78, %76 ]
  %79 = getelementptr inbounds i8, ptr %.04972, i64 8
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = icmp eq ptr %80, null
  br i1 %81, label %82, label %85

82:                                               ; preds = %.lr.ph74
  %83 = getelementptr inbounds i8, ptr %.04972, i64 16
  %84 = load ptr, ptr %83, align 8, !tbaa !5
  call void @free(ptr noundef nonnull %.04972) #7
  br label %88

85:                                               ; preds = %.lr.ph74
  %86 = getelementptr inbounds i8, ptr %80, i64 16
  %87 = load ptr, ptr %86, align 8, !tbaa !5
  store ptr %87, ptr %79, align 8, !tbaa !5
  store ptr %.04972, ptr %86, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %82, %85
  %.0 = phi ptr [ %84, %82 ], [ %80, %85 ]
  %.not57 = icmp eq ptr %.0, null
  br i1 %.not57, label %._crit_edge75, label %.lr.ph74, !llvm.loop !23

._crit_edge75:                                    ; preds = %88, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %1) #7
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand48(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #6

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 = { inlinehint nofree 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 = { 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #6 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !14, i64 0}
!13 = !{!"my_node", !14, i64 0, !14, i64 4, !15, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !7, i64 0, !6, i64 16, !7, i64 24, !14, i64 28}
!16 = !{!13, !14, i64 4}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11}
!20 = !{!21, !6, i64 512}
!21 = !{!"krmq_itr_my", !7, i64 0, !6, i64 512}
!22 = distinct !{!22, !11}
!23 = distinct !{!23, !11}


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