; LLVM IR from indygreg/python-zstandard :: zstd (zstd)

; 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.ZSTD_frameProgression = type { i64, i64, i64, i64, i32, i32 }
%struct.ZSTDMT_CCtx_s = type { ptr, ptr, ptr, ptr, ptr, %struct.ZSTD_CCtx_params_s, i64, i64, i32, %struct.inBuff_t, %struct.roundBuff_t, %struct.serialState_t, %struct.rsyncState_t, i32, i32, i32, i32, i32, i64, i64, i64, %struct.ZSTD_customMem, ptr, ptr, i8 }
%struct.ZSTD_CCtx_params_s = type { i32, %struct.ZSTD_compressionParameters, %struct.ZSTD_frameParameters, i32, i32, i64, i32, i32, i32, i32, i64, i32, i32, %struct.ldmParams_t, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ZSTD_customMem, i32, i32, ptr, ptr, i64, i32 }
%struct.ZSTD_compressionParameters = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_frameParameters = type { i32, i32, i32 }
%struct.ldmParams_t = type { i32, i32, i32, i32, i32, i32 }
%struct.inBuff_t = type { %struct.range_t, %struct.buffer_s, i64 }
%struct.range_t = type { ptr, i64 }
%struct.buffer_s = type { ptr, i64 }
%struct.roundBuff_t = type { ptr, i64, i64 }
%struct.serialState_t = type { %union.pthread_mutex_t, %union.pthread_cond_t, %struct.ZSTD_CCtx_params_s, %struct.ldmState_t, %struct.XXH_NAMESPACEXXH64_state_s, i32, %union.pthread_mutex_t, %union.pthread_cond_t, %struct.ZSTD_window_t }
%struct.ldmState_t = type { %struct.ZSTD_window_t, ptr, i32, ptr, [64 x i64], [64 x %struct.ldmMatchCandidate_t] }
%struct.ldmMatchCandidate_t = type { ptr, i32, i32, ptr }
%struct.XXH_NAMESPACEXXH64_state_s = type { i64, [4 x i64], [4 x i64], i32, i32, i64 }
%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 }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.ZSTD_window_t = type { ptr, ptr, ptr, i32, i32, i32 }
%struct.rsyncState_t = type { i64, i64, i64 }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }
%struct.ZSTDMT_jobDescription = type { i64, i64, %union.pthread_mutex_t, %union.pthread_cond_t, ptr, ptr, ptr, ptr, %struct.buffer_s, %struct.range_t, %struct.range_t, i32, i32, i32, %struct.ZSTD_CCtx_params_s, ptr, i64, i64, i32 }

; 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 @pthread_mutex_lock(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ZSTD_isError(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ZSTDMT_getFrameProgression(ptr dead_on_unwind noalias writable sret(%struct.ZSTD_frameProgression) align 8 %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %2
  br label %12

12:                                               ; preds = %11
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %13, i32 0, i32 19
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %16, i32 0, i32 9
  %18 = getelementptr inbounds %struct.inBuff_t, ptr %17, i32 0, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !28
  %20 = add i64 %15, %19
  %21 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 0
  store i64 %20, ptr %21, align 8, !tbaa !29
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %22, i32 0, i32 19
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 1
  store i64 %24, ptr %25, align 8, !tbaa !31
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %26, i32 0, i32 20
  %28 = load i64, ptr %27, align 8, !tbaa !32
  %29 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 3
  store i64 %28, ptr %29, align 8, !tbaa !33
  %30 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 2
  store i64 %28, ptr %30, align 8, !tbaa !34
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %31, i32 0, i32 15
  %33 = load i32, ptr %32, align 8, !tbaa !35
  %34 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 4
  store i32 %33, ptr %34, align 8, !tbaa !36
  %35 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 5
  store i32 0, ptr %35, align 4, !tbaa !37
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %36, i32 0, i32 15
  %38 = load i32, ptr %37, align 8, !tbaa !35
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %39, i32 0, i32 8
  %41 = load i32, ptr %40, align 8, !tbaa !38
  %42 = add i32 %38, %41
  store i32 %42, ptr %5, align 4, !tbaa !39
  br label %43

43:                                               ; preds = %12
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %46, i32 0, i32 14
  %48 = load i32, ptr %47, align 4, !tbaa !40
  store i32 %48, ptr %4, align 4, !tbaa !39
  br label %49

49:                                               ; preds = %130, %45
  %50 = load i32, ptr %4, align 4, !tbaa !39
  %51 = load i32, ptr %5, align 4, !tbaa !39
  %52 = icmp ult i32 %50, %51
  br i1 %52, label %53, label %133

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %54 = load i32, ptr %4, align 4, !tbaa !39
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %55, i32 0, i32 13
  %57 = load i32, ptr %56, align 8, !tbaa !41
  %58 = and i32 %54, %57
  store i32 %58, ptr %6, align 4, !tbaa !39
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !42
  %62 = load i32, ptr %6, align 4, !tbaa !39
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %61, i64 %63
  store ptr %64, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %65, i32 0, i32 2
  %67 = call i32 @pthread_mutex_lock(ptr noundef %66) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %68, i32 0, i32 1
  %70 = load i64, ptr %69, align 8, !tbaa !43
  store i64 %70, ptr %8, align 8, !tbaa !45
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %71 = load i64, ptr %8, align 8, !tbaa !45
  %72 = call i32 @ZSTD_isError(i64 noundef %71)
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %53
  br label %77

75:                                               ; preds = %53
  %76 = load i64, ptr %8, align 8, !tbaa !45
  br label %77

77:                                               ; preds = %75, %74
  %78 = phi i64 [ 0, %74 ], [ %76, %75 ]
  store i64 %78, ptr %9, align 8, !tbaa !45
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %79 = load i64, ptr %8, align 8, !tbaa !45
  %80 = call i32 @ZSTD_isError(i64 noundef %79)
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %77
  br label %87

83:                                               ; preds = %77
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %84, i32 0, i32 17
  %86 = load i64, ptr %85, align 8, !tbaa !46
  br label %87

87:                                               ; preds = %83, %82
  %88 = phi i64 [ 0, %82 ], [ %86, %83 ]
  store i64 %88, ptr %10, align 8, !tbaa !45
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %89, i32 0, i32 10
  %91 = getelementptr inbounds %struct.range_t, ptr %90, i32 0, i32 1
  %92 = load i64, ptr %91, align 8, !tbaa !47
  %93 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 0
  %94 = load i64, ptr %93, align 8, !tbaa !29
  %95 = add i64 %94, %92
  store i64 %95, ptr %93, align 8, !tbaa !29
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %96, i32 0, i32 0
  %98 = load i64, ptr %97, align 8, !tbaa !48
  %99 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 1
  %100 = load i64, ptr %99, align 8, !tbaa !31
  %101 = add i64 %100, %98
  store i64 %101, ptr %99, align 8, !tbaa !31
  %102 = load i64, ptr %9, align 8, !tbaa !45
  %103 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 2
  %104 = load i64, ptr %103, align 8, !tbaa !34
  %105 = add i64 %104, %102
  store i64 %105, ptr %103, align 8, !tbaa !34
  %106 = load i64, ptr %10, align 8, !tbaa !45
  %107 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 3
  %108 = load i64, ptr %107, align 8, !tbaa !33
  %109 = add i64 %108, %106
  store i64 %109, ptr %107, align 8, !tbaa !33
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %110, i32 0, i32 0
  %112 = load i64, ptr %111, align 8, !tbaa !48
  %113 = load ptr, ptr %7, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %113, i32 0, i32 10
  %115 = getelementptr inbounds %struct.range_t, ptr %114, i32 0, i32 1
  %116 = load i64, ptr %115, align 8, !tbaa !47
  %117 = icmp ult i64 %112, %116
  %118 = zext i1 %117 to i32
  %119 = getelementptr inbounds %struct.ZSTD_frameProgression, ptr %0, i32 0, i32 5
  %120 = load i32, ptr %119, align 4, !tbaa !37
  %121 = add i32 %120, %118
  store i32 %121, ptr %119, align 4, !tbaa !37
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %122, i32 0, i32 1
  %124 = load ptr, ptr %123, align 8, !tbaa !42
  %125 = load i32, ptr %6, align 4, !tbaa !39
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %127, i32 0, i32 2
  %129 = call i32 @pthread_mutex_unlock(ptr noundef %128) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %130

130:                                              ; preds = %87
  %131 = load i32, ptr %4, align 4, !tbaa !39
  %132 = add i32 %131, 1
  store i32 %132, ptr %4, align 4, !tbaa !39
  br label %49, !llvm.loop !49

133:                                              ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  ret void
}

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 = { 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, !27, i64 3040}
!10 = !{!"ZSTDMT_CCtx_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !15, i64 256, !15, i64 264, !12, i64 272, !18, i64 280, !21, i64 320, !22, i64 344, !26, i64 2984, !12, i64 3008, !12, i64 3012, !12, i64 3016, !12, i64 3020, !12, i64 3024, !27, i64 3032, !27, i64 3040, !27, i64 3048, !17, i64 3056, !6, i64 3080, !6, i64 3088, !12, i64 3096}
!11 = !{!"ZSTD_CCtx_params_s", !12, i64 0, !13, i64 4, !14, i64 32, !12, i64 44, !12, i64 48, !15, i64 56, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !15, i64 80, !12, i64 88, !12, i64 92, !16, i64 96, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !12, i64 148, !17, i64 152, !12, i64 176, !12, i64 180, !6, i64 184, !6, i64 192, !15, i64 200, !12, i64 208}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24}
!14 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!17 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"", !19, i64 0, !20, i64 16, !15, i64 32}
!19 = !{!"", !6, i64 0, !15, i64 8}
!20 = !{!"buffer_s", !6, i64 0, !15, i64 8}
!21 = !{!"", !6, i64 0, !15, i64 8, !15, i64 16}
!22 = !{!"", !7, i64 0, !7, i64 40, !11, i64 88, !23, i64 304, !25, i64 2416, !12, i64 2504, !7, i64 2512, !7, i64 2552, !24, i64 2600}
!23 = !{!"", !24, i64 0, !6, i64 40, !12, i64 48, !6, i64 56, !7, i64 64, !7, i64 576}
!24 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32}
!25 = !{!"XXH_NAMESPACEXXH64_state_s", !15, i64 0, !7, i64 8, !7, i64 40, !12, i64 72, !12, i64 76, !15, i64 80}
!26 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16}
!27 = !{!"long long", !7, i64 0}
!28 = !{!10, !15, i64 312}
!29 = !{!30, !27, i64 0}
!30 = !{!"", !27, i64 0, !27, i64 8, !27, i64 16, !27, i64 24, !12, i64 32, !12, i64 36}
!31 = !{!30, !27, i64 8}
!32 = !{!10, !27, i64 3048}
!33 = !{!30, !27, i64 24}
!34 = !{!30, !27, i64 16}
!35 = !{!10, !12, i64 3016}
!36 = !{!30, !12, i64 32}
!37 = !{!30, !12, i64 36}
!38 = !{!10, !12, i64 272}
!39 = !{!12, !12, i64 0}
!40 = !{!10, !12, i64 3012}
!41 = !{!10, !12, i64 3008}
!42 = !{!10, !6, i64 8}
!43 = !{!44, !15, i64 8}
!44 = !{!"", !15, i64 0, !15, i64 8, !7, i64 16, !7, i64 56, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !20, i64 136, !19, i64 152, !19, i64 168, !12, i64 184, !12, i64 188, !12, i64 192, !11, i64 200, !6, i64 416, !27, i64 424, !15, i64 432, !12, i64 440}
!45 = !{!15, !15, i64 0}
!46 = !{!44, !15, i64 432}
!47 = !{!44, !15, i64 176}
!48 = !{!44, !15, i64 0}
!49 = distinct !{!49, !50}
!50 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.ZSTD_frameProgression = type { i64, i64, i64, i64, i32, i32 }
%struct.ZSTDMT_jobDescription = type { i64, i64, %union.pthread_mutex_t, %union.pthread_cond_t, ptr, ptr, ptr, ptr, %struct.buffer_s, %struct.range_t, %struct.range_t, i32, i32, i32, %struct.ZSTD_CCtx_params_s, ptr, i64, i64, 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 }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.buffer_s = type { ptr, i64 }
%struct.range_t = type { ptr, i64 }
%struct.ZSTD_CCtx_params_s = type { i32, %struct.ZSTD_compressionParameters, %struct.ZSTD_frameParameters, i32, i32, i64, i32, i32, i32, i32, i64, i32, i32, %struct.ldmParams_t, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ZSTD_customMem, i32, i32, ptr, ptr, i64, i32 }
%struct.ZSTD_compressionParameters = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_frameParameters = type { i32, i32, i32 }
%struct.ldmParams_t = type { i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @ZSTD_isError(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @ZSTDMT_getFrameProgression(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.ZSTD_frameProgression) align 8 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 3040
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 312
  %6 = load i64, ptr %5, align 8, !tbaa !27
  %7 = add i64 %6, %4
  %8 = getelementptr inbounds i8, ptr %1, i64 3048
  %9 = load i64, ptr %8, align 8, !tbaa !28
  %10 = getelementptr inbounds i8, ptr %1, i64 3016
  %11 = load i32, ptr %10, align 8, !tbaa !29
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %11, ptr %12, align 8, !tbaa !30
  %13 = getelementptr inbounds i8, ptr %1, i64 272
  %14 = load i32, ptr %13, align 8, !tbaa !32
  %15 = add i32 %14, %11
  %16 = getelementptr inbounds i8, ptr %1, i64 3012
  %17 = load i32, ptr %16, align 4, !tbaa !33
  %18 = icmp ult i32 %17, %15
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %19 = getelementptr inbounds i8, ptr %1, i64 3008
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  br label %21

21:                                               ; preds = %.lr.ph, %42
  %.037 = phi i32 [ %17, %.lr.ph ], [ %57, %42 ]
  %22 = phi i64 [ %7, %.lr.ph ], [ %46, %42 ]
  %23 = phi i64 [ %4, %.lr.ph ], [ %48, %42 ]
  %24 = phi i64 [ %9, %.lr.ph ], [ %49, %42 ]
  %25 = phi i64 [ %9, %.lr.ph ], [ %50, %42 ]
  %26 = phi i32 [ 0, %.lr.ph ], [ %53, %42 ]
  %27 = load i32, ptr %19, align 8, !tbaa !34
  %28 = and i32 %27, %.037
  %29 = load ptr, ptr %20, align 8, !tbaa !35
  %30 = zext i32 %28 to i64
  %31 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %29, i64 %30
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %33 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %32) #2
  %34 = getelementptr inbounds i8, ptr %31, i64 8
  %35 = load i64, ptr %34, align 8, !tbaa !36
  %36 = tail call i32 @ZSTD_isError(i64 noundef %35)
  %.not = icmp eq i32 %36, 0
  %37 = select i1 %.not, i64 %35, i64 0
  %38 = tail call i32 @ZSTD_isError(i64 noundef %35)
  %.not28 = icmp eq i32 %38, 0
  br i1 %.not28, label %39, label %42

39:                                               ; preds = %21
  %40 = getelementptr inbounds i8, ptr %31, i64 432
  %41 = load i64, ptr %40, align 8, !tbaa !38
  br label %42

42:                                               ; preds = %21, %39
  %43 = phi i64 [ %41, %39 ], [ 0, %21 ]
  %44 = getelementptr inbounds i8, ptr %31, i64 176
  %45 = load i64, ptr %44, align 8, !tbaa !39
  %46 = add i64 %22, %45
  %47 = load i64, ptr %31, align 8, !tbaa !40
  %48 = add i64 %23, %47
  %49 = add i64 %24, %37
  %50 = add i64 %25, %43
  %51 = icmp ult i64 %47, %45
  %52 = zext i1 %51 to i32
  %53 = add i32 %26, %52
  %54 = load ptr, ptr %20, align 8, !tbaa !35
  %55 = getelementptr inbounds %struct.ZSTDMT_jobDescription, ptr %54, i64 %30, i32 2
  %56 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %55) #2
  %57 = add i32 %.037, 1
  %exitcond.not = icmp eq i32 %57, %15
  br i1 %exitcond.not, label %._crit_edge, label %21, !llvm.loop !41

._crit_edge:                                      ; preds = %42, %2
  %.lcssa36 = phi i32 [ 0, %2 ], [ %53, %42 ]
  %.lcssa34 = phi i64 [ %9, %2 ], [ %50, %42 ]
  %.lcssa32 = phi i64 [ %9, %2 ], [ %49, %42 ]
  %.lcssa30 = phi i64 [ %4, %2 ], [ %48, %42 ]
  %.lcssa = phi i64 [ %7, %2 ], [ %46, %42 ]
  %58 = getelementptr inbounds i8, ptr %0, i64 36
  %59 = getelementptr inbounds i8, ptr %0, i64 16
  %60 = getelementptr inbounds i8, ptr %0, i64 24
  %61 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %.lcssa, ptr %0, align 8, !tbaa !43
  store i64 %.lcssa30, ptr %61, align 8, !tbaa !44
  store i64 %.lcssa32, ptr %59, align 8, !tbaa !45
  store i64 %.lcssa34, ptr %60, align 8, !tbaa !46
  store i32 %.lcssa36, ptr %58, align 4, !tbaa !47
  ret void
}

attributes #0 = { 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 = { 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 = { 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, !26, i64 3040}
!6 = !{!"ZSTDMT_CCtx_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !14, i64 256, !14, i64 264, !11, i64 272, !17, i64 280, !20, i64 320, !21, i64 344, !25, i64 2984, !11, i64 3008, !11, i64 3012, !11, i64 3016, !11, i64 3020, !11, i64 3024, !26, i64 3032, !26, i64 3040, !26, i64 3048, !16, i64 3056, !7, i64 3080, !7, i64 3088, !11, i64 3096}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"ZSTD_CCtx_params_s", !11, i64 0, !12, i64 4, !13, i64 32, !11, i64 44, !11, i64 48, !14, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !14, i64 80, !11, i64 88, !11, i64 92, !15, i64 96, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !16, i64 152, !11, i64 176, !11, i64 180, !7, i64 184, !7, i64 192, !14, i64 200, !11, i64 208}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!14 = !{!"long", !8, i64 0}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!16 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!17 = !{!"", !18, i64 0, !19, i64 16, !14, i64 32}
!18 = !{!"", !7, i64 0, !14, i64 8}
!19 = !{!"buffer_s", !7, i64 0, !14, i64 8}
!20 = !{!"", !7, i64 0, !14, i64 8, !14, i64 16}
!21 = !{!"", !8, i64 0, !8, i64 40, !10, i64 88, !22, i64 304, !24, i64 2416, !11, i64 2504, !8, i64 2512, !8, i64 2552, !23, i64 2600}
!22 = !{!"", !23, i64 0, !7, i64 40, !11, i64 48, !7, i64 56, !8, i64 64, !8, i64 576}
!23 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !11, i64 24, !11, i64 28, !11, i64 32}
!24 = !{!"XXH_NAMESPACEXXH64_state_s", !14, i64 0, !8, i64 8, !8, i64 40, !11, i64 72, !11, i64 76, !14, i64 80}
!25 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16}
!26 = !{!"long long", !8, i64 0}
!27 = !{!6, !14, i64 312}
!28 = !{!6, !26, i64 3048}
!29 = !{!6, !11, i64 3016}
!30 = !{!31, !11, i64 32}
!31 = !{!"", !26, i64 0, !26, i64 8, !26, i64 16, !26, i64 24, !11, i64 32, !11, i64 36}
!32 = !{!6, !11, i64 272}
!33 = !{!6, !11, i64 3012}
!34 = !{!6, !11, i64 3008}
!35 = !{!6, !7, i64 8}
!36 = !{!37, !14, i64 8}
!37 = !{!"", !14, i64 0, !14, i64 8, !8, i64 16, !8, i64 56, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !19, i64 136, !18, i64 152, !18, i64 168, !11, i64 184, !11, i64 188, !11, i64 192, !10, i64 200, !7, i64 416, !26, i64 424, !14, i64 432, !11, i64 440}
!38 = !{!37, !14, i64 432}
!39 = !{!37, !14, i64 176}
!40 = !{!37, !14, i64 0}
!41 = distinct !{!41, !42}
!42 = !{!"llvm.loop.mustprogress"}
!43 = !{!31, !26, i64 0}
!44 = !{!31, !26, i64 8}
!45 = !{!31, !26, i64 16}
!46 = !{!31, !26, i64 24}
!47 = !{!31, !11, i64 36}


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