; LLVM IR from rociodellasala/TP3_SO :: Userland/linearGraph (linearGraph)

; 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
declare dso_local void @coordinates() #0

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

declare void @draw_pixel(i32 noundef, i32 noundef) #2

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

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

11:                                               ; preds = %2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %19, %11
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 1024
  br i1 %14, label %15, label %22

15:                                               ; preds = %12
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sub nsw i32 384, %17
  call void @draw_pixel(i32 noundef %16, i32 noundef %18)
  br label %19

19:                                               ; preds = %15
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %7, align 4, !tbaa !5
  br label %12, !llvm.loop !9

22:                                               ; preds = %12
  br label %43

23:                                               ; preds = %2
  store i32 -384, ptr %7, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %39, %23
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 896
  br i1 %26, label %27, label %42

27:                                               ; preds = %24
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = mul nsw i32 %28, %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %30, %31
  store i32 %32, ptr %8, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = add nsw i32 %33, 512
  store i32 %34, ptr %5, align 4, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = sub nsw i32 384, %35
  store i32 %36, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !5
  call void @draw_pixel(i32 noundef %37, i32 noundef %38)
  br label %39

39:                                               ; preds = %27
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !5
  br label %24, !llvm.loop !11

42:                                               ; preds = %24
  br label %43

43:                                               ; preds = %42, %22
  br label %44

44:                                               ; preds = %47, %43
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = icmp slt i32 %45, 100000000
  br i1 %46, label %47, label %50

47:                                               ; preds = %44
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %7, align 4, !tbaa !5
  br label %44, !llvm.loop !12

50:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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 }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; 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
declare dso_local void @coordinates() local_unnamed_addr #0

declare void @draw_pixel(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @draw(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  tail call void @coordinates()
  %3 = icmp eq i32 %0, 0
  br i1 %3, label %.preheader, label %.preheader19

.preheader:                                       ; preds = %2
  %4 = sub nsw i32 384, %1
  br label %5

5:                                                ; preds = %.preheader, %5
  %.022 = phi i32 [ 0, %.preheader ], [ %6, %5 ]
  tail call void @draw_pixel(i32 noundef %.022, i32 noundef %4) #2
  %6 = add nuw nsw i32 %.022, 1
  %exitcond25.not = icmp eq i32 %6, 1024
  br i1 %exitcond25.not, label %.loopexit, label %5, !llvm.loop !5

.preheader19:                                     ; preds = %2, %.preheader19
  %.121 = phi i32 [ %11, %.preheader19 ], [ -384, %2 ]
  %7 = mul i32 %.121, %0
  %8 = add nsw i32 %.121, 512
  %9 = add i32 %7, %1
  %10 = sub i32 384, %9
  tail call void @draw_pixel(i32 noundef %8, i32 noundef %10) #2
  %11 = add nsw i32 %.121, 1
  %exitcond.not = icmp eq i32 %11, 896
  br i1 %exitcond.not, label %.loopexit, label %.preheader19, !llvm.loop !7

.loopexit:                                        ; preds = %.preheader19, %5
  ret void
}

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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass