; LLVM IR from laurimi/ase_exploration :: src/ExplorationPlanner/sensor/Bresenham2D.ll (ZN11Bresenham2D10initializeEii)

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

%class.Bresenham2D = type <{ i8, [3 x i8], i32, i32, i32, i32, i32, i32, i32, i8, i8, i8, i8 }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11Bresenham2D10initializeEii(ptr noundef nonnull align 4 dereferenceable(35) %0, i32 noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 2
  store i32 0, ptr %8, align 4, !tbaa !11
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 4
  store i32 %9, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 3
  store i32 0, ptr %11, align 4, !tbaa !15
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 5
  store i32 %12, ptr %13, align 4, !tbaa !16
  %14 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 4
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 2
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = sub nsw i32 %15, %17
  %19 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  store i32 %18, ptr %19, align 4, !tbaa !17
  %20 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  %21 = load i32, ptr %20, align 4, !tbaa !17
  %22 = icmp sgt i32 %21, 0
  %23 = zext i1 %22 to i32
  %24 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  %25 = load i32, ptr %24, align 4, !tbaa !17
  %26 = icmp slt i32 %25, 0
  %27 = zext i1 %26 to i32
  %28 = sub nsw i32 %23, %27
  %29 = trunc i32 %28 to i8
  %30 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 9
  store i8 %29, ptr %30, align 4, !tbaa !18
  %31 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = call i32 @llvm.abs.i32(i32 %32, i1 true)
  %34 = shl i32 %33, 1
  %35 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  store i32 %34, ptr %35, align 4, !tbaa !17
  %36 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 5
  %37 = load i32, ptr %36, align 4, !tbaa !16
  %38 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 3
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = sub nsw i32 %37, %39
  %41 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  store i32 %40, ptr %41, align 4, !tbaa !19
  %42 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  %43 = load i32, ptr %42, align 4, !tbaa !19
  %44 = icmp sgt i32 %43, 0
  %45 = zext i1 %44 to i32
  %46 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = icmp slt i32 %47, 0
  %49 = zext i1 %48 to i32
  %50 = sub nsw i32 %45, %49
  %51 = trunc i32 %50 to i8
  %52 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 10
  store i8 %51, ptr %52, align 1, !tbaa !20
  %53 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = call i32 @llvm.abs.i32(i32 %54, i1 true)
  %56 = shl i32 %55, 1
  %57 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  store i32 %56, ptr %57, align 4, !tbaa !19
  %58 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  %59 = load i32, ptr %58, align 4, !tbaa !17
  %60 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  %61 = load i32, ptr %60, align 4, !tbaa !19
  %62 = icmp sge i32 %59, %61
  %63 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 11
  %64 = zext i1 %62 to i8
  store i8 %64, ptr %63, align 2, !tbaa !21
  %65 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 11
  %66 = load i8, ptr %65, align 2, !tbaa !21, !range !22, !noundef !23
  %67 = trunc i8 %66 to i1
  br i1 %67, label %68, label %76

68:                                               ; preds = %3
  %69 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  %70 = load i32, ptr %69, align 4, !tbaa !19
  %71 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  %72 = load i32, ptr %71, align 4, !tbaa !17
  %73 = ashr i32 %72, 1
  %74 = sub nsw i32 %70, %73
  %75 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 8
  store i32 %74, ptr %75, align 4, !tbaa !24
  br label %84

76:                                               ; preds = %3
  %77 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 6
  %78 = load i32, ptr %77, align 4, !tbaa !17
  %79 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 7
  %80 = load i32, ptr %79, align 4, !tbaa !19
  %81 = ashr i32 %80, 1
  %82 = sub nsw i32 %78, %81
  %83 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 8
  store i32 %82, ptr %83, align 4, !tbaa !24
  br label %84

84:                                               ; preds = %76, %68
  %85 = getelementptr inbounds %class.Bresenham2D, ptr %7, i32 0, i32 0
  store i8 1, ptr %85, align 4, !tbaa !25
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

attributes #0 = { mustprogress 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 speculatable willreturn memory(none) }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTS11Bresenham2D", !13, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !7, i64 33, !13, i64 34}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 20}
!18 = !{!12, !7, i64 32}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !7, i64 33}
!21 = !{!12, !13, i64 34}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!12, !10, i64 28}
!25 = !{!12, !13, i64 0}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN11Bresenham2D10initializeEii(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(35) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %1, ptr %5, align 4, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %6, align 4, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %2, ptr %7, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  %.lobit.neg = ashr i32 %1, 31
  %isnotnull = icmp ne i32 %1, 0
  %isnotnull.zext = zext i1 %isnotnull to i32
  %9 = or i32 %.lobit.neg, %isnotnull.zext
  %10 = trunc nsw i32 %9 to i8
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store i8 %10, ptr %11, align 4, !tbaa !14
  %12 = tail call i32 @llvm.abs.i32(i32 %1, i1 true)
  %13 = shl nuw i32 %12, 1
  store i32 %13, ptr %8, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %.lobit.neg2 = ashr i32 %2, 31
  %isnotnull3 = icmp ne i32 %2, 0
  %isnotnull.zext4 = zext i1 %isnotnull3 to i32
  %15 = or i32 %.lobit.neg2, %isnotnull.zext4
  %16 = trunc nsw i32 %15 to i8
  %17 = getelementptr inbounds i8, ptr %0, i64 33
  store i8 %16, ptr %17, align 1, !tbaa !16
  %18 = tail call i32 @llvm.abs.i32(i32 %2, i1 true)
  %19 = shl nuw i32 %18, 1
  store i32 %19, ptr %14, align 4, !tbaa !17
  %20 = icmp sge i32 %13, %19
  %21 = getelementptr inbounds i8, ptr %0, i64 34
  %22 = zext i1 %20 to i8
  store i8 %22, ptr %21, align 2, !tbaa !18
  %. = tail call i32 @llvm.smax.i32(i32 %13, i32 %19)
  %.7 = tail call i32 @llvm.smin.i32(i32 %13, i32 %19)
  %23 = ashr exact i32 %., 1
  %24 = sub nsw i32 %.7, %23
  %25 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %24, ptr %25, align 4
  store i8 1, ptr %0, align 4, !tbaa !19
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, i64 4}
!6 = !{!"_ZTS11Bresenham2D", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !8, i64 32, !8, i64 33, !7, i64 34}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 12}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !8, i64 32}
!15 = !{!6, !10, i64 20}
!16 = !{!6, !8, i64 33}
!17 = !{!6, !10, i64 24}
!18 = !{!6, !7, i64 34}
!19 = !{!6, !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass