; LLVM IR from kalininalab/rinminer :: rinminer (rinminer)

; 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.output_t = type { ptr, i32, i64, i64, i64, ptr, i32, %union.pthread_mutex_t, i32, i32, i32, i32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@stderr = external global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [82 x i8], align 1

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind
declare i32 @ftruncate(i32 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @finalize_output(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp eq i32 %15, -1
  br i1 %16, label %17, label %18

17:                                               ; preds = %1
  br label %195

18:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.output_t, ptr %19, i32 0, i32 3
  %21 = load i64, ptr %20, align 8, !tbaa !13
  store i64 %21, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.output_t, ptr %22, i32 0, i32 8
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = sub i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !16
  br label %26

26:                                               ; preds = %77, %18
  %27 = load i32, ptr %5, align 4, !tbaa !16
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.output_t, ptr %28, i32 0, i32 6
  %30 = load i32, ptr %29, align 8, !tbaa !17
  %31 = icmp ult i32 %27, %30
  br i1 %31, label %32, label %78

32:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.output_t, ptr %33, i32 0, i32 4
  %35 = load i64, ptr %34, align 8, !tbaa !18
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.output_t, ptr %36, i32 0, i32 5
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  %39 = load i32, ptr %5, align 4, !tbaa !16
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds i64, ptr %38, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !14
  %43 = sub nsw i64 %35, %42
  store i64 %43, ptr %6, align 8, !tbaa !14
  %44 = load i64, ptr %6, align 8, !tbaa !14
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.output_t, ptr %45, i32 0, i32 2
  %47 = load i64, ptr %46, align 8, !tbaa !20
  %48 = icmp sle i64 %44, %47
  br i1 %48, label %49, label %62

49:                                               ; preds = %32
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.output_t, ptr %50, i32 0, i32 5
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  %53 = load i32, ptr %5, align 4, !tbaa !16
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i64, ptr %52, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !14
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.output_t, ptr %57, i32 0, i32 2
  %59 = load i64, ptr %58, align 8, !tbaa !20
  %60 = srem i64 %56, %59
  store i64 %60, ptr %3, align 8, !tbaa !14
  %61 = load i64, ptr %6, align 8, !tbaa !14
  store i64 %61, ptr %4, align 8, !tbaa !14
  store i32 3, ptr %7, align 4
  br label %75

62:                                               ; preds = %32
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = load i32, ptr %5, align 4, !tbaa !16
  %65 = add i32 %64, 1
  %66 = load i64, ptr %6, align 8, !tbaa !14
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.output_t, ptr %67, i32 0, i32 9
  %69 = load i32, ptr %68, align 4, !tbaa !21
  %70 = zext i32 %69 to i64
  %71 = add nsw i64 %66, %70
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.15, i32 noundef %65, i64 noundef %71) #6
  %73 = load i32, ptr %5, align 4, !tbaa !16
  %74 = add i32 %73, 1
  store i32 %74, ptr %5, align 4, !tbaa !16
  store i32 0, ptr %7, align 4
  br label %75

75:                                               ; preds = %62, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %76 = load i32, ptr %7, align 4
  switch i32 %76, label %196 [
    i32 0, label %77
    i32 3, label %78
  ]

77:                                               ; preds = %75
  br label %26, !llvm.loop !22

78:                                               ; preds = %75, %26
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.output_t, ptr %79, i32 0, i32 5
  %81 = load ptr, ptr %80, align 8, !tbaa !19
  call void @free(ptr noundef %81) #6
  %82 = load i64, ptr %3, align 8, !tbaa !14
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.output_t, ptr %83, i32 0, i32 3
  %85 = load i64, ptr %84, align 8, !tbaa !13
  %86 = icmp sle i64 %82, %85
  br i1 %86, label %87, label %101

87:                                               ; preds = %78
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.output_t, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !24
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.output_t, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !24
  %94 = load i64, ptr %3, align 8, !tbaa !14
  %95 = getelementptr inbounds i8, ptr %93, i64 %94
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.output_t, ptr %96, i32 0, i32 3
  %98 = load i64, ptr %97, align 8, !tbaa !13
  %99 = load i64, ptr %3, align 8, !tbaa !14
  %100 = sub nsw i64 %98, %99
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %90, ptr align 1 %95, i64 %100, i1 false)
  br label %155

101:                                              ; preds = %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %102 = load i64, ptr %3, align 8, !tbaa !14
  store i64 %102, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.output_t, ptr %103, i32 0, i32 2
  %105 = load i64, ptr %104, align 8, !tbaa !20
  store i64 %105, ptr %10, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %106 = load i64, ptr %9, align 8, !tbaa !14
  store i64 %106, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  br label %107

107:                                              ; preds = %153, %101
  %108 = load i64, ptr %8, align 8, !tbaa !14
  %109 = load i64, ptr %4, align 8, !tbaa !14
  %110 = icmp slt i64 %108, %109
  br i1 %110, label %111, label %154

111:                                              ; preds = %107
  %112 = load i64, ptr %9, align 8, !tbaa !14
  %113 = load i64, ptr %8, align 8, !tbaa !14
  %114 = sub nsw i64 %112, %113
  %115 = load i64, ptr %10, align 8, !tbaa !14
  %116 = load i64, ptr %9, align 8, !tbaa !14
  %117 = sub nsw i64 %115, %116
  %118 = icmp slt i64 %114, %117
  br i1 %118, label %119, label %123

119:                                              ; preds = %111
  %120 = load i64, ptr %9, align 8, !tbaa !14
  %121 = load i64, ptr %8, align 8, !tbaa !14
  %122 = sub nsw i64 %120, %121
  br label %127

123:                                              ; preds = %111
  %124 = load i64, ptr %10, align 8, !tbaa !14
  %125 = load i64, ptr %9, align 8, !tbaa !14
  %126 = sub nsw i64 %124, %125
  br label %127

127:                                              ; preds = %123, %119
  %128 = phi i64 [ %122, %119 ], [ %126, %123 ]
  store i64 %128, ptr %12, align 8, !tbaa !14
  %129 = load ptr, ptr %2, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.output_t, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !24
  %132 = load i64, ptr %8, align 8, !tbaa !14
  %133 = load i64, ptr %11, align 8, !tbaa !14
  %134 = load i64, ptr %12, align 8, !tbaa !14
  call void @swap_range(ptr noundef %131, i64 noundef %132, i64 noundef %133, i64 noundef %134)
  %135 = load i64, ptr %12, align 8, !tbaa !14
  %136 = load i64, ptr %8, align 8, !tbaa !14
  %137 = add nsw i64 %136, %135
  store i64 %137, ptr %8, align 8, !tbaa !14
  %138 = load i64, ptr %12, align 8, !tbaa !14
  %139 = load i64, ptr %11, align 8, !tbaa !14
  %140 = add nsw i64 %139, %138
  store i64 %140, ptr %11, align 8, !tbaa !14
  %141 = load i64, ptr %11, align 8, !tbaa !14
  %142 = load i64, ptr %10, align 8, !tbaa !14
  %143 = icmp eq i64 %141, %142
  br i1 %143, label %144, label %146

144:                                              ; preds = %127
  %145 = load i64, ptr %9, align 8, !tbaa !14
  store i64 %145, ptr %11, align 8, !tbaa !14
  br label %153

146:                                              ; preds = %127
  %147 = load i64, ptr %8, align 8, !tbaa !14
  %148 = load i64, ptr %9, align 8, !tbaa !14
  %149 = icmp eq i64 %147, %148
  br i1 %149, label %150, label %152

150:                                              ; preds = %146
  %151 = load i64, ptr %11, align 8, !tbaa !14
  store i64 %151, ptr %9, align 8, !tbaa !14
  br label %152

152:                                              ; preds = %150, %146
  br label %153

153:                                              ; preds = %152, %144
  br label %107, !llvm.loop !25

154:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %155

155:                                              ; preds = %154, %87
  %156 = load ptr, ptr %2, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.output_t, ptr %156, i32 0, i32 9
  %158 = load i32, ptr %157, align 4, !tbaa !21
  %159 = load ptr, ptr %2, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.output_t, ptr %159, i32 0, i32 0
  %161 = load ptr, ptr %160, align 8, !tbaa !24
  %162 = zext i32 %158 to i64
  %163 = sub i64 0, %162
  %164 = getelementptr inbounds i8, ptr %161, i64 %163
  store ptr %164, ptr %160, align 8, !tbaa !24
  %165 = load ptr, ptr %2, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.output_t, ptr %165, i32 0, i32 9
  %167 = load i32, ptr %166, align 4, !tbaa !21
  %168 = zext i32 %167 to i64
  %169 = load ptr, ptr %2, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.output_t, ptr %169, i32 0, i32 2
  %171 = load i64, ptr %170, align 8, !tbaa !20
  %172 = add nsw i64 %171, %168
  store i64 %172, ptr %170, align 8, !tbaa !20
  %173 = load ptr, ptr %2, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.output_t, ptr %173, i32 0, i32 9
  %175 = load i32, ptr %174, align 4, !tbaa !21
  %176 = zext i32 %175 to i64
  %177 = load i64, ptr %4, align 8, !tbaa !14
  %178 = add nsw i64 %177, %176
  store i64 %178, ptr %4, align 8, !tbaa !14
  %179 = load ptr, ptr %2, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.output_t, ptr %179, i32 0, i32 0
  %181 = load ptr, ptr %180, align 8, !tbaa !24
  %182 = load ptr, ptr %2, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.output_t, ptr %182, i32 0, i32 2
  %184 = load i64, ptr %183, align 8, !tbaa !20
  %185 = call i32 @munmap(ptr noundef %181, i64 noundef %184) #6
  %186 = load ptr, ptr %2, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.output_t, ptr %186, i32 0, i32 1
  %188 = load i32, ptr %187, align 8, !tbaa !9
  %189 = load i64, ptr %4, align 8, !tbaa !14
  %190 = call i32 @ftruncate(i32 noundef %188, i64 noundef %189) #6
  %191 = load ptr, ptr %2, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.output_t, ptr %191, i32 0, i32 1
  %193 = load i32, ptr %192, align 8, !tbaa !9
  %194 = call i32 @close(i32 noundef %193)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %195

195:                                              ; preds = %155, %17
  ret void

196:                                              ; preds = %75
  unreachable
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @swap_range(ptr noundef, i64 noundef, i64 noundef, i64 noundef) #4

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

declare i32 @close(i32 noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { "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 = { 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, !11, i64 8}
!10 = !{!"output_t", !6, i64 0, !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !6, i64 40, !11, i64 48, !7, i64 56, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 24}
!14 = !{!12, !12, i64 0}
!15 = !{!10, !11, i64 96}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 48}
!18 = !{!10, !12, i64 32}
!19 = !{!10, !6, i64 40}
!20 = !{!10, !12, i64 16}
!21 = !{!10, !11, i64 100}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!10, !6, i64 0}
!25 = distinct !{!25, !23}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [82 x i8], align 1

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

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

; Function Attrs: nounwind
declare i32 @ftruncate(i32 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @finalize_output(ptr nocapture noundef %0) local_unnamed_addr #3 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp eq i32 %3, -1
  br i1 %4, label %71, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = add i32 %9, -1
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = icmp ult i32 %10, %12
  br i1 %13, label %.lr.ph, label %.loopexit88

.lr.ph:                                           ; preds = %5
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = getelementptr inbounds i8, ptr %0, i64 100
  %18 = zext i32 %10 to i64
  br label %19

19:                                               ; preds = %.lr.ph, %27
  %indvars.iv = phi i64 [ %18, %.lr.ph ], [ %indvars.iv.next, %27 ]
  %20 = load i64, ptr %14, align 8, !tbaa !15
  %21 = load ptr, ptr %15, align 8, !tbaa !16
  %22 = getelementptr inbounds i64, ptr %21, i64 %indvars.iv
  %23 = load i64, ptr %22, align 8, !tbaa !17
  %24 = sub nsw i64 %20, %23
  %25 = load i64, ptr %16, align 8, !tbaa !18
  %.not = icmp sgt i64 %24, %25
  br i1 %.not, label %27, label %.thread

.thread:                                          ; preds = %19
  %26 = srem i64 %23, %25
  br label %.loopexit88

27:                                               ; preds = %19
  %28 = load ptr, ptr @stderr, align 8, !tbaa !19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr %17, align 4, !tbaa !20
  %30 = zext i32 %29 to i64
  %31 = add nsw i64 %24, %30
  %32 = trunc nuw i64 %indvars.iv.next to i32
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.15, i32 noundef %32, i64 noundef %31) #8
  %34 = load i32, ptr %11, align 8, !tbaa !14
  %35 = zext i32 %34 to i64
  %36 = icmp ult i64 %indvars.iv.next, %35
  br i1 %36, label %19, label %.loopexit88

.loopexit88:                                      ; preds = %27, %5, %.thread
  %.268 = phi i64 [ %24, %.thread ], [ 0, %5 ], [ 0, %27 ]
  %.2 = phi i64 [ %26, %.thread ], [ %7, %5 ], [ %7, %27 ]
  %37 = getelementptr inbounds i8, ptr %0, i64 40
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  tail call void @free(ptr noundef %38) #9
  %39 = load i64, ptr %6, align 8, !tbaa !12
  %.not82 = icmp sgt i64 %.2, %39
  br i1 %.not82, label %44, label %40

40:                                               ; preds = %.loopexit88
  %41 = load ptr, ptr %0, align 8, !tbaa !21
  %42 = getelementptr inbounds i8, ptr %41, i64 %.2
  %43 = sub nsw i64 %39, %.2
  tail call void @llvm.memmove.p0.p0.i64(ptr align 1 %41, ptr align 1 %42, i64 %43, i1 false)
  br label %.loopexit

44:                                               ; preds = %.loopexit88
  %45 = getelementptr inbounds i8, ptr %0, i64 16
  %46 = load i64, ptr %45, align 8, !tbaa !18
  %47 = icmp sgt i64 %.268, 0
  br i1 %47, label %.lr.ph95, label %.loopexit

.lr.ph95:                                         ; preds = %44, %.lr.ph95
  %.06494 = phi i64 [ %.165, %.lr.ph95 ], [ %.2, %44 ]
  %.06993 = phi i64 [ %.170, %.lr.ph95 ], [ %.2, %44 ]
  %.07192 = phi i64 [ %51, %.lr.ph95 ], [ 0, %44 ]
  %48 = sub nsw i64 %.06993, %.07192
  %49 = sub nsw i64 %46, %.06993
  %. = tail call i64 @llvm.smin.i64(i64 %48, i64 %49)
  %50 = load ptr, ptr %0, align 8, !tbaa !21
  tail call void @swap_range(ptr noundef %50, i64 noundef %.07192, i64 noundef %.06494, i64 noundef %.)
  %51 = add nsw i64 %., %.07192
  %52 = add nsw i64 %., %.06494
  %53 = icmp eq i64 %52, %46
  %54 = icmp eq i64 %51, %.06993
  %spec.select = select i1 %54, i64 %52, i64 %.06993
  %.170 = select i1 %53, i64 %.06993, i64 %spec.select
  %.165 = select i1 %53, i64 %.06993, i64 %52
  %55 = icmp slt i64 %51, %.268
  br i1 %55, label %.lr.ph95, label %.loopexit, !llvm.loop !22

.loopexit:                                        ; preds = %.lr.ph95, %44, %40
  %56 = getelementptr inbounds i8, ptr %0, i64 100
  %57 = load i32, ptr %56, align 4, !tbaa !20
  %58 = load ptr, ptr %0, align 8, !tbaa !21
  %59 = zext i32 %57 to i64
  %60 = sub nsw i64 0, %59
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  store ptr %61, ptr %0, align 8, !tbaa !21
  %62 = getelementptr inbounds i8, ptr %0, i64 16
  %63 = load i64, ptr %62, align 8, !tbaa !18
  %64 = add nsw i64 %63, %59
  store i64 %64, ptr %62, align 8, !tbaa !18
  %65 = add nsw i64 %.268, %59
  %66 = tail call i32 @munmap(ptr noundef %61, i64 noundef %64) #9
  %67 = load i32, ptr %2, align 8, !tbaa !5
  %68 = tail call i32 @ftruncate(i32 noundef %67, i64 noundef %65) #9
  %69 = load i32, ptr %2, align 8, !tbaa !5
  %70 = tail call i32 @close(i32 noundef %69) #9
  br label %71

71:                                               ; preds = %1, %.loopexit
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @swap_range(ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i32 @munmap(ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @close(i32 noundef) local_unnamed_addr #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #7

attributes #0 = { 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 #1 = { 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 #2 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { cold nounwind }
attributes #9 = { 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, !10, i64 8}
!6 = !{!"output_t", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !10, i64 48, !8, i64 56, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !11, i64 24}
!13 = !{!6, !10, i64 96}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !11, i64 32}
!16 = !{!6, !7, i64 40}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 16}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !10, i64 100}
!21 = !{!6, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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