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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_0x5F_unlockfile(ptr noundef, i32 noundef) #4

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

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

35:                                               ; preds = %5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %36, ptr %13, align 4, !tbaa !9
  %37 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %37, ptr %14, align 4, !tbaa !9
  %38 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %38, ptr %15, align 4, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %13, align 4, !tbaa !9
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = load i32, ptr %15, align 4, !tbaa !9
  %43 = call i32 @w2c_hermes_0x5F_fwritex(ptr noundef %39, i32 noundef %40, i32 noundef %41, i32 noundef %42)
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %44, ptr %7, align 4, !tbaa !9
  br label %72

45:                                               ; preds = %5
  %46 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %46, ptr %13, align 4, !tbaa !9
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = call i32 @w2c_hermes_0x5F_lockfile(ptr noundef %47, i32 noundef %48)
  store i32 %49, ptr %13, align 4, !tbaa !9
  %50 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %50, ptr %12, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %51, ptr %13, align 4, !tbaa !9
  %52 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %52, ptr %14, align 4, !tbaa !9
  %53 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %53, ptr %15, align 4, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = load i32, ptr %14, align 4, !tbaa !9
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = call i32 @w2c_hermes_0x5F_fwritex(ptr noundef %54, i32 noundef %55, i32 noundef %56, i32 noundef %57)
  store i32 %58, ptr %13, align 4, !tbaa !9
  %59 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %59, ptr %7, align 4, !tbaa !9
  %60 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %60, ptr %13, align 4, !tbaa !9
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = icmp ne i32 %61, 0
  %63 = xor i1 %62, true
  %64 = zext i1 %63 to i32
  store i32 %64, ptr %13, align 4, !tbaa !9
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %45
  br label %72

68:                                               ; preds = %45
  %69 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %69, ptr %13, align 4, !tbaa !9
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i32, ptr %13, align 4, !tbaa !9
  call void @w2c_hermes_0x5F_unlockfile(ptr noundef %70, i32 noundef %71)
  br label %72

72:                                               ; preds = %68, %67, %35
  %73 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %73, ptr %13, align 4, !tbaa !9
  %74 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %74, ptr %14, align 4, !tbaa !9
  %75 = load i32, ptr %13, align 4, !tbaa !9
  %76 = load i32, ptr %14, align 4, !tbaa !9
  %77 = icmp eq i32 %75, %76
  %78 = zext i1 %77 to i32
  store i32 %78, ptr %13, align 4, !tbaa !9
  %79 = load i32, ptr %13, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %92

81:                                               ; preds = %72
  %82 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %82, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %14, align 4, !tbaa !9
  %83 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %83, ptr %15, align 4, !tbaa !9
  %84 = load i32, ptr %15, align 4, !tbaa !9
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %88

86:                                               ; preds = %81
  %87 = load i32, ptr %13, align 4, !tbaa !9
  br label %90

88:                                               ; preds = %81
  %89 = load i32, ptr %14, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %88, %86
  %91 = phi i32 [ %87, %86 ], [ %89, %88 ]
  store i32 %91, ptr %13, align 4, !tbaa !9
  br label %111

92:                                               ; preds = %72
  %93 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %93, ptr %13, align 4, !tbaa !9
  %94 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %94, ptr %14, align 4, !tbaa !9
  %95 = load i32, ptr %14, align 4, !tbaa !9
  %96 = icmp eq i32 %95, 0
  %97 = xor i1 %96, true
  %98 = xor i1 %97, true
  %99 = zext i1 %98 to i32
  %100 = sext i32 %99 to i64
  %101 = call i64 @llvm.expect.i64(i64 %100, i64 0)
  %102 = icmp ne i64 %101, 0
  br i1 %102, label %103, label %105

103:                                              ; preds = %92
  call void @wasm_rt_trap(i32 noundef 3) #6
  unreachable

104:                                              ; No predecessors!
  br label %109

105:                                              ; preds = %92
  %106 = load i32, ptr %13, align 4, !tbaa !9
  %107 = load i32, ptr %14, align 4, !tbaa !9
  %108 = udiv i32 %106, %107
  br label %109

109:                                              ; preds = %105, %104
  %110 = phi i32 [ 0, %104 ], [ %108, %105 ]
  store i32 %110, ptr %13, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %109, %90
  %112 = load i32, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret i32 %112
}

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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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_0x5F_lockfile(ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @w2c_hermes_fwrite(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  %6 = mul i32 %3, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = zext i32 %4 to i64
  %9 = add nuw nsw i64 %8, 76
  %10 = tail call i32 @i32_load(ptr noundef nonnull %7, i64 noundef %9)
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %5
  %13 = tail call i32 @w2c_hermes_0x5F_fwritex(ptr noundef %0, i32 noundef %1, i32 noundef %6, i32 noundef %4)
  br label %18

14:                                               ; preds = %5
  %15 = tail call i32 @w2c_hermes_0x5F_lockfile(ptr noundef %0, i32 noundef %4)
  %16 = tail call i32 @w2c_hermes_0x5F_fwritex(ptr noundef %0, i32 noundef %1, i32 noundef %6, i32 noundef %4)
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %18, label %17

17:                                               ; preds = %14
  tail call void @w2c_hermes_0x5F_unlockfile(ptr noundef %0, i32 noundef %4)
  br label %18

18:                                               ; preds = %14, %17, %12
  %.052 = phi i32 [ %13, %12 ], [ %16, %14 ], [ %16, %17 ]
  %19 = icmp eq i32 %.052, %6
  %.not54 = icmp eq i32 %2, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = select i1 %.not54, i32 0, i32 %3
  br label %26

22:                                               ; preds = %18
  br i1 %.not54, label %23, label %24, !prof !5

23:                                               ; preds = %22
  tail call void @wasm_rt_trap(i32 noundef 3) #3
  unreachable

24:                                               ; preds = %22
  %25 = udiv i32 %.052, %2
  br label %26

26:                                               ; preds = %24, %20
  %.0 = phi i32 [ %21, %20 ], [ %25, %24 ]
  ret i32 %.0
}

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 = { 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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass