; LLVM IR from facebook/hermes :: API/hermes_sandbox/external (hermes_sandbox_impl_compiled_5)

; 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.w2c_hermes = type { ptr, ptr, ptr, i32, i32, i32, %struct.wasm_rt_memory_t, %struct.wasm_rt_funcref_table_t }
%struct.wasm_rt_memory_t = type { ptr, i64, i64, i64, i8 }
%struct.wasm_rt_funcref_table_t = type { ptr, i32, i32 }

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @i64_load(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_llvh0x3A0x3AAPInt0x3A0x3AcountTrailingZerosSlowCase0x280x290x20const(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  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 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %17 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %17, ptr %11, align 4, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.w2c_hermes, ptr %18, i32 0, i32 6
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = add i64 %21, 8
  %23 = call i32 @i32_load(ptr noundef %19, i64 noundef %22)
  store i32 %23, ptr %11, align 4, !tbaa !9
  %24 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %24, ptr %7, align 4, !tbaa !9
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  store i64 %26, ptr %15, align 8, !tbaa !11
  store i64 63, ptr %16, align 8, !tbaa !11
  %27 = load i64, ptr %16, align 8, !tbaa !11
  %28 = load i64, ptr %15, align 8, !tbaa !11
  %29 = add i64 %28, %27
  store i64 %29, ptr %15, align 8, !tbaa !11
  store i64 6, ptr %16, align 8, !tbaa !11
  %30 = load i64, ptr %16, align 8, !tbaa !11
  %31 = and i64 %30, 63
  %32 = load i64, ptr %15, align 8, !tbaa !11
  %33 = lshr i64 %32, %31
  store i64 %33, ptr %15, align 8, !tbaa !11
  %34 = load i64, ptr %15, align 8, !tbaa !11
  %35 = trunc i64 %34 to i32
  store i32 %35, ptr %11, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %36, ptr %8, align 4, !tbaa !9
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  store i32 %40, ptr %11, align 4, !tbaa !9
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %2
  br label %120

44:                                               ; preds = %2
  %45 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %45, ptr %11, align 4, !tbaa !9
  store i32 6, ptr %12, align 4, !tbaa !9
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = and i32 %46, 31
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = shl i32 %48, %47
  store i32 %49, ptr %11, align 4, !tbaa !9
  %50 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %50, ptr %5, align 4, !tbaa !9
  %51 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %51, ptr %11, align 4, !tbaa !9
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.w2c_hermes, ptr %52, i32 0, i32 6
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = call i32 @i32_load(ptr noundef %53, i64 noundef %55)
  store i32 %56, ptr %11, align 4, !tbaa !9
  %57 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %57, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  %58 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %58, ptr %4, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %99, %44
  %60 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %60, ptr %11, align 4, !tbaa !9
  %61 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %61, ptr %12, align 4, !tbaa !9
  store i32 3, ptr %13, align 4, !tbaa !9
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = and i32 %62, 31
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = shl i32 %64, %63
  store i32 %65, ptr %12, align 4, !tbaa !9
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = add i32 %67, %66
  store i32 %68, ptr %11, align 4, !tbaa !9
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.w2c_hermes, ptr %69, i32 0, i32 6
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = zext i32 %71 to i64
  %73 = call i64 @i64_load(ptr noundef %70, i64 noundef %72)
  store i64 %73, ptr %15, align 8, !tbaa !11
  %74 = load i64, ptr %15, align 8, !tbaa !11
  store i64 %74, ptr %10, align 8, !tbaa !11
  %75 = load i64, ptr %15, align 8, !tbaa !11
  %76 = icmp ne i64 %75, 0
  %77 = xor i1 %76, true
  %78 = zext i1 %77 to i32
  store i32 %78, ptr %11, align 4, !tbaa !9
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %101

81:                                               ; preds = %59
  %82 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %82, ptr %11, align 4, !tbaa !9
  store i32 -64, ptr %12, align 4, !tbaa !9
  %83 = load i32, ptr %12, align 4, !tbaa !9
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = sub i32 %84, %83
  store i32 %85, ptr %11, align 4, !tbaa !9
  %86 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %86, ptr %6, align 4, !tbaa !9
  %87 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %87, ptr %11, align 4, !tbaa !9
  store i32 1, ptr %12, align 4, !tbaa !9
  %88 = load i32, ptr %12, align 4, !tbaa !9
  %89 = load i32, ptr %11, align 4, !tbaa !9
  %90 = add i32 %89, %88
  store i32 %90, ptr %11, align 4, !tbaa !9
  %91 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %91, ptr %4, align 4, !tbaa !9
  %92 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %92, ptr %12, align 4, !tbaa !9
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = icmp ne i32 %93, %94
  %96 = zext i1 %95 to i32
  store i32 %96, ptr %11, align 4, !tbaa !9
  %97 = load i32, ptr %11, align 4, !tbaa !9
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %81
  br label %59

100:                                              ; preds = %81
  br label %120

101:                                              ; preds = %59
  %102 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %102, ptr %11, align 4, !tbaa !9
  %103 = load i64, ptr %10, align 8, !tbaa !11
  store i64 %103, ptr %16, align 8, !tbaa !11
  %104 = load i64, ptr %16, align 8, !tbaa !11
  %105 = icmp ne i64 %104, 0
  br i1 %105, label %106, label %110

106:                                              ; preds = %101
  %107 = load i64, ptr %16, align 8, !tbaa !11
  %108 = call i64 @llvm.cttz.i64(i64 %107, i1 true)
  %109 = trunc i64 %108 to i32
  br label %111

110:                                              ; preds = %101
  br label %111

111:                                              ; preds = %110, %106
  %112 = phi i32 [ %109, %106 ], [ 64, %110 ]
  %113 = sext i32 %112 to i64
  store i64 %113, ptr %16, align 8, !tbaa !11
  %114 = load i64, ptr %16, align 8, !tbaa !11
  %115 = trunc i64 %114 to i32
  store i32 %115, ptr %12, align 4, !tbaa !9
  %116 = load i32, ptr %12, align 4, !tbaa !9
  %117 = load i32, ptr %11, align 4, !tbaa !9
  %118 = or i32 %117, %116
  store i32 %118, ptr %11, align 4, !tbaa !9
  %119 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %119, ptr %5, align 4, !tbaa !9
  br label %120

120:                                              ; preds = %111, %100, %43
  %121 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %121, ptr %11, align 4, !tbaa !9
  %122 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %122, ptr %12, align 4, !tbaa !9
  %123 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %123, ptr %13, align 4, !tbaa !9
  %124 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %124, ptr %14, align 4, !tbaa !9
  %125 = load i32, ptr %13, align 4, !tbaa !9
  %126 = load i32, ptr %14, align 4, !tbaa !9
  %127 = icmp ugt i32 %125, %126
  %128 = zext i1 %127 to i32
  store i32 %128, ptr %13, align 4, !tbaa !9
  %129 = load i32, ptr %13, align 4, !tbaa !9
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %133

131:                                              ; preds = %120
  %132 = load i32, ptr %11, align 4, !tbaa !9
  br label %135

133:                                              ; preds = %120
  %134 = load i32, ptr %12, align 4, !tbaa !9
  br label %135

135:                                              ; preds = %133, %131
  %136 = phi i32 [ %132, %131 ], [ %134, %133 ]
  store i32 %136, ptr %11, align 4, !tbaa !9
  %137 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %137
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; 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: inlinehint nounwind uwtable
declare hidden i32 @i32_load(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @i64_load(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_llvh0x3A0x3AAPInt0x3A0x3AcountTrailingZerosSlowCase0x280x290x20const(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = zext i32 %1 to i64
  %5 = add nuw nsw i64 %4, 8
  %6 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %5)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.loopexit, label %7

7:                                                ; preds = %2
  %8 = zext i32 %6 to i64
  %9 = add nuw nsw i64 %8, 63
  %10 = lshr i64 %9, 6
  %11 = trunc nuw nsw i64 %10 to i32
  %12 = shl i32 %11, 6
  %13 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %4)
  br label %14

14:                                               ; preds = %19, %7
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ 0, %7 ]
  %.062 = phi i32 [ %20, %19 ], [ 0, %7 ]
  %indvars.iv.tr = trunc i64 %indvars.iv to i32
  %15 = shl i32 %indvars.iv.tr, 3
  %16 = add i32 %15, %13
  %17 = zext i32 %16 to i64
  %18 = tail call i64 @i64_load(ptr noundef nonnull %3, i64 noundef %17)
  %.not65 = icmp eq i64 %18, 0
  br i1 %.not65, label %19, label %21

19:                                               ; preds = %14
  %20 = add i32 %.062, 64
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not66 = icmp eq i64 %indvars.iv.next, %10
  br i1 %.not66, label %.loopexit, label %14

21:                                               ; preds = %14
  %22 = tail call range(i64 0, 65) i64 @llvm.cttz.i64(i64 %18, i1 true)
  %23 = trunc nuw nsw i64 %22 to i32
  %24 = or disjoint i32 %.062, %23
  br label %.loopexit

.loopexit:                                        ; preds = %19, %2, %21
  %.063 = phi i32 [ 0, %2 ], [ %24, %21 ], [ %12, %19 ]
  %25 = tail call i32 @llvm.umin.i32(i32 %.063, i32 %6)
  ret i32 %25
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

attributes #0 = { inlinehint 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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass