; LLVM IR from nde-jesu/Doom_Nukem :: libft/srcs/file (ft_get_next_line)

; 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.s_gnlist = type { i32, ptr, ptr, ptr }

@ft_get_next_line.cyclehit = external hidden global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ft_get_next_line(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  %9 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  store ptr %9, ptr %7, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %29, %2
  %11 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %27

13:                                               ; preds = %10
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %20

16:                                               ; preds = %13
  %17 = load ptr, ptr %7, align 8, !tbaa !9
  %18 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %19 = icmp ne ptr %17, %18
  br i1 %19, label %20, label %27

20:                                               ; preds = %16, %13
  %21 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.s_gnlist, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp ne i32 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %20
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %26, %20, %16, %10
  %28 = phi i1 [ false, %20 ], [ false, %16 ], [ false, %10 ], [ true, %26 ]
  br i1 %28, label %29, label %33

29:                                               ; preds = %27
  %30 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.s_gnlist, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  store ptr %32, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  br label %10, !llvm.loop !14

33:                                               ; preds = %27
  %34 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %42

36:                                               ; preds = %33
  %37 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.s_gnlist, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = icmp ne i32 %39, %40
  br i1 %41, label %42, label %85

42:                                               ; preds = %36, %33
  %43 = call noalias ptr @malloc(i64 noundef 32) #4
  store ptr %43, ptr %7, align 8, !tbaa !9
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %97

46:                                               ; preds = %42
  %47 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %53

49:                                               ; preds = %46
  %50 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.s_gnlist, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  br label %55

53:                                               ; preds = %46
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %53, %49
  %56 = phi ptr [ %52, %49 ], [ %54, %53 ]
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.s_gnlist, ptr %57, i32 0, i32 2
  store ptr %56, ptr %58, align 8, !tbaa !13
  %59 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %63

61:                                               ; preds = %55
  %62 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  br label %65

63:                                               ; preds = %55
  %64 = load ptr, ptr %7, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %63, %61
  %66 = phi ptr [ %62, %61 ], [ %64, %63 ]
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.s_gnlist, ptr %67, i32 0, i32 3
  store ptr %66, ptr %68, align 8, !tbaa !16
  %69 = load ptr, ptr %7, align 8, !tbaa !9
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.s_gnlist, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = getelementptr inbounds %struct.s_gnlist, ptr %72, i32 0, i32 3
  store ptr %69, ptr %73, align 8, !tbaa !16
  %74 = load ptr, ptr %7, align 8, !tbaa !9
  %75 = load ptr, ptr %7, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.s_gnlist, ptr %75, i32 0, i32 3
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %78 = getelementptr inbounds %struct.s_gnlist, ptr %77, i32 0, i32 2
  store ptr %74, ptr %78, align 8, !tbaa !13
  %79 = load ptr, ptr %7, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.s_gnlist, ptr %79, i32 0, i32 1
  store ptr null, ptr %80, align 8, !tbaa !17
  %81 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %81, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.s_gnlist, ptr %83, i32 0, i32 0
  store i32 %82, ptr %84, align 8, !tbaa !11
  br label %85

85:                                               ; preds = %65, %36
  %86 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.s_gnlist, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !11
  %89 = load ptr, ptr %5, align 8, !tbaa !9
  %90 = load ptr, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.s_gnlist, ptr %90, i32 0, i32 1
  %92 = call i32 @ft_fd_line(i32 noundef %88, ptr noundef %89, ptr noundef %91)
  store i32 %92, ptr %6, align 4, !tbaa !5
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %85
  call void @ft_gnlist_del(ptr noundef @ft_get_next_line.cyclehit)
  br label %95

95:                                               ; preds = %94, %85
  %96 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %96, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %97

97:                                               ; preds = %95, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %98 = load i32, ptr %3, align 4
  ret i32 %98
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @ft_fd_line(i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @ft_gnlist_del(ptr noundef) #0

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

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"s_gnlist", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!12, !10, i64 24}
!17 = !{!12, !10, i64 8}


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

@ft_get_next_line.cyclehit = external hidden global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ft_get_next_line(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr @ft_get_next_line.cyclehit, align 8
  %.not33 = icmp eq ptr %3, null
  br i1 %.not33, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not24.peel = icmp eq i32 %4, %0
  br i1 %.not24.peel, label %.loopexit, label %5

5:                                                ; preds = %.lr.ph.preheader
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  store ptr %7, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !12
  %.not.peel = icmp eq ptr %7, null
  br i1 %.not.peel, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %11
  %8 = phi ptr [ %13, %11 ], [ %7, %5 ]
  %.not23 = icmp eq ptr %3, %8
  br i1 %.not23, label %.loopexit, label %9

9:                                                ; preds = %.lr.ph
  %10 = load i32, ptr %8, align 8, !tbaa !5
  %.not24 = icmp eq i32 %10, %0
  br i1 %.not24, label %.loopexit, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %8, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  store ptr %13, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !12
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph, %9, %.lr.ph.preheader
  %.lcssa = phi ptr [ %3, %.lr.ph.preheader ], [ %8, %9 ], [ %8, %.lr.ph ]
  %14 = load i32, ptr %.lcssa, align 8, !tbaa !5
  %.not26 = icmp eq i32 %14, %0
  br i1 %.not26, label %._crit_edge, label %.critedge.thread30

._crit_edge:                                      ; preds = %.loopexit
  %.pre = load i32, ptr %.lcssa, align 8, !tbaa !5
  br label %30

.critedge:                                        ; preds = %11, %5, %2
  %15 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #2
  %.not27 = icmp eq ptr %15, null
  br i1 %.not27, label %37, label %20

.critedge.thread30:                               ; preds = %.loopexit
  %16 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #2
  %.not2731 = icmp eq ptr %16, null
  br i1 %.not2731, label %37, label %17

17:                                               ; preds = %.critedge.thread30
  %18 = getelementptr inbounds i8, ptr %.lcssa, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %.critedge, %17
  %21 = phi ptr [ %.lcssa, %17 ], [ %15, %.critedge ]
  %22 = phi ptr [ %16, %17 ], [ %15, %.critedge ]
  %23 = phi ptr [ %19, %17 ], [ %15, %.critedge ]
  %24 = getelementptr inbounds i8, ptr %22, i64 16
  store ptr %23, ptr %24, align 8, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %22, i64 24
  store ptr %21, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %23, i64 24
  store ptr %22, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %25, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  store ptr %22, ptr %28, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %22, i64 8
  store ptr null, ptr %29, align 8, !tbaa !17
  store ptr %22, ptr @ft_get_next_line.cyclehit, align 8, !tbaa !12
  store i32 %0, ptr %22, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %._crit_edge, %20
  %31 = phi i32 [ %0, %20 ], [ %.pre, %._crit_edge ]
  %32 = phi ptr [ %22, %20 ], [ %.lcssa, %._crit_edge ]
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  %34 = tail call i32 @ft_fd_line(i32 noundef %31, ptr noundef %1, ptr noundef nonnull %33)
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  tail call void @ft_gnlist_del(ptr noundef nonnull @ft_get_next_line.cyclehit)
  br label %37

37:                                               ; preds = %.critedge.thread30, %30, %36, %.critedge
  %.017 = phi i32 [ -1, %.critedge ], [ 0, %36 ], [ %34, %30 ], [ -1, %.critedge.thread30 ]
  ret i32 %.017
}

; 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: nounwind uwtable
declare hidden i32 @ft_fd_line(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @ft_gnlist_del(ptr noundef) local_unnamed_addr #0

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 = { nounwind allocsize(0) }

!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 0}
!6 = !{!"s_gnlist", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14, !15}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.peeled.count", i32 1}
!16 = !{!6, !10, i64 24}
!17 = !{!6, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass