; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/src/hid/led.ll (ZN5daisy3Led4InitE12dsy_gpio_pinbf)

; 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.daisy::Led" = type { i64, i64, float, float, float, i8, i8, i8, %struct.dsy_gpio }
%struct.dsy_gpio = type { %struct.dsy_gpio_pin, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5daisy3Led4InitE12dsy_gpio_pinbf(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 %1, i1 noundef zeroext %2, float noundef %3) #0 align 2 {
  %5 = alloca %struct.dsy_gpio_pin, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca float, align 4
  store i64 %1, ptr %5, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %7, align 1, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !11
  %10 = load ptr, ptr %6, align 8
  %11 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 8
  %12 = getelementptr inbounds %struct.dsy_gpio, ptr %11, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !13
  %13 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 8
  %14 = getelementptr inbounds %struct.dsy_gpio, ptr %13, i32 0, i32 1
  store i32 1, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 8
  call void @dsy_gpio_init(ptr noundef %15)
  %16 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 2
  store float 0.000000e+00, ptr %16, align 8, !tbaa !24
  %17 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 0
  store i64 0, ptr %17, align 8, !tbaa !25
  %18 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 2
  %19 = load float, ptr %18, align 8, !tbaa !24
  call void @_ZN5daisy3Led3SetEf(ptr noundef nonnull align 8 dereferenceable(48) %10, float noundef %19)
  %20 = load i8, ptr %7, align 1, !tbaa !9, !range !26, !noundef !27
  %21 = trunc i8 %20 to i1
  %22 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 5
  %23 = zext i1 %21 to i8
  store i8 %23, ptr %22, align 4, !tbaa !28
  %24 = load float, ptr %8, align 4, !tbaa !11
  %25 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 4
  store float %24, ptr %25, align 8, !tbaa !29
  %26 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 5
  %27 = load i8, ptr %26, align 4, !tbaa !28, !range !26, !noundef !27
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %32

29:                                               ; preds = %4
  %30 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 6
  store i8 0, ptr %30, align 1, !tbaa !30
  %31 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 7
  store i8 1, ptr %31, align 2, !tbaa !31
  br label %35

32:                                               ; preds = %4
  %33 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 6
  store i8 1, ptr %33, align 1, !tbaa !30
  %34 = getelementptr inbounds %"class.daisy::Led", ptr %10, i32 0, i32 7
  store i8 0, ptr %34, align 2, !tbaa !31
  br label %35

35:                                               ; preds = %32, %29
  ret void
}

; 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) #1

declare void @dsy_gpio_init(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5daisy3Led3SetEf(ptr noundef nonnull align 8 dereferenceable(48), float noundef) #0 align 2

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

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{i64 0, i64 4, !14, i64 4, i64 1, !16}
!14 = !{!15, !15, i64 0}
!15 = !{!"_ZTS13dsy_gpio_port", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !22, i64 40}
!18 = !{!"_ZTSN5daisy3LedE", !19, i64 0, !19, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !10, i64 28, !10, i64 29, !10, i64 30, !20, i64 32}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTS8dsy_gpio", !21, i64 0, !22, i64 8, !23, i64 12}
!21 = !{!"_ZTS12dsy_gpio_pin", !15, i64 0, !7, i64 4}
!22 = !{!"_ZTS13dsy_gpio_mode", !7, i64 0}
!23 = !{!"_ZTS13dsy_gpio_pull", !7, i64 0}
!24 = !{!18, !12, i64 16}
!25 = !{!18, !19, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!18, !10, i64 28}
!29 = !{!18, !12, i64 24}
!30 = !{!18, !10, i64 29}
!31 = !{!18, !10, i64 30}


; 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 @_ZN5daisy3Led4InitE12dsy_gpio_pinbf(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 %1, i1 noundef zeroext %2, float noundef %3) local_unnamed_addr #0 align 2 {
  %5 = zext i1 %2 to i8
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %1, ptr %6, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 1, ptr %7, align 8, !tbaa !5
  tail call void @dsy_gpio_init(ptr noundef nonnull %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store float 0.000000e+00, ptr %8, align 8, !tbaa !17
  store i64 0, ptr %0, align 8, !tbaa !18
  tail call void @_ZN5daisy3Led3SetEf(ptr noundef nonnull align 8 dereferenceable(48) %0, float noundef 0.000000e+00)
  %9 = getelementptr inbounds i8, ptr %0, i64 28
  store i8 %5, ptr %9, align 4, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store float %3, ptr %10, align 8, !tbaa !20
  %not. = xor i1 %2, true
  %spec.select = zext i1 %not. to i8
  %spec.select3 = zext i1 %2 to i8
  %11 = getelementptr inbounds i8, ptr %0, i64 29
  store i8 %spec.select, ptr %11, align 1
  %12 = getelementptr inbounds i8, ptr %0, i64 30
  store i8 %spec.select3, ptr %12, align 2
  ret void
}

declare void @dsy_gpio_init(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5daisy3Led3SetEf(ptr noundef nonnull align 8 dereferenceable(48), float noundef) local_unnamed_addr #0 align 2

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 = { "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, !15, i64 40}
!6 = !{!"_ZTSN5daisy3LedE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !11, i64 28, !11, i64 29, !11, i64 30, !12, i64 32}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTS8dsy_gpio", !13, i64 0, !15, i64 8, !16, i64 12}
!13 = !{!"_ZTS12dsy_gpio_pin", !14, i64 0, !8, i64 4}
!14 = !{!"_ZTS13dsy_gpio_port", !8, i64 0}
!15 = !{!"_ZTS13dsy_gpio_mode", !8, i64 0}
!16 = !{!"_ZTS13dsy_gpio_pull", !8, i64 0}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !11, i64 28}
!20 = !{!6, !10, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass