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

45:                                               ; preds = %2
  br label %125

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

61:                                               ; preds = %123, %46
  %62 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %62, ptr %12, align 4, !tbaa !9
  %63 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %63, ptr %13, align 4, !tbaa !9
  store i32 1, ptr %14, align 4, !tbaa !9
  %64 = load i32, ptr %14, align 4, !tbaa !9
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = sub i32 %65, %64
  store i32 %66, ptr %13, align 4, !tbaa !9
  %67 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %67, ptr %9, align 4, !tbaa !9
  store i32 3, ptr %14, align 4, !tbaa !9
  %68 = load i32, ptr %14, align 4, !tbaa !9
  %69 = and i32 %68, 31
  %70 = load i32, ptr %13, align 4, !tbaa !9
  %71 = shl i32 %70, %69
  store i32 %71, ptr %13, align 4, !tbaa !9
  %72 = load i32, ptr %13, align 4, !tbaa !9
  %73 = load i32, ptr %12, align 4, !tbaa !9
  %74 = add i32 %73, %72
  store i32 %74, ptr %12, align 4, !tbaa !9
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.w2c_hermes, ptr %75, i32 0, i32 6
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = zext i32 %77 to i64
  %79 = call i64 @i64_load(ptr noundef %76, i64 noundef %78)
  store i64 %79, ptr %17, align 8, !tbaa !11
  %80 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %80, ptr %11, align 8, !tbaa !11
  store i64 0, ptr %18, align 8, !tbaa !11
  %81 = load i64, ptr %17, align 8, !tbaa !11
  %82 = load i64, ptr %18, align 8, !tbaa !11
  %83 = icmp ne i64 %81, %82
  %84 = zext i1 %83 to i32
  store i32 %84, ptr %12, align 4, !tbaa !9
  %85 = load i32, ptr %12, align 4, !tbaa !9
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %106

87:                                               ; preds = %61
  %88 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %88, ptr %12, align 4, !tbaa !9
  %89 = load i64, ptr %11, align 8, !tbaa !11
  store i64 %89, ptr %18, align 8, !tbaa !11
  %90 = load i64, ptr %18, align 8, !tbaa !11
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %92, label %96

92:                                               ; preds = %87
  %93 = load i64, ptr %18, align 8, !tbaa !11
  %94 = call i64 @llvm.ctlz.i64(i64 %93, i1 true)
  %95 = trunc i64 %94 to i32
  br label %97

96:                                               ; preds = %87
  br label %97

97:                                               ; preds = %96, %92
  %98 = phi i32 [ %95, %92 ], [ 64, %96 ]
  %99 = sext i32 %98 to i64
  store i64 %99, ptr %18, align 8, !tbaa !11
  %100 = load i64, ptr %18, align 8, !tbaa !11
  %101 = trunc i64 %100 to i32
  store i32 %101, ptr %13, align 4, !tbaa !9
  %102 = load i32, ptr %13, align 4, !tbaa !9
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = or i32 %103, %102
  store i32 %104, ptr %12, align 4, !tbaa !9
  %105 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %105, ptr %6, align 4, !tbaa !9
  br label %125

106:                                              ; preds = %61
  %107 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %107, ptr %12, align 4, !tbaa !9
  store i32 -64, ptr %13, align 4, !tbaa !9
  %108 = load i32, ptr %13, align 4, !tbaa !9
  %109 = load i32, ptr %12, align 4, !tbaa !9
  %110 = sub i32 %109, %108
  store i32 %110, ptr %12, align 4, !tbaa !9
  %111 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %111, ptr %4, align 4, !tbaa !9
  %112 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %112, ptr %12, align 4, !tbaa !9
  store i32 1, ptr %13, align 4, !tbaa !9
  %113 = load i32, ptr %12, align 4, !tbaa !9
  %114 = load i32, ptr %13, align 4, !tbaa !9
  %115 = icmp ugt i32 %113, %114
  %116 = zext i1 %115 to i32
  store i32 %116, ptr %12, align 4, !tbaa !9
  %117 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %117, ptr %10, align 4, !tbaa !9
  %118 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %118, ptr %12, align 4, !tbaa !9
  %119 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %119, ptr %5, align 4, !tbaa !9
  %120 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %120, ptr %12, align 4, !tbaa !9
  %121 = load i32, ptr %12, align 4, !tbaa !9
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %124

123:                                              ; preds = %106
  br label %61

124:                                              ; preds = %106
  br label %125

125:                                              ; preds = %124, %97, %45
  %126 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %126, ptr %12, align 4, !tbaa !9
  %127 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %127, ptr %13, align 4, !tbaa !9
  store i32 -64, ptr %14, align 4, !tbaa !9
  %128 = load i32, ptr %14, align 4, !tbaa !9
  %129 = load i32, ptr %13, align 4, !tbaa !9
  %130 = or i32 %129, %128
  store i32 %130, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %14, align 4, !tbaa !9
  %131 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %131, ptr %15, align 4, !tbaa !9
  store i32 63, ptr %16, align 4, !tbaa !9
  %132 = load i32, ptr %16, align 4, !tbaa !9
  %133 = load i32, ptr %15, align 4, !tbaa !9
  %134 = and i32 %133, %132
  store i32 %134, ptr %15, align 4, !tbaa !9
  %135 = load i32, ptr %15, align 4, !tbaa !9
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %137, label %139

137:                                              ; preds = %125
  %138 = load i32, ptr %13, align 4, !tbaa !9
  br label %141

139:                                              ; preds = %125
  %140 = load i32, ptr %14, align 4, !tbaa !9
  br label %141

141:                                              ; preds = %139, %137
  %142 = phi i32 [ %138, %137 ], [ %140, %139 ]
  store i32 %142, ptr %13, align 4, !tbaa !9
  %143 = load i32, ptr %13, align 4, !tbaa !9
  %144 = load i32, ptr %12, align 4, !tbaa !9
  %145 = add i32 %144, %143
  store i32 %145, ptr %12, align 4, !tbaa !9
  %146 = load i32, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, 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 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, 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 %146
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.ctlz.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_llvh0x3A0x3AAPInt0x3A0x3AcountLeadingZerosSlowCase0x280x290x20const(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 = %23, %7
  %indvars.iv = phi i64 [ %indvars.iv.next, %23 ], [ %10, %7 ]
  %.0 = phi i32 [ %24, %23 ], [ 0, %7 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %indvars = trunc i64 %indvars.iv.next to i32
  %15 = shl i32 %indvars, 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)
  %.not72 = icmp eq i64 %18, 0
  br i1 %.not72, label %23, label %19

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

23:                                               ; preds = %14
  %24 = add i32 %.0, 64
  %25 = icmp ugt i64 %indvars.iv, 1
  br i1 %25, label %14, label %.loopexit

.loopexit:                                        ; preds = %23, %2, %19
  %.070 = phi i32 [ 0, %2 ], [ %22, %19 ], [ %12, %23 ]
  %26 = or i32 %6, -64
  %27 = and i32 %6, 63
  %.not73 = icmp eq i32 %27, 0
  %28 = select i1 %.not73, i32 0, i32 %26
  %29 = add i32 %.070, %28
  ret i32 %29
}

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

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

!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,SROAPass,SimplifyCFGPass,TailCallElimPass