; LLVM IR from Nonoum/ECL :: ECL_common (ECL_JH_Write_E4E5)

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

; 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: nounwind uwtable
declare dso_local void @ECL_JH_Write(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local void @ECL_JH_Write_E4E5(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  %6 = load i32, ptr %4, align 4, !tbaa !9
  %7 = icmp ugt i32 %6, 15
  %8 = zext i1 %7 to i64
  %9 = select i1 %7, i32 16, i32 0
  %10 = trunc i32 %9 to i8
  store i8 %10, ptr %5, align 1, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = trunc i32 %12 to i8
  %14 = zext i8 %13 to i32
  %15 = load i8, ptr %5, align 1, !tbaa !11
  %16 = zext i8 %15 to i32
  %17 = or i32 %14, %16
  %18 = trunc i32 %17 to i8
  call void @ECL_JH_Write(ptr noundef %11, i8 noundef zeroext %18, i8 noundef zeroext 5)
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = lshr i32 %19, 4
  store i32 %20, ptr %4, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %24, %2
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %40

24:                                               ; preds = %21
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = icmp ugt i32 %25, 31
  %27 = zext i1 %26 to i64
  %28 = select i1 %26, i32 32, i32 0
  %29 = trunc i32 %28 to i8
  store i8 %29, ptr %5, align 1, !tbaa !11
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = trunc i32 %31 to i8
  %33 = zext i8 %32 to i32
  %34 = load i8, ptr %5, align 1, !tbaa !11
  %35 = zext i8 %34 to i32
  %36 = or i32 %33, %35
  %37 = trunc i32 %36 to i8
  call void @ECL_JH_Write(ptr noundef %30, i8 noundef zeroext %37, i8 noundef zeroext 6)
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = lshr i32 %38, 5
  store i32 %39, ptr %4, align 4, !tbaa !9
  br label %21, !llvm.loop !12

40:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: nounwind uwtable
declare dso_local void @ECL_JH_Write(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @ECL_JH_Write_E4E5(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %.inv = icmp ult i32 %1, 16
  %3 = select i1 %.inv, i32 0, i32 16
  %4 = or i32 %3, %1
  %5 = trunc i32 %4 to i8
  tail call void @ECL_JH_Write(ptr noundef %0, i8 noundef zeroext %5, i8 noundef zeroext 5)
  br i1 %.inv, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %6 = lshr i32 %1, 4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.012 = phi i32 [ %10, %.lr.ph ], [ %6, %.lr.ph.preheader ]
  %.inv10 = icmp ult i32 %.012, 32
  %7 = select i1 %.inv10, i32 0, i32 32
  %8 = or i32 %7, %.012
  %9 = trunc i32 %8 to i8
  tail call void @ECL_JH_Write(ptr noundef %0, i8 noundef zeroext %9, i8 noundef zeroext 6)
  %10 = lshr i32 %.012, 5
  br i1 %.inv10, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void
}

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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass