; LLVM IR from IOsonata/IOsonata :: src/slip_intrf.ll/Z26SlipIntrfRxDataNonBlockingP14 (device_intrfPhi)

; 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.__device_intrf = type <{ ptr, i32, ptr, %"struct.std::atomic_flag", [3 x i8], i32, %"struct.std::atomic", i32, i8, i8, %"struct.std::atomic.0", %"struct.std::atomic.0", i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }>
%"struct.std::atomic_flag" = type { %"struct.std::__atomic_flag_base" }
%"struct.std::__atomic_flag_base" = type { i8 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i8 }
%struct.__Slip_Device = type <{ %struct.__device_intrf, ptr, ptr, i8, [7 x i8] }>

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z26SlipIntrfRxDataNonBlockingP14__device_intrfPhi(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.__device_intrf, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 4, !tbaa !11
  store ptr %14, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #2
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.__Slip_Device, ptr %15, i32 0, i32 3
  store volatile i8 0, ptr %16, align 8, !tbaa !22
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i8, ptr %17, align 1, !tbaa !24
  %19 = zext i8 %18 to i32
  %20 = icmp eq i32 %19, 219
  br i1 %20, label %21, label %53

21:                                               ; preds = %3
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.__Slip_Device, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !25
  %25 = getelementptr inbounds %struct.__device_intrf, ptr %24, i32 0, i32 18
  %26 = load ptr, ptr %25, align 4, !tbaa !26
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.__Slip_Device, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !25
  %30 = call noundef i32 %26(ptr noundef %29, ptr noundef %10, i32 noundef 1)
  %31 = icmp sle i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %21
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %119

33:                                               ; preds = %21
  %34 = load i8, ptr %10, align 1, !tbaa !24
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 220
  br i1 %36, label %37, label %39

37:                                               ; preds = %33
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 -64, ptr %38, align 1, !tbaa !24
  br label %46

39:                                               ; preds = %33
  %40 = load i8, ptr %10, align 1, !tbaa !24
  %41 = zext i8 %40 to i32
  %42 = icmp eq i32 %41, 221
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 -37, ptr %44, align 1, !tbaa !24
  br label %45

45:                                               ; preds = %43, %39
  br label %46

46:                                               ; preds = %45, %37
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i32 1
  store ptr %48, ptr %6, align 8, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr %7, align 4, !tbaa !9
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %9, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %46, %3
  br label %54

54:                                               ; preds = %110, %53
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %57, label %117

57:                                               ; preds = %54
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.__Slip_Device, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !25
  %61 = getelementptr inbounds %struct.__device_intrf, ptr %60, i32 0, i32 18
  %62 = load ptr, ptr %61, align 4, !tbaa !26
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.__Slip_Device, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !25
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = call noundef i32 %62(ptr noundef %65, ptr noundef %66, i32 noundef 1)
  %68 = icmp sle i32 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %57
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 -1, ptr %70, align 1, !tbaa !24
  br label %117

71:                                               ; preds = %57
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load i8, ptr %72, align 1, !tbaa !24
  %74 = zext i8 %73 to i32
  %75 = icmp eq i32 %74, 192
  br i1 %75, label %76, label %79

76:                                               ; preds = %71
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.__Slip_Device, ptr %77, i32 0, i32 3
  store volatile i8 1, ptr %78, align 8, !tbaa !22
  br label %117

79:                                               ; preds = %71
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = load i8, ptr %80, align 1, !tbaa !24
  %82 = zext i8 %81 to i32
  %83 = icmp eq i32 %82, 219
  br i1 %83, label %84, label %110

84:                                               ; preds = %79
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.__Slip_Device, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !25
  %88 = getelementptr inbounds %struct.__device_intrf, ptr %87, i32 0, i32 18
  %89 = load ptr, ptr %88, align 4, !tbaa !26
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.__Slip_Device, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !25
  %93 = call noundef i32 %89(ptr noundef %92, ptr noundef %10, i32 noundef 1)
  %94 = icmp sle i32 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %84
  br label %117

96:                                               ; preds = %84
  %97 = load i8, ptr %10, align 1, !tbaa !24
  %98 = zext i8 %97 to i32
  %99 = icmp eq i32 %98, 220
  br i1 %99, label %100, label %102

100:                                              ; preds = %96
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 -64, ptr %101, align 1, !tbaa !24
  br label %109

102:                                              ; preds = %96
  %103 = load i8, ptr %10, align 1, !tbaa !24
  %104 = zext i8 %103 to i32
  %105 = icmp eq i32 %104, 221
  br i1 %105, label %106, label %108

106:                                              ; preds = %102
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 -37, ptr %107, align 1, !tbaa !24
  br label %108

108:                                              ; preds = %106, %102
  br label %109

109:                                              ; preds = %108, %100
  br label %110

110:                                              ; preds = %109, %79
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds i8, ptr %111, i32 1
  store ptr %112, ptr %6, align 8, !tbaa !5
  %113 = load i32, ptr %7, align 4, !tbaa !9
  %114 = add nsw i32 %113, -1
  store i32 %114, ptr %7, align 4, !tbaa !9
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %9, align 4, !tbaa !9
  br label %54, !llvm.loop !27

117:                                              ; preds = %95, %76, %69, %54
  %118 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %118, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %119

119:                                              ; preds = %117, %32
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %120 = load i32, ptr %4, align 4
  ret i32 %120
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS14__device_intrf", !6, i64 0, !10, i64 8, !6, i64 12, !13, i64 20, !10, i64 24, !16, i64 28, !18, i64 32, !15, i64 36, !15, i64 37, !19, i64 38, !19, i64 39, !21, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152}
!13 = !{!"_ZTSSt11atomic_flag", !14, i64 0}
!14 = !{!"_ZTSSt18__atomic_flag_base", !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSSt6atomicIiE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!18 = !{!"_ZTS16__Dev_Intrf_Type", !7, i64 0}
!19 = !{!"_ZTSSt6atomicIbE", !20, i64 0}
!20 = !{!"_ZTSSt13__atomic_baseIbE", !15, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!23, !15, i64 176}
!23 = !{!"_ZTS13__Slip_Device", !12, i64 0, !6, i64 160, !6, i64 168, !15, i64 176}
!24 = !{!7, !7, i64 0}
!25 = !{!23, !6, i64 160}
!26 = !{!12, !6, i64 88}
!27 = distinct !{!27, !28}
!28 = !{!"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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z26SlipIntrfRxDataNonBlockingP14__device_intrfPhi(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca i8, align 1
  %5 = load ptr, ptr %0, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #2
  %6 = getelementptr inbounds i8, ptr %5, i64 176
  store volatile i8 0, ptr %6, align 8, !tbaa !20
  %7 = load i8, ptr %1, align 1, !tbaa !22
  %8 = icmp eq i8 %7, -37
  br i1 %8, label %9, label %22

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %5, i64 160
  %11 = load ptr, ptr %10, align 8, !tbaa !23
  %12 = getelementptr inbounds i8, ptr %11, i64 88
  %13 = load ptr, ptr %12, align 4, !tbaa !24
  %14 = call noundef i32 %13(ptr noundef %11, ptr noundef nonnull %4, i32 noundef 1)
  %15 = icmp slt i32 %14, 1
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %9
  %17 = load i8, ptr %4, align 1, !tbaa !22
  switch i8 %17, label %19 [
    i8 -36, label %.sink.split
    i8 -35, label %18
  ]

18:                                               ; preds = %16
  br label %.sink.split

.sink.split:                                      ; preds = %16, %18
  %.sink = phi i8 [ -37, %18 ], [ -64, %16 ]
  store i8 %.sink, ptr %1, align 1, !tbaa !22
  br label %19

19:                                               ; preds = %.sink.split, %16
  %20 = getelementptr inbounds i8, ptr %1, i64 1
  %21 = add nsw i32 %2, -1
  br label %22

22:                                               ; preds = %19, %3
  %.029 = phi ptr [ %20, %19 ], [ %1, %3 ]
  %.027 = phi i32 [ %21, %19 ], [ %2, %3 ]
  %.0 = phi i32 [ 1, %19 ], [ 0, %3 ]
  %23 = icmp sgt i32 %.027, 0
  br i1 %23, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %22
  %24 = getelementptr inbounds i8, ptr %5, i64 160
  %25 = add nuw i32 %.027, %.0
  br label %26

26:                                               ; preds = %.lr.ph, %45
  %.140 = phi i32 [ %.0, %.lr.ph ], [ %47, %45 ]
  %.13038 = phi ptr [ %.029, %.lr.ph ], [ %46, %45 ]
  %27 = load ptr, ptr %24, align 8, !tbaa !23
  %28 = getelementptr inbounds i8, ptr %27, i64 88
  %29 = load ptr, ptr %28, align 4, !tbaa !24
  %30 = call noundef i32 %29(ptr noundef %27, ptr noundef nonnull %.13038, i32 noundef 1)
  %31 = icmp slt i32 %30, 1
  br i1 %31, label %32, label %33

32:                                               ; preds = %26
  store i8 -1, ptr %.13038, align 1, !tbaa !22
  br label %.loopexit

33:                                               ; preds = %26
  %34 = load i8, ptr %.13038, align 1, !tbaa !22
  switch i8 %34, label %45 [
    i8 -64, label %35
    i8 -37, label %36
  ]

35:                                               ; preds = %33
  store volatile i8 1, ptr %6, align 8, !tbaa !20
  br label %.loopexit

36:                                               ; preds = %33
  %37 = load ptr, ptr %24, align 8, !tbaa !23
  %38 = getelementptr inbounds i8, ptr %37, i64 88
  %39 = load ptr, ptr %38, align 4, !tbaa !24
  %40 = call noundef i32 %39(ptr noundef %37, ptr noundef nonnull %4, i32 noundef 1)
  %41 = icmp slt i32 %40, 1
  br i1 %41, label %.loopexit, label %42

42:                                               ; preds = %36
  %43 = load i8, ptr %4, align 1, !tbaa !22
  switch i8 %43, label %45 [
    i8 -36, label %.sink.split51
    i8 -35, label %44
  ]

44:                                               ; preds = %42
  br label %.sink.split51

.sink.split51:                                    ; preds = %42, %44
  %.sink52 = phi i8 [ -37, %44 ], [ -64, %42 ]
  store i8 %.sink52, ptr %.13038, align 1, !tbaa !22
  br label %45

45:                                               ; preds = %.sink.split51, %42, %33
  %46 = getelementptr inbounds i8, ptr %.13038, i64 1
  %47 = add nuw i32 %.140, 1
  %exitcond.not = icmp eq i32 %47, %25
  br i1 %exitcond.not, label %.loopexit, label %26, !llvm.loop !25

.loopexit:                                        ; preds = %36, %45, %22, %32, %35, %9
  %.026 = phi i32 [ 0, %9 ], [ %.140, %35 ], [ %.140, %32 ], [ %.0, %22 ], [ %.140, %36 ], [ %25, %45 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #2
  ret i32 %.026
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTS14__device_intrf", !7, i64 0, !10, i64 8, !7, i64 12, !11, i64 20, !10, i64 24, !14, i64 28, !16, i64 32, !13, i64 36, !13, i64 37, !17, i64 38, !17, i64 39, !19, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSSt11atomic_flag", !12, i64 0}
!12 = !{!"_ZTSSt18__atomic_flag_base", !13, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTSSt6atomicIiE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!16 = !{!"_ZTS16__Dev_Intrf_Type", !8, i64 0}
!17 = !{!"_ZTSSt6atomicIbE", !18, i64 0}
!18 = !{!"_ZTSSt13__atomic_baseIbE", !13, i64 0}
!19 = !{!"long", !8, i64 0}
!20 = !{!21, !13, i64 176}
!21 = !{!"_ZTS13__Slip_Device", !6, i64 0, !7, i64 160, !7, i64 168, !13, i64 176}
!22 = !{!8, !8, i64 0}
!23 = !{!21, !7, i64 160}
!24 = !{!6, !7, i64 88}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass