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

; 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: noreturn
declare void @wasm_rt_trap(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AAlignedStorage0x3A0x3A0x7EAlignedStorage0x280x29(ptr noundef, i32 noundef) #3

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

24:                                               ; preds = %2
  br label %72

25:                                               ; preds = %2
  %26 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %26, ptr %8, align 4, !tbaa !9
  store i32 81920, ptr %9, align 4, !tbaa !9
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = add i32 %28, %27
  store i32 %29, ptr %8, align 4, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %30, ptr %6, align 4, !tbaa !9
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = call i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Apage_size0x280x29(ptr noundef %31)
  store i32 %32, ptr %9, align 4, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %33, ptr %5, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 0
  %36 = xor i1 %35, true
  %37 = xor i1 %36, true
  %38 = zext i1 %37 to i32
  %39 = sext i32 %38 to i64
  %40 = call i64 @llvm.expect.i64(i64 %39, i64 0)
  %41 = icmp ne i64 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %25
  call void @wasm_rt_trap(i32 noundef 3) #7
  unreachable

43:                                               ; No predecessors!
  br label %48

44:                                               ; preds = %25
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = urem i32 %45, %46
  br label %48

48:                                               ; preds = %44, %43
  %49 = phi i32 [ 0, %43 ], [ %47, %44 ]
  store i32 %49, ptr %8, align 4, !tbaa !9
  %50 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %50, ptr %7, align 4, !tbaa !9
  %51 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %51, ptr %8, align 4, !tbaa !9
  store i32 4096, ptr %9, align 4, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = icmp ugt i32 %52, %53
  %55 = zext i1 %54 to i32
  store i32 %55, ptr %8, align 4, !tbaa !9
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %48
  br label %72

59:                                               ; preds = %48
  %60 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %60, ptr %8, align 4, !tbaa !9
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %59
  br label %72

64:                                               ; preds = %59
  %65 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %65, ptr %8, align 4, !tbaa !9
  %66 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %66, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !9
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = call i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Avm_protect0x28void0x2A0x2C0x20unsigned0x20long0x2C0x20hermes0x3A0x3Aoscompat0x3A0x3AProtectMode0x29(ptr noundef %67, i32 noundef %68, i32 noundef %69, i32 noundef %70)
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %64, %63, %58, %24
  %73 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %73, ptr %8, align 4, !tbaa !9
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = call i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AAlignedStorage0x3A0x3A0x7EAlignedStorage0x280x29(ptr noundef %74, i32 noundef %75)
  store i32 %76, ptr %8, align 4, !tbaa !9
  %77 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret i32 %77
}

declare i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Apage_size0x280x29(ptr noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #5

declare i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Avm_protect0x28void0x2A0x2C0x20unsigned0x20long0x2C0x20hermes0x3A0x3Aoscompat0x3A0x3AProtectMode0x29(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 = { 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 #3 = { 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 #4 = { "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 #5 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { noreturn }

!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: noreturn
declare void @wasm_rt_trap(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AAlignedStorage0x3A0x3A0x7EAlignedStorage0x280x29(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AAlignedHeapSegment0x3A0x3A0x7EAlignedHeapSegment0x280x29(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %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)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %17, label %6

6:                                                ; preds = %2
  %7 = add i32 %5, 81920
  %8 = tail call i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Apage_size0x280x29(ptr noundef %0) #4
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %11, !prof !5

10:                                               ; preds = %6
  tail call void @wasm_rt_trap(i32 noundef 3) #5
  unreachable

11:                                               ; preds = %6
  %12 = icmp ugt i32 %8, 4096
  br i1 %12, label %17, label %13

13:                                               ; preds = %11
  %14 = urem i32 %7, %8
  %.not31 = icmp eq i32 %14, 0
  br i1 %.not31, label %15, label %17

15:                                               ; preds = %13
  %16 = tail call i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Avm_protect0x28void0x2A0x2C0x20unsigned0x20long0x2C0x20hermes0x3A0x3Aoscompat0x3A0x3AProtectMode0x29(ptr noundef %0, i32 noundef %7, i32 noundef %8, i32 noundef 0) #4
  br label %17

17:                                               ; preds = %13, %11, %2, %15
  %18 = tail call i32 @w2c_hermes_hermes0x3A0x3Avm0x3A0x3AAlignedStorage0x3A0x3A0x7EAlignedStorage0x280x29(ptr noundef %0, i32 noundef %1)
  ret i32 %18
}

declare i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Apage_size0x280x29(ptr noundef) local_unnamed_addr #3

declare i32 @w2c_hermes_hermes0x3A0x3Aoscompat0x3A0x3Avm_protect0x28void0x2A0x2C0x20unsigned0x20long0x2C0x20hermes0x3A0x3Aoscompat0x3A0x3AProtectMode0x29(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { noreturn "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 = { 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 }
attributes #5 = { noreturn 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass