; 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: nounwind uwtable
declare dso_local i32 @w2c_hermes_0x5F_errno_location_0(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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

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

32:                                               ; preds = %3
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @w2c_hermes_0x5F_errno_location_0(ptr noundef %33)
  store i32 %34, ptr %9, align 4, !tbaa !9
  store i32 28, ptr %10, align 4, !tbaa !9
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.w2c_hermes, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = load i32, ptr %10, align 4, !tbaa !9
  call void @i32_store(ptr noundef %36, i64 noundef %38, i32 noundef %39)
  store i32 -1, ptr %9, align 4, !tbaa !9
  br label %102

40:                                               ; preds = %3
  store i32 -1, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %41, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %42, ptr %10, align 4, !tbaa !9
  store i64 1, ptr %14, align 8, !tbaa !17
  %43 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %43, ptr %11, align 4, !tbaa !9
  store i32 24, ptr %12, align 4, !tbaa !9
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = add i32 %45, %44
  store i32 %46, ptr %11, align 4, !tbaa !9
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.w2c_hermes, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = load i64, ptr %14, align 8, !tbaa !17
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = call i32 @w2c_wasi__snapshot__preview1_clock_time_get(ptr noundef %49, i32 noundef %50, i64 noundef %51, i32 noundef %52)
  store i32 %53, ptr %10, align 4, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = call i32 @w2c_hermes_0x5F_wasi_syscall_ret(ptr noundef %54, i32 noundef %55)
  store i32 %56, ptr %10, align 4, !tbaa !9
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %40
  br label %102

60:                                               ; preds = %40
  %61 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %61, ptr %9, align 4, !tbaa !9
  store i32 8, ptr %10, align 4, !tbaa !9
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = add i32 %63, %62
  store i32 %64, ptr %9, align 4, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %65, ptr %10, align 4, !tbaa !9
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.w2c_hermes, ptr %66, i32 0, i32 6
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = add i64 %69, 24
  %71 = call i64 @i64_load(ptr noundef %67, i64 noundef %70)
  store i64 %71, ptr %13, align 8, !tbaa !17
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = load i64, ptr %13, align 8, !tbaa !17
  call void @w2c_hermes_0x5F_wasi_timestamp_to_timespec(ptr noundef %72, i32 noundef %73, i64 noundef %74)
  %75 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %75, ptr %9, align 4, !tbaa !9
  %76 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %76, ptr %10, align 4, !tbaa !9
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.w2c_hermes, ptr %77, i32 0, i32 6
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = add i64 %80, 16
  %82 = call i64 @i64_load(ptr noundef %78, i64 noundef %81)
  store i64 %82, ptr %13, align 8, !tbaa !17
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.w2c_hermes, ptr %83, i32 0, i32 6
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = zext i32 %85 to i64
  %87 = add i64 %86, 8
  %88 = load i64, ptr %13, align 8, !tbaa !17
  call void @i64_store(ptr noundef %84, i64 noundef %87, i64 noundef %88)
  %89 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %89, ptr %9, align 4, !tbaa !9
  %90 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %90, ptr %10, align 4, !tbaa !9
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.w2c_hermes, ptr %91, i32 0, i32 6
  %93 = load i32, ptr %10, align 4, !tbaa !9
  %94 = zext i32 %93 to i64
  %95 = add i64 %94, 8
  %96 = call i64 @i64_load(ptr noundef %92, i64 noundef %95)
  store i64 %96, ptr %13, align 8, !tbaa !17
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.w2c_hermes, ptr %97, i32 0, i32 6
  %99 = load i32, ptr %9, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = load i64, ptr %13, align 8, !tbaa !17
  call void @i64_store(ptr noundef %98, i64 noundef %100, i64 noundef %101)
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %60, %59, %32
  %103 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %103, ptr %8, align 4, !tbaa !9
  %104 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %104, ptr %9, align 4, !tbaa !9
  store i32 32, ptr %10, align 4, !tbaa !9
  %105 = load i32, ptr %10, align 4, !tbaa !9
  %106 = load i32, ptr %9, align 4, !tbaa !9
  %107 = add i32 %106, %105
  store i32 %107, ptr %9, align 4, !tbaa !9
  %108 = load i32, ptr %9, align 4, !tbaa !9
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.w2c_hermes, ptr %109, i32 0, i32 3
  store i32 %108, ptr %110, align 8, !tbaa !11
  %111 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %111, ptr %9, align 4, !tbaa !9
  %112 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  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
  ret i32 %112
}

declare i32 @w2c_wasi__snapshot__preview1_clock_time_get(ptr noundef, i32 noundef, i64 noundef, i32 noundef) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_0x5F_wasi_timestamp_to_timespec(ptr noundef, i32 noundef, i64 noundef) #0

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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}
!11 = !{!12, !10, i64 24}
!12 = !{!"w2c_hermes", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !13, i64 40, !16, i64 80}
!13 = !{!"", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !15, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!14, !14, i64 0}
!18 = !{!12, !6, i64 16}


; 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: nounwind uwtable
declare dso_local i32 @w2c_hermes_0x5F_errno_location_0(ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @w2c_hermes_0x5F_clock_gettime(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = add i32 %5, -32
  store i32 %6, ptr %4, align 8, !tbaa !5
  %7 = icmp ugt i32 %1, 3
  br i1 %7, label %8, label %12

8:                                                ; preds = %3
  %9 = tail call i32 @w2c_hermes_0x5F_errno_location_0(ptr noundef nonnull %0)
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = zext i32 %9 to i64
  tail call void @i32_store(ptr noundef nonnull %10, i64 noundef %11, i32 noundef 28)
  br label %30

12:                                               ; preds = %3
  %13 = add i32 %5, -8
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = tail call i32 @w2c_wasi__snapshot__preview1_clock_time_get(ptr noundef %15, i32 noundef %1, i64 noundef 1, i32 noundef %13) #3
  %17 = tail call i32 @w2c_hermes_0x5F_wasi_syscall_ret(ptr noundef nonnull %0, i32 noundef %16)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %30

18:                                               ; preds = %12
  %19 = add i32 %5, -24
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = zext i32 %6 to i64
  %22 = add nuw nsw i64 %21, 24
  %23 = tail call i64 @i64_load(ptr noundef nonnull %20, i64 noundef %22)
  tail call void @w2c_hermes_0x5F_wasi_timestamp_to_timespec(ptr noundef nonnull %0, i32 noundef %19, i64 noundef %23)
  %24 = add nuw nsw i64 %21, 16
  %25 = tail call i64 @i64_load(ptr noundef nonnull %20, i64 noundef %24)
  %26 = zext i32 %2 to i64
  %27 = add nuw nsw i64 %26, 8
  tail call void @i64_store(ptr noundef nonnull %20, i64 noundef %27, i64 noundef %25)
  %28 = add nuw nsw i64 %21, 8
  %29 = tail call i64 @i64_load(ptr noundef nonnull %20, i64 noundef %28)
  tail call void @i64_store(ptr noundef nonnull %20, i64 noundef %26, i64 noundef %29)
  br label %30

30:                                               ; preds = %12, %18, %8
  %.0 = phi i32 [ -1, %8 ], [ -1, %12 ], [ 0, %18 ]
  store i32 %5, ptr %4, align 8, !tbaa !5
  ret i32 %.0
}

declare i32 @w2c_wasi__snapshot__preview1_clock_time_get(ptr noundef, i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @w2c_hermes_0x5F_wasi_timestamp_to_timespec(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

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

attributes #0 = { 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 = { 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 = { "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, !10, i64 24}
!6 = !{!"w2c_hermes", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 40, !14, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !13, i64 32}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!6, !7, i64 16}


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