; LLVM IR from yellow-footed-honeyguide/facad :: src (git_utils)

; 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.GitFileList = type { [1000 x %struct.GitFile], i32 }
%struct.GitFile = type { [1024 x i8], i8 }

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 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

declare noalias ptr @popen(ptr noundef, ptr noundef) #1

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #1

declare i32 @pclose(ptr noundef) #1

; 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
define dso_local void @get_git_status(ptr dead_on_unwind noalias writable sret(%struct.GitFileList) align 4 %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca [1027 x i8], align 16
  %5 = alloca %struct.GitFile, align 1
  call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 1025004, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  %6 = call noalias ptr @popen(ptr noundef @.str.3, ptr noundef @.str.1)
  store ptr %6, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i32 1, ptr %3, align 4
  br label %50

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1027, ptr %4) #7
  br label %11

11:                                               ; preds = %46, %10
  %12 = getelementptr inbounds [1027 x i8], ptr %4, i64 0, i64 0
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call ptr @fgets(ptr noundef %12, i32 noundef 1027, ptr noundef %13)
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %20

16:                                               ; preds = %11
  %17 = getelementptr inbounds %struct.GitFileList, ptr %0, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp slt i32 %18, 1000
  br label %20

20:                                               ; preds = %16, %11
  %21 = phi i1 [ false, %11 ], [ %19, %16 ]
  br i1 %21, label %22, label %47

22:                                               ; preds = %20
  %23 = getelementptr inbounds [1027 x i8], ptr %4, i64 0, i64 0
  %24 = call i64 @strlen(ptr noundef %23) #8
  %25 = icmp ugt i64 %24, 3
  br i1 %25, label %26, label %46

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1025, ptr %5) #7
  %27 = getelementptr inbounds [1027 x i8], ptr %4, i64 0, i64 0
  %28 = call signext i8 @parse_status(ptr noundef %27)
  %29 = getelementptr inbounds %struct.GitFile, ptr %5, i32 0, i32 1
  store i8 %28, ptr %29, align 1, !tbaa !12
  %30 = getelementptr inbounds %struct.GitFile, ptr %5, i32 0, i32 0
  %31 = getelementptr inbounds [1024 x i8], ptr %30, i64 0, i64 0
  %32 = getelementptr inbounds [1027 x i8], ptr %4, i64 0, i64 0
  %33 = getelementptr inbounds i8, ptr %32, i64 3
  %34 = call ptr @strncpy(ptr noundef %31, ptr noundef %33, i64 noundef 1023) #7
  %35 = getelementptr inbounds %struct.GitFile, ptr %5, i32 0, i32 0
  %36 = getelementptr inbounds %struct.GitFile, ptr %5, i32 0, i32 0
  %37 = getelementptr inbounds [1024 x i8], ptr %36, i64 0, i64 0
  %38 = call i64 @strcspn(ptr noundef %37, ptr noundef @.str.4) #8
  %39 = getelementptr inbounds [1024 x i8], ptr %35, i64 0, i64 %38
  store i8 0, ptr %39, align 1, !tbaa !14
  %40 = getelementptr inbounds %struct.GitFileList, ptr %0, i32 0, i32 0
  %41 = getelementptr inbounds %struct.GitFileList, ptr %0, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %41, align 4, !tbaa !9
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds [1000 x %struct.GitFile], ptr %40, i64 0, i64 %44
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %45, ptr align 1 %5, i64 1025, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 1025, ptr %5) #7
  br label %46

46:                                               ; preds = %26, %22
  br label %11, !llvm.loop !16

47:                                               ; preds = %20
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = call i32 @pclose(ptr noundef %48)
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 1027, ptr %4) #7
  br label %50

50:                                               ; preds = %47, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @parse_status(ptr noundef) #2

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #5

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strcspn(ptr noundef, ptr noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #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: write) }
attributes #4 = { 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 #5 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }

!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 1025000}
!10 = !{!"", !7, i64 0, !11, i64 1025000}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !7, i64 1024}
!13 = !{!"", !7, i64 0, !7, i64 1024}
!14 = !{!7, !7, i64 0}
!15 = !{i64 0, i64 1024, !14, i64 1024, i64 1, !14}
!16 = distinct !{!16, !17}
!17 = !{!"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.GitFileList = type { [1000 x %struct.GitFile], i32 }
%struct.GitFile = type { [1024 x i8], i8 }

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #1

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

; 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
define dso_local void @get_git_status(ptr dead_on_unwind noalias nocapture writable sret(%struct.GitFileList) align 4 %0) local_unnamed_addr #2 {
  %2 = alloca [1027 x i8], align 16
  %3 = alloca %struct.GitFile, align 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1025004) %0, i8 0, i64 1025004, i1 false)
  %4 = tail call noalias ptr @popen(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %30, label %6

6:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1027, ptr nonnull %2) #7
  %7 = call ptr @fgets(ptr noundef nonnull %2, i32 noundef 1027, ptr noundef nonnull %4)
  %.not = icmp eq ptr %7, null
  %8 = getelementptr inbounds i8, ptr %0, i64 1025000
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %9 = getelementptr inbounds i8, ptr %3, i64 1024
  %10 = getelementptr inbounds i8, ptr %2, i64 3
  br label %11

11:                                               ; preds = %.lr.ph, %23
  %12 = phi i32 [ 0, %.lr.ph ], [ %24, %23 ]
  %13 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #8
  %14 = icmp ugt i64 %13, 3
  br i1 %14, label %15, label %23

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1025, ptr nonnull %3) #7
  %16 = call signext i8 @parse_status(ptr noundef nonnull %2)
  store i8 %16, ptr %9, align 1, !tbaa !5
  %17 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %10, i64 noundef 1023) #7
  %18 = call i64 @strcspn(ptr noundef nonnull %3, ptr noundef nonnull @.str.4) #8
  %19 = getelementptr inbounds [1024 x i8], ptr %3, i64 0, i64 %18
  store i8 0, ptr %19, align 1, !tbaa !9
  %20 = add nsw i32 %12, 1
  store i32 %20, ptr %8, align 4, !tbaa !10
  %21 = sext i32 %12 to i64
  %22 = getelementptr inbounds [1000 x %struct.GitFile], ptr %0, i64 0, i64 %21
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1025) %22, ptr noundef nonnull align 1 dereferenceable(1025) %3, i64 1025, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 1025, ptr nonnull %3) #7
  %.pre = load i32, ptr %8, align 4
  br label %23

23:                                               ; preds = %15, %11
  %24 = phi i32 [ %.pre, %15 ], [ %12, %11 ]
  %25 = call ptr @fgets(ptr noundef nonnull %2, i32 noundef 1027, ptr noundef nonnull %4)
  %26 = icmp ne ptr %25, null
  %27 = icmp slt i32 %24, 1000
  %28 = select i1 %26, i1 %27, i1 false
  br i1 %28, label %11, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %23, %6
  %29 = call i32 @pclose(ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 1027, ptr nonnull %2) #7
  br label %30

30:                                               ; preds = %1, %._crit_edge
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @parse_status(ptr noundef) local_unnamed_addr #2

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 1024}
!6 = !{!"", !7, i64 0, !7, i64 1024}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 1025000}
!11 = !{!"", !7, i64 0, !12, i64 1025000}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 1024, !9, i64 1024, i64 1, !9}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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