; LLVM IR from sskorol/respeaker-websockets :: src (animation)

; 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.RUNTIME_OPTIONS = type { [50 x i8], %struct.HW_LED_SPEC, %struct.HW_GPIO_SPEC, i8, i64, i32, %struct.COLOURS, i32, i8, i8, [6 x i8], i8 }
%struct.HW_LED_SPEC = type { i32, i32, i32 }
%struct.HW_GPIO_SPEC = type { i32, i32 }
%struct.COLOURS = type { i32, i32, i32, i32, i32 }

@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [33 x i8], align 1
@RUNTIME = external global %struct.RUNTIME_OPTIONS, align 8
@__FUNCTION__.on_disabled = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1

declare i32 @verbose(i32 noundef, ptr noundef, ptr noundef, ...) #0

declare void @cAPA102_Clear_All() #0

; Function Attrs: nounwind uwtable
declare hidden void @delay_on_state(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @on_disabled() #1 {
  %1 = load ptr, ptr @stdout, align 8, !tbaa !5
  %2 = call i32 (i32, ptr, ptr, ...) @verbose(i32 noundef 2, ptr noundef %1, ptr noundef @.str, ptr noundef @__FUNCTION__.on_disabled)
  store i8 0, ptr getelementptr inbounds (%struct.RUNTIME_OPTIONS, ptr @RUNTIME, i32 0, i32 8), align 4, !tbaa !9
  br label %3

3:                                                ; preds = %6, %0
  %4 = load i32, ptr getelementptr inbounds (%struct.RUNTIME_OPTIONS, ptr @RUNTIME, i32 0, i32 5), align 8, !tbaa !16
  %5 = icmp eq i32 %4, 5
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  call void @cAPA102_Clear_All()
  call void @delay_on_state(i32 noundef 100, i32 noundef 5)
  br label %3, !llvm.loop !17

7:                                                ; preds = %3
  call void @cAPA102_Clear_All()
  ret ptr @.str.6
}

attributes #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 116}
!10 = !{!"", !7, i64 0, !11, i64 52, !13, i64 64, !7, i64 72, !14, i64 80, !12, i64 88, !15, i64 92, !12, i64 112, !7, i64 116, !7, i64 117, !7, i64 118, !7, i64 124}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!10, !12, i64 88}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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.RUNTIME_OPTIONS = type { [50 x i8], %struct.HW_LED_SPEC, %struct.HW_GPIO_SPEC, i8, i64, i32, %struct.COLOURS, i32, i8, i8, [6 x i8], i8 }
%struct.HW_LED_SPEC = type { i32, i32, i32 }
%struct.HW_GPIO_SPEC = type { i32, i32 }
%struct.COLOURS = type { i32, i32, i32, i32, i32 }

@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [33 x i8], align 1
@RUNTIME = external local_unnamed_addr global %struct.RUNTIME_OPTIONS, align 8
@__FUNCTION__.on_disabled = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1

declare i32 @verbose(i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

declare void @cAPA102_Clear_All() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @delay_on_state(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @on_disabled() local_unnamed_addr #1 {
  %1 = load ptr, ptr @stdout, align 8, !tbaa !5
  %2 = tail call i32 (i32, ptr, ptr, ...) @verbose(i32 noundef 2, ptr noundef %1, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.on_disabled) #2
  store i8 0, ptr getelementptr inbounds (i8, ptr @RUNTIME, i64 116), align 4, !tbaa !9
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @RUNTIME, i64 88), align 8, !tbaa !16
  %4 = icmp eq i32 %3, 5
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  tail call void @cAPA102_Clear_All() #2
  tail call void @delay_on_state(i32 noundef 100, i32 noundef 5)
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @RUNTIME, i64 88), align 8, !tbaa !16
  %6 = icmp eq i32 %5, 5
  br i1 %6, label %.lr.ph, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %0
  tail call void @cAPA102_Clear_All() #2
  ret ptr @.str.6
}

attributes #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 = { 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 #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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 116}
!10 = !{!"", !7, i64 0, !11, i64 52, !13, i64 64, !7, i64 72, !14, i64 80, !12, i64 88, !15, i64 92, !12, i64 112, !7, i64 116, !7, i64 117, !7, i64 118, !7, i64 124}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!10, !12, i64 88}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SimplifyCFGPass,TailCallElimPass