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

; 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: inlinehint nounwind uwtable
declare hidden i64 @i64_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: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3Abigint0x3A0x3AisSingleDigitTruncationLossless0x28hermes0x3A0x3Abigint0x3A0x3AImmutableBigIntRef0x2C0x20bool0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %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 i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %12 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %12, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.w2c_hermes, ptr %13, i32 0, i32 6
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = zext i32 %15 to i64
  %17 = add i64 %16, 4
  %18 = call i32 @i32_load(ptr noundef %14, i64 noundef %17)
  store i32 %18, ptr %8, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %19, ptr %7, align 4, !tbaa !9
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  %22 = xor i1 %21, true
  %23 = zext i1 %22 to i32
  store i32 %23, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %3
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %85

27:                                               ; preds = %3
  %28 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %28, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %37

31:                                               ; preds = %27
  %32 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %32, ptr %8, align 4, !tbaa !9
  store i32 1, ptr %9, align 4, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp eq i32 %33, %34
  %36 = zext i1 %35 to i32
  store i32 %36, ptr %8, align 4, !tbaa !9
  br label %85

37:                                               ; preds = %27
  store i32 0, ptr %8, align 4, !tbaa !9
  %38 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %38, ptr %6, align 4, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %39, ptr %8, align 4, !tbaa !9
  store i32 1, ptr %9, align 4, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = sub i32 %41, %40
  store i32 %42, ptr %8, align 4, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %43, label %46 [
    i32 0, label %44
    i32 1, label %45
  ]

44:                                               ; preds = %37
  br label %47

45:                                               ; preds = %37
  br label %65

46:                                               ; preds = %37
  br label %83

47:                                               ; preds = %44
  %48 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %48, ptr %8, align 4, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.w2c_hermes, ptr %49, i32 0, i32 6
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = call i32 @i32_load(ptr noundef %50, i64 noundef %52)
  store i32 %53, ptr %8, align 4, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.w2c_hermes, ptr %54, i32 0, i32 6
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = call i64 @i64_load(ptr noundef %55, i64 noundef %57)
  store i64 %58, ptr %10, align 8, !tbaa !11
  store i64 0, ptr %11, align 8, !tbaa !11
  %59 = load i64, ptr %10, align 8, !tbaa !11
  %60 = load i64, ptr %11, align 8, !tbaa !11
  %61 = icmp sge i64 %59, %60
  %62 = zext i1 %61 to i32
  %63 = sext i32 %62 to i64
  %64 = trunc i64 %63 to i32
  store i32 %64, ptr %8, align 4, !tbaa !9
  br label %85

65:                                               ; preds = %45
  %66 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %66, ptr %8, align 4, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.w2c_hermes, ptr %67, i32 0, i32 6
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = call i32 @i32_load(ptr noundef %68, i64 noundef %70)
  store i32 %71, ptr %8, align 4, !tbaa !9
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.w2c_hermes, ptr %72, i32 0, i32 6
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = add i64 %75, 8
  %77 = call i64 @i64_load(ptr noundef %73, i64 noundef %76)
  store i64 %77, ptr %10, align 8, !tbaa !11
  %78 = load i64, ptr %10, align 8, !tbaa !11
  %79 = icmp ne i64 %78, 0
  %80 = xor i1 %79, true
  %81 = zext i1 %80 to i32
  store i32 %81, ptr %8, align 4, !tbaa !9
  %82 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %82, ptr %6, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %65, %46
  %84 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %84, ptr %8, align 4, !tbaa !9
  br label %85

85:                                               ; preds = %83, %47, %31, %26
  %86 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %86
}

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 = { 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 range(i32 0, 2) i32 @w2c_hermes_hermes0x3A0x3Abigint0x3A0x3AisSingleDigitTruncationLossless0x28hermes0x3A0x3Abigint0x3A0x3AImmutableBigIntRef0x2C0x20bool0x29(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = zext i32 %1 to i64
  %6 = add nuw nsw i64 %5, 4
  %7 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %6)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %22, label %8

8:                                                ; preds = %3
  %.not32 = icmp eq i32 %2, 0
  br i1 %.not32, label %11, label %9

9:                                                ; preds = %8
  %10 = icmp eq i32 %7, 1
  br label %22

11:                                               ; preds = %8
  switch i32 %7, label %22 [
    i32 1, label %12
    i32 2, label %17
  ]

12:                                               ; preds = %11
  %13 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %5)
  %14 = zext i32 %13 to i64
  %15 = tail call i64 @i64_load(ptr noundef nonnull %4, i64 noundef %14)
  %16 = icmp sgt i64 %15, -1
  br label %22

17:                                               ; preds = %11
  %18 = tail call i32 @i32_load(ptr noundef nonnull %4, i64 noundef %5)
  %19 = zext i32 %18 to i64
  %20 = add nuw nsw i64 %19, 8
  %21 = tail call i64 @i64_load(ptr noundef nonnull %4, i64 noundef %20)
  %.not33 = icmp eq i64 %21, 0
  br label %22

22:                                               ; preds = %17, %11, %3, %12, %9
  %.031.shrunk = phi i1 [ %10, %9 ], [ %16, %12 ], [ true, %3 ], [ false, %11 ], [ %.not33, %17 ]
  %.031 = zext i1 %.031.shrunk to i32
  ret i32 %.031
}

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

!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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass