; LLVM IR from nde-jesu/Doom_Nukem :: libbmp/srcs/maths (infos)

; 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_dib = type { %struct.s_vec, %struct.s_vec, i8, i8, i8, i8, i32, i32, i32 }
%struct.s_vec = type { i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @scanline(ptr noundef byval(%struct.s_dib) align 8 %0, i8 noundef zeroext %1) #0 {
  %3 = alloca i8, align 1
  store i8 %1, ptr %3, align 1, !tbaa !5
  %4 = getelementptr inbounds %struct.s_dib, ptr %0, i32 0, i32 1
  %5 = getelementptr inbounds %struct.s_vec, ptr %4, i32 0, i32 0
  %6 = load i32, ptr %5, align 8, !tbaa !8
  %7 = getelementptr inbounds %struct.s_dib, ptr %0, i32 0, i32 2
  %8 = load i8, ptr %7, align 8, !tbaa !12
  %9 = zext i8 %8 to i32
  %10 = sdiv i32 %9, 8
  %11 = mul nsw i32 %6, %10
  %12 = load i8, ptr %3, align 1, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = add nsw i32 %11, %13
  ret i32 %14
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"s_dib", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 17, !6, i64 18, !6, i64 19, !11, i64 20, !11, i64 24, !11, i64 28}
!10 = !{!"s_vec", !11, i64 0, !11, i64 4}
!11 = !{!"int", !6, i64 0}
!12 = !{!9, !6, i64 16}


; 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.s_dib = type { %struct.s_vec, %struct.s_vec, i8, i8, i8, i8, i32, i32, i32 }
%struct.s_vec = type { i32, i32 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @scanline(ptr nocapture noundef readonly byval(%struct.s_dib) align 8 %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i8, ptr %5, align 8, !tbaa !11
  %7 = lshr i8 %6, 3
  %8 = zext nneg i8 %7 to i32
  %9 = mul nsw i32 %4, %8
  %10 = zext i8 %1 to i32
  %11 = add nsw i32 %9, %10
  ret i32 %11
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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, !8, i64 8}
!6 = !{!"s_dib", !7, i64 0, !7, i64 8, !9, i64 16, !9, i64 17, !9, i64 18, !9, i64 19, !8, i64 20, !8, i64 24, !8, i64 28}
!7 = !{!"s_vec", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!6, !9, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass