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

; 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: 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 void @i32_store(ptr noundef, i64 noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_getint(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 i32, align 4
  %12 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %13 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %13, ptr %8, align 4, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.w2c_hermes, ptr %14, i32 0, i32 6
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = call i32 @i32_load(ptr noundef %15, i64 noundef %17)
  store i32 %18, ptr %8, align 4, !tbaa !9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.w2c_hermes, ptr %19, i32 0, i32 6
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = call i32 @i32_load8_s(ptr noundef %20, i64 noundef %22)
  store i32 %23, ptr %8, align 4, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = call i32 @w2c_hermes_isdigit(ptr noundef %24, i32 noundef %25)
  store i32 %26, ptr %8, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  %29 = xor i1 %28, true
  %30 = zext i1 %29 to i32
  store i32 %30, ptr %8, align 4, !tbaa !9
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %2
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %116

34:                                               ; preds = %2
  br label %35

35:                                               ; preds = %113, %34
  %36 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %36, ptr %8, align 4, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.w2c_hermes, ptr %37, i32 0, i32 6
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = call i32 @i32_load(ptr noundef %38, i64 noundef %40)
  store i32 %41, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %42, ptr %7, align 4, !tbaa !9
  store i32 -1, ptr %8, align 4, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %43, ptr %5, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %44, ptr %8, align 4, !tbaa !9
  store i32 214748364, ptr %9, align 4, !tbaa !9
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = icmp ule i32 %45, %46
  %48 = zext i1 %47 to i32
  store i32 %48, ptr %8, align 4, !tbaa !9
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %88

51:                                               ; preds = %35
  store i32 -1, ptr %8, align 4, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %52, ptr %9, align 4, !tbaa !9
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.w2c_hermes, ptr %53, i32 0, i32 6
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = call i32 @i32_load8_s(ptr noundef %54, i64 noundef %56)
  store i32 %57, ptr %9, align 4, !tbaa !9
  store i32 48, ptr %10, align 4, !tbaa !9
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = sub i32 %59, %58
  store i32 %60, ptr %9, align 4, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %61, ptr %5, align 4, !tbaa !9
  %62 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %62, ptr %10, align 4, !tbaa !9
  store i32 10, ptr %11, align 4, !tbaa !9
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = mul i32 %64, %63
  store i32 %65, ptr %10, align 4, !tbaa !9
  %66 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %66, ptr %6, align 4, !tbaa !9
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = add i32 %68, %67
  store i32 %69, ptr %9, align 4, !tbaa !9
  %70 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %70, ptr %10, align 4, !tbaa !9
  %71 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %71, ptr %11, align 4, !tbaa !9
  store i32 2147483647, ptr %12, align 4, !tbaa !9
  %72 = load i32, ptr %12, align 4, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = xor i32 %73, %72
  store i32 %74, ptr %11, align 4, !tbaa !9
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = icmp sgt i32 %75, %76
  %78 = zext i1 %77 to i32
  store i32 %78, ptr %10, align 4, !tbaa !9
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %51
  %82 = load i32, ptr %8, align 4, !tbaa !9
  br label %85

83:                                               ; preds = %51
  %84 = load i32, ptr %9, align 4, !tbaa !9
  br label %85

85:                                               ; preds = %83, %81
  %86 = phi i32 [ %82, %81 ], [ %84, %83 ]
  store i32 %86, ptr %8, align 4, !tbaa !9
  %87 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %87, ptr %5, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %85, %35
  %89 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %89, ptr %8, align 4, !tbaa !9
  %90 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %90, ptr %9, align 4, !tbaa !9
  store i32 1, ptr %10, align 4, !tbaa !9
  %91 = load i32, ptr %10, align 4, !tbaa !9
  %92 = load i32, ptr %9, align 4, !tbaa !9
  %93 = add i32 %92, %91
  store i32 %93, ptr %9, align 4, !tbaa !9
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.w2c_hermes, ptr %94, i32 0, i32 6
  %96 = load i32, ptr %8, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = load i32, ptr %9, align 4, !tbaa !9
  call void @i32_store(ptr noundef %95, i64 noundef %97, i32 noundef %98)
  %99 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %99, ptr %8, align 4, !tbaa !9
  %100 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %100, ptr %6, align 4, !tbaa !9
  %101 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %101, ptr %8, align 4, !tbaa !9
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.w2c_hermes, ptr %102, i32 0, i32 6
  %104 = load i32, ptr %8, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = add i64 %105, 1
  %107 = call i32 @i32_load8_s(ptr noundef %103, i64 noundef %106)
  store i32 %107, ptr %8, align 4, !tbaa !9
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = load i32, ptr %8, align 4, !tbaa !9
  %110 = call i32 @w2c_hermes_isdigit(ptr noundef %108, i32 noundef %109)
  store i32 %110, ptr %8, align 4, !tbaa !9
  %111 = load i32, ptr %8, align 4, !tbaa !9
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %114

113:                                              ; preds = %88
  br label %35

114:                                              ; preds = %88
  %115 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %115, ptr %8, align 4, !tbaa !9
  br label %116

116:                                              ; preds = %114, %33
  %117 = load i32, ptr %8, align 4, !tbaa !9
  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 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 %117
}

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

declare i32 @w2c_hermes_isdigit(ptr noundef, i32 noundef) #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 = { "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 = !{!"int", !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 void @i32_store(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_getint(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 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %4)
  %6 = zext i32 %5 to i64
  %7 = tail call i32 @i32_load8_s(ptr noundef nonnull %3, i64 noundef %6)
  %8 = tail call i32 @w2c_hermes_isdigit(ptr noundef %0, i32 noundef %7) #3
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %2, %.preheader._crit_edge
  %.056 = phi i32 [ %.0, %.preheader._crit_edge ], [ 0, %2 ]
  %9 = tail call i32 @i32_load(ptr noundef nonnull %3, i64 noundef %4)
  %10 = icmp ult i32 %.056, 214748365
  %11 = zext i32 %9 to i64
  br i1 %10, label %12, label %.preheader._crit_edge

12:                                               ; preds = %.preheader
  %13 = tail call i32 @i32_load8_s(ptr noundef nonnull %3, i64 noundef %11)
  %14 = add i32 %13, -48
  %15 = mul nuw nsw i32 %.056, 10
  %16 = add i32 %14, %15
  %17 = xor i32 %15, 2147483647
  %18 = icmp sgt i32 %14, %17
  %19 = select i1 %18, i32 -1, i32 %16
  br label %.preheader._crit_edge

.preheader._crit_edge:                            ; preds = %.preheader, %12
  %.0 = phi i32 [ %19, %12 ], [ -1, %.preheader ]
  %20 = add i32 %9, 1
  tail call void @i32_store(ptr noundef nonnull %3, i64 noundef %4, i32 noundef %20)
  %21 = add nuw nsw i64 %11, 1
  %22 = tail call i32 @i32_load8_s(ptr noundef nonnull %3, i64 noundef %21)
  %23 = tail call i32 @w2c_hermes_isdigit(ptr noundef %0, i32 noundef %22) #3
  %.not58 = icmp eq i32 %23, 0
  br i1 %.not58, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader._crit_edge, %2
  %.057 = phi i32 [ 0, %2 ], [ %.0, %.preheader._crit_edge ]
  ret i32 %.057
}

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

declare i32 @w2c_hermes_isdigit(ptr noundef, i32 noundef) local_unnamed_addr #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 = { "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)"}


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