; LLVM IR from mlcommons/tiny :: benchmark/interface/Middlewares/ST/filex/common/src/fxe_unicode_directory_crea_9baafb26 (create)

; 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.TX_THREAD_STRUCT = type { i64, i64, ptr, ptr, ptr, i64, i64, i64, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i64, %struct.TX_TIMER_INTERNAL_STRUCT, ptr, ptr, ptr, ptr, i64, ptr, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64 }
%struct.TX_TIMER_INTERNAL_STRUCT = type { i64, i64, ptr, i64, ptr, ptr, ptr }

@_tx_thread_system_state = external global i64, align 8
@_tx_thread_current_ptr = external global ptr, align 8
@_tx_timer_thread = external global %struct.TX_THREAD_STRUCT, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @_fxe_unicode_directory_create(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %24, label %15

15:                                               ; preds = %4
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %24, label %18

18:                                               ; preds = %15
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %21, %18, %15, %4
  store i32 24, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %74

25:                                               ; preds = %21
  %26 = load volatile i64, ptr @_tx_thread_system_state, align 8, !tbaa !9
  %27 = call i32 @_tx_ipsr_get()
  %28 = zext i32 %27 to i64
  %29 = or i64 %26, %28
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %37, label %31

31:                                               ; preds = %25
  %32 = load ptr, ptr @_tx_thread_current_ptr, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %37, label %34

34:                                               ; preds = %31
  %35 = load ptr, ptr @_tx_thread_current_ptr, align 8, !tbaa !5
  %36 = icmp eq ptr %35, @_tx_timer_thread
  br i1 %36, label %37, label %38

37:                                               ; preds = %34, %31, %25
  store i32 32, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %74

38:                                               ; preds = %34
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %64, %38
  %40 = load i32, ptr %11, align 4, !tbaa !11
  %41 = zext i32 %40 to i64
  %42 = load i64, ptr %8, align 8, !tbaa !9
  %43 = shl i64 %42, 1
  %44 = icmp ult i64 %41, %43
  br i1 %44, label %45, label %67

45:                                               ; preds = %39
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i32, ptr %11, align 4, !tbaa !11
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !13
  %51 = zext i8 %50 to i32
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %63

53:                                               ; preds = %45
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load i32, ptr %11, align 4, !tbaa !11
  %56 = add i32 %55, 1
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %54, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !13
  %60 = zext i8 %59 to i32
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %53
  store i32 12, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %74

63:                                               ; preds = %53, %45
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %11, align 4, !tbaa !11
  %66 = add i32 %65, 2
  store i32 %66, ptr %11, align 4, !tbaa !11
  br label %39, !llvm.loop !14

67:                                               ; preds = %39
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i64, ptr %8, align 8, !tbaa !9
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = call i32 @_fx_unicode_directory_create(ptr noundef %68, ptr noundef %69, i64 noundef %70, ptr noundef %71)
  store i32 %72, ptr %10, align 4, !tbaa !11
  %73 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %73, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %74

74:                                               ; preds = %67, %62, %37, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %75 = load i32, ptr %5, align 4
  ret i32 %75
}

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @_tx_ipsr_get() #2

declare i32 @_fx_unicode_directory_create(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #3

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 #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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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.TX_THREAD_STRUCT = type { i64, i64, ptr, ptr, ptr, i64, i64, i64, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i64, %struct.TX_TIMER_INTERNAL_STRUCT, ptr, ptr, ptr, ptr, i64, ptr, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64 }
%struct.TX_TIMER_INTERNAL_STRUCT = type { i64, i64, ptr, i64, ptr, ptr, ptr }

@_tx_thread_system_state = external global i64, align 8
@_tx_thread_current_ptr = external local_unnamed_addr global ptr, align 8
@_tx_timer_thread = external global %struct.TX_THREAD_STRUCT, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @_fxe_unicode_directory_create(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %0, null
  %6 = icmp eq ptr %1, null
  %or.cond = or i1 %5, %6
  %7 = icmp eq i64 %2, 0
  %or.cond3 = or i1 %or.cond, %7
  %8 = icmp eq ptr %3, null
  %or.cond5 = or i1 %or.cond3, %8
  br i1 %or.cond5, label %.loopexit, label %9

9:                                                ; preds = %4
  %10 = load volatile i64, ptr @_tx_thread_system_state, align 8, !tbaa !5
  %11 = tail call i32 @_tx_ipsr_get()
  %12 = zext i32 %11 to i64
  %13 = or i64 %10, %12
  %14 = icmp ne i64 %13, 0
  %15 = load ptr, ptr @_tx_thread_current_ptr, align 8
  %16 = icmp eq ptr %15, null
  %17 = icmp eq ptr %15, @_tx_timer_thread
  %18 = or i1 %16, %17
  %or.cond9 = select i1 %14, i1 true, i1 %18
  br i1 %or.cond9, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %9
  %19 = shl i64 %2, 1
  %.not = icmp eq i64 %19, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %30
  %20 = phi i64 [ %32, %30 ], [ 0, %.preheader ]
  %.031 = phi i32 [ %31, %30 ], [ 0, %.preheader ]
  %21 = getelementptr inbounds i8, ptr %1, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = icmp eq i8 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %.lr.ph
  %25 = or disjoint i32 %.031, 1
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %1, i64 %26
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = icmp eq i8 %28, 0
  br i1 %29, label %.loopexit, label %30

30:                                               ; preds = %.lr.ph, %24
  %31 = add i32 %.031, 2
  %32 = zext i32 %31 to i64
  %33 = icmp ugt i64 %19, %32
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %30, %.preheader
  %34 = tail call i32 @_fx_unicode_directory_create(ptr noundef %0, ptr noundef nonnull %1, i64 noundef %2, ptr noundef %3) #3
  br label %.loopexit

.loopexit:                                        ; preds = %24, %9, %4, %._crit_edge
  %.025 = phi i32 [ %34, %._crit_edge ], [ 24, %4 ], [ 32, %9 ], [ 12, %24 ]
  ret i32 %.025
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @_tx_ipsr_get() local_unnamed_addr #1

declare i32 @_fx_unicode_directory_create(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

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" }
attributes #1 = { alwaysinline 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 = { "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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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