; LLVM IR from jordan4ibanez/tinyphysicsengine :: old (test)

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

@TPE_sinTable = external hidden constant [128 x i32], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_wrap(i32 noundef, i32 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
define dso_local i32 @TPE_sin(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  store i32 %0, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = sdiv i32 %4, 1
  %6 = call i32 @TPE_wrap(i32 noundef %5, i32 noundef 512)
  store i32 %6, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i8 1, ptr %3, align 1, !tbaa !9
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 128
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  br label %30

10:                                               ; preds = %1
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 256
  br i1 %12, label %13, label %17

13:                                               ; preds = %10
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sub nsw i32 256, %14
  %16 = sub nsw i32 %15, 1
  store i32 %16, ptr %2, align 4, !tbaa !5
  br label %29

17:                                               ; preds = %10
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 384
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sub nsw i32 %21, 256
  store i32 %22, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !9
  br label %28

23:                                               ; preds = %17
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 384
  %26 = sub nsw i32 128, %25
  %27 = sub nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !9
  br label %28

28:                                               ; preds = %23, %20
  br label %29

29:                                               ; preds = %28, %13
  br label %30

30:                                               ; preds = %29, %9
  %31 = load i8, ptr %3, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %30
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [128 x i32], ptr @TPE_sinTable, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  br label %45

39:                                               ; preds = %30
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [128 x i32], ptr @TPE_sinTable, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = mul nsw i32 -1, %43
  br label %45

45:                                               ; preds = %39, %34
  %46 = phi i32 [ %38, %34 ], [ %44, %39 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret i32 %46
}

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 = { 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 = !{!7, !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"

@TPE_sinTable = external hidden local_unnamed_addr constant [128 x i32], align 16

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TPE_sin(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @TPE_wrap(i32 noundef %0, i32 noundef 512)
  %3 = icmp slt i32 %2, 128
  br i1 %3, label %16, label %4

4:                                                ; preds = %1
  %5 = icmp ult i32 %2, 256
  br i1 %5, label %6, label %8

6:                                                ; preds = %4
  %7 = sub nuw nsw i32 255, %2
  br label %16

8:                                                ; preds = %4
  %9 = icmp ult i32 %2, 384
  %10 = sub nsw i32 511, %2
  %11 = add nsw i32 %2, -256
  %.010.ph = select i1 %9, i32 %11, i32 %10
  %12 = sext i32 %.010.ph to i64
  %13 = getelementptr inbounds [128 x i32], ptr @TPE_sinTable, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sub nsw i32 0, %14
  br label %20

16:                                               ; preds = %1, %6
  %.010 = phi i32 [ %2, %1 ], [ %7, %6 ]
  %17 = sext i32 %.010 to i64
  %18 = getelementptr inbounds [128 x i32], ptr @TPE_sinTable, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %8, %16
  %21 = phi i32 [ %19, %16 ], [ %15, %8 ]
  ret i32 %21
}

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

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


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