; LLVM IR from AdrianWR/push_swap :: src/checker (get_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"

; Function Attrs: nounwind uwtable
define dso_local i32 @get_instructions(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [4096 x ptr], align 16
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 32768, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %34, %1
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %13, label %10

10:                                               ; preds = %7
  %11 = call i32 @get_next_line(i32 noundef 0, ptr noundef %6)
  %12 = icmp sgt i32 %11, 0
  br label %13

13:                                               ; preds = %10, %7
  %14 = phi i1 [ false, %7 ], [ %12, %10 ]
  br i1 %14, label %15, label %35

15:                                               ; preds = %13
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call zeroext i1 @invalid_instruction(ptr noundef %16)
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %34

19:                                               ; preds = %15
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %3, align 4, !tbaa !9
  %23 = sext i32 %21 to i64
  %24 = getelementptr inbounds [4096 x ptr], ptr %5, i64 0, i64 %23
  store ptr %20, ptr %24, align 8, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 4096
  br i1 %26, label %27, label %33

27:                                               ; preds = %19
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds [4096 x ptr], ptr %5, i64 0, i64 0
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = call i32 @heap_set(ptr noundef %28, ptr noundef %29, i32 noundef %30)
  %32 = getelementptr inbounds [4096 x ptr], ptr %5, i64 0, i64 0
  call void @ft_bzero(ptr noundef %32, i64 noundef 4096)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %27, %19
  br label %34

34:                                               ; preds = %33, %18
  br label %7, !llvm.loop !11

35:                                               ; preds = %13
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds [4096 x ptr], ptr %5, i64 0, i64 0
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = call i32 @heap_set(ptr noundef %36, ptr noundef %37, i32 noundef %38)
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %40) #4
  %41 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 32768, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %41
}

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

declare i32 @get_next_line(i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @invalid_instruction(ptr noundef) #0

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

declare void @ft_bzero(ptr noundef, i64 noundef) #2

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

; 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 = { "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 "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 }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @get_instructions(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca [4096 x ptr], align 16
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %4 = call i32 @get_next_line(i32 noundef 0, ptr noundef nonnull %3) #4
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %1, %16
  %.071115 = phi i32 [ %.18, %16 ], [ 0, %1 ]
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call zeroext i1 @invalid_instruction(ptr noundef %6)
  br i1 %7, label %.critedge, label %8

8:                                                ; preds = %.lr.ph
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = add nsw i32 %.071115, 1
  %11 = sext i32 %.071115 to i64
  %12 = getelementptr inbounds [4096 x ptr], ptr %2, i64 0, i64 %11
  store ptr %9, ptr %12, align 8, !tbaa !5
  %13 = icmp eq i32 %10, 4096
  br i1 %13, label %14, label %16

14:                                               ; preds = %8
  %15 = call i32 @heap_set(ptr noundef %0, ptr noundef nonnull %2, i32 noundef 4096)
  call void @ft_bzero(ptr noundef nonnull %2, i64 noundef 4096) #4
  br label %16

16:                                               ; preds = %8, %14
  %.18 = phi i32 [ 0, %14 ], [ %10, %8 ]
  %17 = call i32 @get_next_line(i32 noundef 0, ptr noundef nonnull %3) #4
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %.critedge

.critedge:                                        ; preds = %16, %.lr.ph, %1
  %.0711.lcssa = phi i32 [ 0, %1 ], [ %.18, %16 ], [ %.071115, %.lr.ph ]
  %.0.lcssa = phi i32 [ 0, %1 ], [ 0, %16 ], [ 1, %.lr.ph ]
  %19 = call i32 @heap_set(ptr noundef %0, ptr noundef nonnull %2, i32 noundef %.0711.lcssa)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %2) #4
  ret i32 %.0.lcssa
}

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

declare i32 @get_next_line(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @invalid_instruction(ptr noundef) local_unnamed_addr #0

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

declare void @ft_bzero(ptr noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 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 #4 = { 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass