; LLVM IR from recp/cglm :: test/src (tests)

; 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.test_status_t = type { ptr, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [94 x i8], align 1
@.str.891 = external hidden unnamed_addr constant [65 x i8], align 1
@__const.test_glm_perlin_vec2.p1 = external hidden unnamed_addr constant [10 x [2 x float]], align 16
@__const.test_glm_perlin_vec2.e = external hidden unnamed_addr constant [10 x float], align 16
@.str.894 = external hidden unnamed_addr constant [40 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @test_eq(float noundef, float noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; 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 { ptr, i32 } @test_glm_perlin_vec2() #4 {
  %1 = alloca %struct.test_status_t, align 8
  %2 = alloca [10 x [2 x float]], align 16
  %3 = alloca [10 x float], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 80, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_glm_perlin_vec2.p1, i64 80, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.test_glm_perlin_vec2.e, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %30, %0
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 10
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %5, align 4
  br label %33

10:                                               ; preds = %6
  br label %11

11:                                               ; preds = %10
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [10 x [2 x float]], ptr %2, i64 0, i64 %13
  %15 = getelementptr inbounds [2 x float], ptr %14, i64 0, i64 0
  %16 = call float @glm_perlin_vec2(ptr noundef %15)
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10 x float], ptr %3, i64 0, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = call zeroext i1 @test_eq(float noundef %16, float noundef %20)
  br i1 %21, label %27, label %22

22:                                               ; preds = %11
  %23 = load ptr, ptr @stderr, align 8, !tbaa !11
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str, ptr noundef @.str.891, i32 noundef 110, ptr noundef @.str.894) #5
  %25 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 0
  store ptr null, ptr %25, align 8, !tbaa !13
  %26 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 1
  store i32 0, ptr %26, align 8, !tbaa !15
  store i32 1, ptr %5, align 4
  br label %33

27:                                               ; preds = %11
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !16

33:                                               ; preds = %22, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %34 = load i32, ptr %5, align 4
  switch i32 %34, label %38 [
    i32 2, label %35
  ]

35:                                               ; preds = %33
  %36 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 0
  store ptr null, ptr %36, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 1
  store i32 1, ptr %37, align 8, !tbaa !15
  store i32 1, ptr %5, align 4
  br label %38

38:                                               ; preds = %35, %33
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %2) #5
  %39 = load { ptr, i32 }, ptr %1, align 8
  ret { ptr, i32 } %39
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden float @glm_perlin_vec2(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 "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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"test_status_t", !12, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [94 x i8], align 1
@.str.891 = external hidden unnamed_addr constant [65 x i8], align 1
@__const.test_glm_perlin_vec2.p1 = external hidden unnamed_addr constant [10 x [2 x float]], align 16
@__const.test_glm_perlin_vec2.e = external hidden unnamed_addr constant [10 x float], align 16
@.str.894 = external hidden unnamed_addr constant [40 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @test_eq(float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress 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 { ptr, i32 } @test_glm_perlin_vec2() local_unnamed_addr #4 {
  %1 = alloca [10 x [2 x float]], align 16
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(80) %1, ptr noundef nonnull align 16 dereferenceable(80) @__const.test_glm_perlin_vec2.p1, i64 80, i1 false)
  %2 = call float @glm_perlin_vec2(ptr noundef nonnull %1)
  %3 = load float, ptr @__const.test_glm_perlin_vec2.e, align 16, !tbaa !5
  %4 = call zeroext i1 @test_eq(float noundef %2, float noundef %3)
  br i1 %4, label %5, label %50

5:                                                ; preds = %0
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = call float @glm_perlin_vec2(ptr noundef nonnull %6)
  %8 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 4), align 4, !tbaa !5
  %9 = call zeroext i1 @test_eq(float noundef %7, float noundef %8)
  br i1 %9, label %10, label %50

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %12 = call float @glm_perlin_vec2(ptr noundef nonnull %11)
  %13 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 8), align 8, !tbaa !5
  %14 = call zeroext i1 @test_eq(float noundef %12, float noundef %13)
  br i1 %14, label %15, label %50

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %1, i64 24
  %17 = call float @glm_perlin_vec2(ptr noundef nonnull %16)
  %18 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 12), align 4, !tbaa !5
  %19 = call zeroext i1 @test_eq(float noundef %17, float noundef %18)
  br i1 %19, label %20, label %50

20:                                               ; preds = %15
  %21 = getelementptr inbounds i8, ptr %1, i64 32
  %22 = call float @glm_perlin_vec2(ptr noundef nonnull %21)
  %23 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 16), align 16, !tbaa !5
  %24 = call zeroext i1 @test_eq(float noundef %22, float noundef %23)
  br i1 %24, label %25, label %50

25:                                               ; preds = %20
  %26 = getelementptr inbounds i8, ptr %1, i64 40
  %27 = call float @glm_perlin_vec2(ptr noundef nonnull %26)
  %28 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 20), align 4, !tbaa !5
  %29 = call zeroext i1 @test_eq(float noundef %27, float noundef %28)
  br i1 %29, label %30, label %50

30:                                               ; preds = %25
  %31 = getelementptr inbounds i8, ptr %1, i64 48
  %32 = call float @glm_perlin_vec2(ptr noundef nonnull %31)
  %33 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 24), align 8, !tbaa !5
  %34 = call zeroext i1 @test_eq(float noundef %32, float noundef %33)
  br i1 %34, label %35, label %50

35:                                               ; preds = %30
  %36 = getelementptr inbounds i8, ptr %1, i64 56
  %37 = call float @glm_perlin_vec2(ptr noundef nonnull %36)
  %38 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 28), align 4, !tbaa !5
  %39 = call zeroext i1 @test_eq(float noundef %37, float noundef %38)
  br i1 %39, label %40, label %50

40:                                               ; preds = %35
  %41 = getelementptr inbounds i8, ptr %1, i64 64
  %42 = call float @glm_perlin_vec2(ptr noundef nonnull %41)
  %43 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 32), align 16, !tbaa !5
  %44 = call zeroext i1 @test_eq(float noundef %42, float noundef %43)
  br i1 %44, label %45, label %50

45:                                               ; preds = %40
  %46 = getelementptr inbounds i8, ptr %1, i64 72
  %47 = call float @glm_perlin_vec2(ptr noundef nonnull %46)
  %48 = load float, ptr getelementptr inbounds (i8, ptr @__const.test_glm_perlin_vec2.e, i64 36), align 4, !tbaa !5
  %49 = call zeroext i1 @test_eq(float noundef %47, float noundef %48)
  br i1 %49, label %.loopexit, label %50

50:                                               ; preds = %45, %40, %35, %30, %25, %20, %15, %10, %5, %0
  %51 = load ptr, ptr @stderr, align 8, !tbaa !9
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef nonnull @.str, ptr noundef nonnull @.str.891, i32 noundef 110, ptr noundef nonnull @.str.894) #6
  br label %.loopexit

.loopexit:                                        ; preds = %45, %50
  %spec.select = phi i32 [ 0, %50 ], [ 1, %45 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #5
  %.fca.1.insert = insertvalue { ptr, i32 } { ptr null, i32 poison }, i32 %spec.select, 1
  ret { ptr, i32 } %.fca.1.insert
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden float @glm_perlin_vec2(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 = { nofree nounwind "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 = { cold 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass