; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/src/dev (sr_595)

; 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.dsy_gpio_pin = type { i32, i8 }
%class.ShiftRegister595 = type { [3 x %struct.dsy_gpio], [16 x i8], i64 }
%struct.dsy_gpio = type { %struct.dsy_gpio_pin, i32, i32 }

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

10:                                               ; preds = %33, %3
  %11 = load i64, ptr %7, align 8, !tbaa !9
  %12 = icmp ult i64 %11, 3
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %36

14:                                               ; preds = %10
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.dsy_gpio_pin, ptr %15, i64 %16
  %18 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 0
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = getelementptr inbounds [3 x %struct.dsy_gpio], ptr %18, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.dsy_gpio, ptr %20, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 4 %17, i64 8, i1 false), !tbaa.struct !11
  %22 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 0
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = getelementptr inbounds [3 x %struct.dsy_gpio], ptr %22, i64 0, i64 %23
  %25 = getelementptr inbounds %struct.dsy_gpio, ptr %24, i32 0, i32 1
  store i32 1, ptr %25, align 8, !tbaa !15
  %26 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 0
  %27 = load i64, ptr %7, align 8, !tbaa !9
  %28 = getelementptr inbounds [3 x %struct.dsy_gpio], ptr %26, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.dsy_gpio, ptr %28, i32 0, i32 2
  store i32 0, ptr %29, align 4, !tbaa !20
  %30 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 0
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = getelementptr inbounds [3 x %struct.dsy_gpio], ptr %30, i64 0, i64 %31
  call void @dsy_gpio_init(ptr noundef %32)
  br label %33

33:                                               ; preds = %14
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %7, align 8, !tbaa !9
  br label %10, !llvm.loop !21

36:                                               ; preds = %13
  %37 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 1
  %38 = getelementptr inbounds [16 x i8], ptr %37, i64 0, i64 0
  %39 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 1
  %40 = getelementptr inbounds [16 x i8], ptr %39, i64 0, i64 0
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !23
  call void @_ZSt4fillIPhiEvT_S1_RKT0_(ptr noundef %38, ptr noundef %41, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 2
  store i64 %42, ptr %43, align 8, !tbaa !25
  %44 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 2
  %45 = load i64, ptr %44, align 8, !tbaa !25
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %51, label %47

47:                                               ; preds = %36
  %48 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 2
  %49 = load i64, ptr %48, align 8, !tbaa !25
  %50 = icmp ugt i64 %49, 16
  br i1 %50, label %51, label %53

51:                                               ; preds = %47, %36
  %52 = getelementptr inbounds %class.ShiftRegister595, ptr %9, i32 0, i32 2
  store i64 1, ptr %52, align 8, !tbaa !25
  br label %53

53:                                               ; preds = %51, %47
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @dsy_gpio_init(ptr noundef) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPhiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { inlinehint mustprogress 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 #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 1, !14}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS13dsy_gpio_port", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !18, i64 8}
!16 = !{!"_ZTS8dsy_gpio", !17, i64 0, !18, i64 8, !19, i64 12}
!17 = !{!"_ZTS12dsy_gpio_pin", !13, i64 0, !7, i64 4}
!18 = !{!"_ZTS13dsy_gpio_mode", !7, i64 0}
!19 = !{!"_ZTS13dsy_gpio_pull", !7, i64 0}
!20 = !{!16, !19, i64 12}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!24, !24, i64 0}
!24 = !{!"int", !7, i64 0}
!25 = !{!26, !10, i64 64}
!26 = !{!"_ZTS16ShiftRegister595", !7, i64 0, !7, i64 48, !10, i64 64}


; 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 uwtable
define dso_local void @_ZN16ShiftRegister5954InitEP12dsy_gpio_pinm(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca i32, align 4
  %5 = load i64, ptr %1, align 4
  store i64 %5, ptr %0, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 1, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %7, align 4, !tbaa !13
  tail call void @dsy_gpio_init(ptr noundef nonnull %0)
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i64, ptr %8, align 4
  store i64 %10, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 1, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 0, ptr %12, align 4, !tbaa !13
  tail call void @dsy_gpio_init(ptr noundef nonnull %9)
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load i64, ptr %13, align 4
  store i64 %15, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 1, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 0, ptr %17, align 4, !tbaa !13
  tail call void @dsy_gpio_init(ptr noundef nonnull %14)
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  %19 = getelementptr inbounds i8, ptr %0, i64 64
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 0, ptr %4, align 4, !tbaa !14
  call void @_ZSt4fillIPhiEvT_S1_RKT0_(ptr noundef nonnull %18, ptr noundef nonnull %19, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  %20 = add i64 %2, -17
  %or.cond = icmp ult i64 %20, -16
  %spec.store.select = select i1 %or.cond, i64 1, i64 %2
  store i64 %spec.store.select, ptr %19, align 8
  ret void
}

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

declare void @dsy_gpio_init(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPhiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 #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, !11, i64 8}
!6 = !{!"_ZTS8dsy_gpio", !7, i64 0, !11, i64 8, !12, i64 12}
!7 = !{!"_ZTS12dsy_gpio_pin", !8, i64 0, !9, i64 4}
!8 = !{!"_ZTS13dsy_gpio_port", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS13dsy_gpio_mode", !9, i64 0}
!12 = !{!"_ZTS13dsy_gpio_pull", !9, i64 0}
!13 = !{!6, !12, i64 12}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass