; LLVM IR from jermp/2i_bench :: external/CRoaring/benchmarks (create_ds2i_format)

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

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 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 uwtable
declare dso_local void @write_to_file(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @create_ds2i_format(i64 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %20 = load ptr, ptr %10, align 8, !tbaa !11
  %21 = call i64 @strlen(ptr noundef %20) #8
  %22 = add i64 %21, 5
  %23 = add i64 %22, 1
  %24 = call noalias ptr @malloc(i64 noundef %23) #9
  store ptr %24, ptr %11, align 8, !tbaa !11
  %25 = load ptr, ptr %11, align 8, !tbaa !11
  %26 = load ptr, ptr %10, align 8, !tbaa !11
  %27 = call ptr @strcpy(ptr noundef %25, ptr noundef %26) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %28 = load ptr, ptr %11, align 8, !tbaa !11
  %29 = call ptr @strcat(ptr noundef %28, ptr noundef @.str) #7
  %30 = call noalias ptr @fopen(ptr noundef %29, ptr noundef @.str.1)
  store ptr %30, ptr %12, align 8, !tbaa !11
  %31 = load ptr, ptr %12, align 8, !tbaa !11
  %32 = icmp ne ptr %31, null
  br i1 %32, label %35, label %33

33:                                               ; preds = %5
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #10
  unreachable

35:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %36 = load ptr, ptr %10, align 8, !tbaa !11
  %37 = call i64 @strlen(ptr noundef %36) #8
  %38 = add i64 %37, 6
  %39 = add i64 %38, 1
  %40 = call noalias ptr @malloc(i64 noundef %39) #9
  store ptr %40, ptr %13, align 8, !tbaa !11
  %41 = load ptr, ptr %13, align 8, !tbaa !11
  %42 = load ptr, ptr %10, align 8, !tbaa !11
  %43 = call ptr @strcpy(ptr noundef %41, ptr noundef %42) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %44 = load ptr, ptr %13, align 8, !tbaa !11
  %45 = call ptr @strcat(ptr noundef %44, ptr noundef @.str.3) #7
  %46 = call noalias ptr @fopen(ptr noundef %45, ptr noundef @.str.1)
  store ptr %46, ptr %14, align 8, !tbaa !11
  %47 = load ptr, ptr %14, align 8, !tbaa !11
  %48 = icmp ne ptr %47, null
  br i1 %48, label %51, label %49

49:                                               ; preds = %35
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #10
  unreachable

51:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !9
  %52 = load ptr, ptr %12, align 8, !tbaa !11
  %53 = load i32, ptr %15, align 4, !tbaa !9
  call void @write_to_file(ptr noundef %52, i32 noundef %53)
  %54 = load ptr, ptr %12, align 8, !tbaa !11
  %55 = load i32, ptr %7, align 4, !tbaa !9
  call void @write_to_file(ptr noundef %54, i32 noundef %55)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store i64 0, ptr %16, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %92, %51
  %57 = load i64, ptr %16, align 8, !tbaa !5
  %58 = load i64, ptr %6, align 8, !tbaa !5
  %59 = icmp ne i64 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %95

61:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %62 = load ptr, ptr %8, align 8, !tbaa !11
  %63 = load i64, ptr %16, align 8, !tbaa !5
  %64 = getelementptr inbounds i64, ptr %62, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !5
  %66 = trunc i64 %65 to i32
  store i32 %66, ptr %18, align 4, !tbaa !9
  %67 = load ptr, ptr %12, align 8, !tbaa !11
  %68 = load i32, ptr %18, align 4, !tbaa !9
  call void @write_to_file(ptr noundef %67, i32 noundef %68)
  %69 = load ptr, ptr %14, align 8, !tbaa !11
  %70 = load i32, ptr %18, align 4, !tbaa !9
  call void @write_to_file(ptr noundef %69, i32 noundef %70)
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  store i64 0, ptr %19, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %88, %61
  %72 = load i64, ptr %19, align 8, !tbaa !5
  %73 = load i32, ptr %18, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = icmp ne i64 %72, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %71
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %91

77:                                               ; preds = %71
  %78 = load ptr, ptr %12, align 8, !tbaa !11
  %79 = load ptr, ptr %9, align 8, !tbaa !11
  %80 = load i64, ptr %16, align 8, !tbaa !5
  %81 = getelementptr inbounds ptr, ptr %79, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = load i64, ptr %19, align 8, !tbaa !5
  %84 = getelementptr inbounds i32, ptr %82, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !9
  call void @write_to_file(ptr noundef %78, i32 noundef %85)
  %86 = load ptr, ptr %14, align 8, !tbaa !11
  %87 = load i32, ptr %15, align 4, !tbaa !9
  call void @write_to_file(ptr noundef %86, i32 noundef %87)
  br label %88

88:                                               ; preds = %77
  %89 = load i64, ptr %19, align 8, !tbaa !5
  %90 = add i64 %89, 1
  store i64 %90, ptr %19, align 8, !tbaa !5
  br label %71, !llvm.loop !13

91:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %92

92:                                               ; preds = %91
  %93 = load i64, ptr %16, align 8, !tbaa !5
  %94 = add i64 %93, 1
  store i64 %94, ptr %16, align 8, !tbaa !5
  br label %56, !llvm.loop !15

95:                                               ; preds = %60
  %96 = load ptr, ptr %12, align 8, !tbaa !11
  %97 = call i32 @fclose(ptr noundef %96)
  %98 = load ptr, ptr %14, align 8, !tbaa !11
  %99 = call i32 @fclose(ptr noundef %98)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #4

declare noalias ptr @fopen(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #4

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #6

declare i32 @fclose(ptr noundef) #5

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 = { nounwind allocsize(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 willreturn memory(read) "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 = { "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 = { noreturn 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { noreturn 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @create_ds2i_format(i64 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #6
  %7 = add i64 %6, 6
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #7
  %9 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %4) #8
  %10 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str) #8
  %11 = tail call noalias ptr @fopen(ptr noundef %8, ptr noundef nonnull @.str.1)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %12, label %14

12:                                               ; preds = %5
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #9
  unreachable

14:                                               ; preds = %5
  %15 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #6
  %16 = add i64 %15, 7
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #7
  %18 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %17, ptr noundef nonnull dereferenceable(1) %4) #8
  %19 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %17, ptr noundef nonnull dereferenceable(1) @.str.3) #8
  %20 = tail call noalias ptr @fopen(ptr noundef %17, ptr noundef nonnull @.str.1)
  %.not36 = icmp eq ptr %20, null
  br i1 %.not36, label %21, label %23

21:                                               ; preds = %14
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #9
  unreachable

23:                                               ; preds = %14
  tail call void @write_to_file(ptr noundef nonnull %11, i32 noundef 1)
  tail call void @write_to_file(ptr noundef nonnull %11, i32 noundef %1)
  %.not3741 = icmp eq i64 %0, 0
  br i1 %.not3741, label %._crit_edge45, label %.lr.ph44

._crit_edge45:                                    ; preds = %._crit_edge, %23
  %24 = tail call i32 @fclose(ptr noundef nonnull %11)
  %25 = tail call i32 @fclose(ptr noundef nonnull %20)
  ret void

.lr.ph44:                                         ; preds = %23, %._crit_edge
  %.03342 = phi i64 [ %31, %._crit_edge ], [ 0, %23 ]
  %26 = getelementptr inbounds i64, ptr %2, i64 %.03342
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = trunc i64 %27 to i32
  tail call void @write_to_file(ptr noundef nonnull %11, i32 noundef %28)
  tail call void @write_to_file(ptr noundef nonnull %20, i32 noundef %28)
  %29 = and i64 %27, 4294967295
  %.not3839 = icmp eq i64 %29, 0
  br i1 %.not3839, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph44
  %30 = getelementptr inbounds ptr, ptr %3, i64 %.03342
  br label %32

._crit_edge:                                      ; preds = %32, %.lr.ph44
  %31 = add nuw i64 %.03342, 1
  %.not37 = icmp eq i64 %31, %0
  br i1 %.not37, label %._crit_edge45, label %.lr.ph44, !llvm.loop !9

32:                                               ; preds = %.lr.ph, %32
  %.040 = phi i64 [ 0, %.lr.ph ], [ %36, %32 ]
  %33 = load ptr, ptr %30, align 8, !tbaa !11
  %34 = getelementptr inbounds i32, ptr %33, i64 %.040
  %35 = load i32, ptr %34, align 4, !tbaa !13
  tail call void @write_to_file(ptr noundef nonnull %11, i32 noundef %35)
  tail call void @write_to_file(ptr noundef nonnull %20, i32 noundef 1)
  %36 = add nuw nsw i64 %.040, 1
  %.not38 = icmp eq i64 %36, %29
  br i1 %.not38, label %._crit_edge, label %32, !llvm.loop !15
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 nofree nounwind willreturn memory(argmem: readwrite) "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 = { 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 #5 = { noreturn 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 #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { noreturn 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !10}


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