; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (math-int-internal)

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

@.str = external hidden unnamed_addr constant [27 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @int_add(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @int_rshift(i64 noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @int_div(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @int_sqrt(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.WordArray_st, ptr %15, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !9
  store i64 %17, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %18 = load i64, ptr %5, align 8, !tbaa !12
  %19 = shl i64 %18, 1
  store i64 %19, ptr %6, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !13
  br label %20

20:                                               ; preds = %2
  %21 = load i64, ptr %5, align 8, !tbaa !12
  %22 = call ptr @wa_alloc_with_zero(i64 noundef %21)
  store ptr %22, ptr %9, align 8, !tbaa !5
  %23 = icmp eq ptr null, %22
  br i1 %23, label %24, label %26

24:                                               ; preds = %20
  store i32 2, ptr %12, align 4, !tbaa !13
  %25 = load i32, ptr %12, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 756, i32 noundef %25)
  br label %102

26:                                               ; preds = %20
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = load i64, ptr %5, align 8, !tbaa !12
  %31 = call ptr @wa_alloc(i64 noundef %30)
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = icmp eq ptr null, %31
  br i1 %32, label %33, label %35

33:                                               ; preds = %29
  store i32 2, ptr %12, align 4, !tbaa !13
  %34 = load i32, ptr %12, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 757, i32 noundef %34)
  br label %102

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  call void @int_rshift(i64 noundef 0, ptr noundef %38, i64 noundef 1, ptr noundef %39)
  br label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call ptr @wa_copy_with_alloc(ptr noundef %41)
  store ptr %42, ptr %8, align 8, !tbaa !5
  %43 = icmp eq ptr null, %42
  br i1 %43, label %44, label %46

44:                                               ; preds = %40
  store i32 2, ptr %12, align 4, !tbaa !13
  %45 = load i32, ptr %12, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 759, i32 noundef %45)
  br label %102

46:                                               ; preds = %40
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call ptr @wa_copy_with_alloc(ptr noundef %50)
  store ptr %51, ptr %10, align 8, !tbaa !5
  %52 = icmp eq ptr null, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  store i32 2, ptr %12, align 4, !tbaa !13
  %54 = load i32, ptr %12, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 760, i32 noundef %54)
  br label %102

55:                                               ; preds = %49
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = load i64, ptr %6, align 8, !tbaa !12
  call void @wa_change_len(ptr noundef %58, i64 noundef %59)
  br label %60

60:                                               ; preds = %57
  %61 = load i64, ptr %6, align 8, !tbaa !12
  %62 = call ptr @wa_alloc(i64 noundef %61)
  store ptr %62, ptr %11, align 8, !tbaa !5
  %63 = icmp eq ptr null, %62
  br i1 %63, label %64, label %66

64:                                               ; preds = %60
  store i32 2, ptr %12, align 4, !tbaa !13
  %65 = load i32, ptr %12, align 4, !tbaa !13
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 762, i32 noundef %65)
  br label %102

66:                                               ; preds = %60
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %97, %68
  br label %70

70:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  call void @int_div(ptr noundef %71, ptr noundef %72, ptr noundef %73, ptr noundef null)
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = load i64, ptr %5, align 8, !tbaa !12
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = call i32 @wa_copy_part(ptr noundef %74, i64 noundef 0, i64 noundef %75, ptr noundef %76)
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = call i64 @int_add(ptr noundef %78, ptr noundef %79, ptr noundef %80)
  store i64 %81, ptr %13, align 8, !tbaa !12
  %82 = load i64, ptr %13, align 8, !tbaa !12
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  call void @int_rshift(i64 noundef %82, ptr noundef %83, i64 noundef 1, ptr noundef %84)
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = call i32 @int_cmp(ptr noundef %85, ptr noundef %86)
  %88 = icmp sgt i32 %87, 0
  br i1 %88, label %89, label %93

89:                                               ; preds = %70
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = call i32 @wa_copy(ptr noundef %90, ptr noundef %91)
  br label %94

93:                                               ; preds = %70
  store i32 14, ptr %14, align 4
  br label %95

94:                                               ; preds = %89
  store i32 0, ptr %14, align 4
  br label %95

95:                                               ; preds = %94, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %96 = load i32, ptr %14, align 4
  switch i32 %96, label %108 [
    i32 0, label %97
    i32 14, label %98
  ]

97:                                               ; preds = %95
  br label %69

98:                                               ; preds = %95
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = call i32 @wa_copy(ptr noundef %99, ptr noundef %100)
  br label %102

102:                                              ; preds = %98, %64, %53, %44, %33, %24
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  call void @wa_free(ptr noundef %103)
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  call void @wa_free(ptr noundef %104)
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  call void @wa_free(ptr noundef %105)
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  call void @wa_free(ptr noundef %106)
  %107 = load ptr, ptr %11, align 8, !tbaa !5
  call void @wa_free(ptr noundef %107)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void

108:                                              ; preds = %95
  unreachable
}

declare ptr @wa_alloc_with_zero(i64 noundef) #2

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #2

declare ptr @wa_alloc(i64 noundef) #2

declare ptr @wa_copy_with_alloc(ptr noundef) #2

declare void @wa_change_len(ptr noundef, i64 noundef) #2

declare i32 @wa_copy_part(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare i32 @wa_copy(ptr noundef, ptr noundef) #2

declare void @wa_free(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"WordArray_st", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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"

@.str = external hidden unnamed_addr constant [27 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @int_sqrt(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = shl i64 %4, 1
  %6 = tail call ptr @wa_alloc_with_zero(i64 noundef %4) #2
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 756, i32 noundef 2) #2
  br label %33

9:                                                ; preds = %2
  %10 = tail call ptr @wa_alloc(i64 noundef %4) #2
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 757, i32 noundef 2) #2
  br label %33

13:                                               ; preds = %9
  tail call void @int_rshift(i64 noundef 0, ptr noundef nonnull %0, i64 noundef 1, ptr noundef nonnull %10)
  %14 = tail call ptr @wa_copy_with_alloc(ptr noundef nonnull %0) #2
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 759, i32 noundef 2) #2
  br label %33

17:                                               ; preds = %13
  %18 = tail call ptr @wa_copy_with_alloc(ptr noundef nonnull %0) #2
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 760, i32 noundef 2) #2
  br label %33

21:                                               ; preds = %17
  tail call void @wa_change_len(ptr noundef nonnull %18, i64 noundef %5) #2
  %22 = tail call ptr @wa_alloc(i64 noundef %5) #2
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %.preheader

24:                                               ; preds = %21
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 762, i32 noundef 2) #2
  br label %33

.preheader:                                       ; preds = %21, %29
  tail call void @int_div(ptr noundef nonnull %18, ptr noundef nonnull %10, ptr noundef nonnull %22, ptr noundef null)
  %25 = tail call i32 @wa_copy_part(ptr noundef nonnull %22, i64 noundef 0, i64 noundef %4, ptr noundef nonnull %6) #2
  %26 = tail call i64 @int_add(ptr noundef nonnull %6, ptr noundef nonnull %10, ptr noundef nonnull %10)
  tail call void @int_rshift(i64 noundef %26, ptr noundef nonnull %10, i64 noundef 1, ptr noundef nonnull %10)
  %27 = tail call i32 @int_cmp(ptr noundef nonnull %14, ptr noundef nonnull %10)
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %.preheader
  %30 = tail call i32 @wa_copy(ptr noundef nonnull %10, ptr noundef nonnull %14) #2
  br label %.preheader

31:                                               ; preds = %.preheader
  %32 = tail call i32 @wa_copy(ptr noundef nonnull %14, ptr noundef %1) #2
  br label %33

33:                                               ; preds = %31, %24, %20, %16, %12, %8
  %.042 = phi ptr [ null, %8 ], [ null, %12 ], [ null, %16 ], [ %14, %20 ], [ %14, %24 ], [ %14, %31 ]
  %.041 = phi ptr [ null, %8 ], [ null, %12 ], [ null, %16 ], [ null, %20 ], [ %18, %24 ], [ %18, %31 ]
  %.040 = phi ptr [ null, %8 ], [ null, %12 ], [ null, %16 ], [ null, %20 ], [ null, %24 ], [ %22, %31 ]
  %.039 = phi ptr [ null, %8 ], [ null, %12 ], [ %10, %16 ], [ %10, %20 ], [ %10, %24 ], [ %10, %31 ]
  tail call void @wa_free(ptr noundef %.039) #2
  tail call void @wa_free(ptr noundef %.042) #2
  tail call void @wa_free(ptr noundef %6) #2
  tail call void @wa_free(ptr noundef %.041) #2
  tail call void @wa_free(ptr noundef %.040) #2
  ret void
}

declare ptr @wa_alloc_with_zero(i64 noundef) local_unnamed_addr #1

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @wa_alloc(i64 noundef) local_unnamed_addr #1

declare ptr @wa_copy_with_alloc(ptr noundef) local_unnamed_addr #1

declare void @wa_change_len(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @wa_copy_part(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @wa_copy(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @wa_free(ptr 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 = { "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 }

!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 8}
!6 = !{!"WordArray_st", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}


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