; LLVM IR from square/subzero :: core/external-crypto/modes/ltc (ltc_eax)

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @eax_init(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; 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 @eax_encryptx(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eax_memory(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, ptr noundef %9, i64 noundef %10, i32 noundef %11, ptr noundef %12) #0 {
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i64, align 8
  %26 = alloca i32, align 4
  %27 = alloca ptr, align 8
  %28 = alloca i32, align 4
  %29 = alloca ptr, align 8
  %30 = alloca ptr, align 8
  %31 = alloca i32, align 4
  store ptr %0, ptr %15, align 8, !tbaa !5
  store i64 %1, ptr %16, align 8, !tbaa !9
  store ptr %2, ptr %17, align 8, !tbaa !5
  store i64 %3, ptr %18, align 8, !tbaa !9
  store ptr %4, ptr %19, align 8, !tbaa !5
  store i64 %5, ptr %20, align 8, !tbaa !9
  store ptr %6, ptr %21, align 8, !tbaa !5
  store i64 %7, ptr %22, align 8, !tbaa !9
  store ptr %8, ptr %23, align 8, !tbaa !5
  store ptr %9, ptr %24, align 8, !tbaa !5
  store i64 %10, ptr %25, align 8, !tbaa !9
  store i32 %11, ptr %26, align 4, !tbaa !11
  store ptr %12, ptr %27, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #5
  store i32 1, ptr %28, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #5
  %32 = call noalias ptr @malloc(i64 noundef 992) #6
  store ptr %32, ptr %29, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %13
  br label %110

35:                                               ; preds = %13
  %36 = load i32, ptr %26, align 4, !tbaa !11
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %62

38:                                               ; preds = %35
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = load i64, ptr %16, align 8, !tbaa !9
  %41 = load ptr, ptr %17, align 8, !tbaa !5
  %42 = load i64, ptr %18, align 8, !tbaa !9
  %43 = load ptr, ptr %19, align 8, !tbaa !5
  %44 = load i64, ptr %20, align 8, !tbaa !9
  %45 = load ptr, ptr %29, align 8, !tbaa !5
  %46 = call i32 @eax_init(ptr noundef %39, i64 noundef %40, ptr noundef %41, i64 noundef %42, ptr noundef %43, i64 noundef %44, ptr noundef %45)
  store i32 %46, ptr %28, align 4, !tbaa !11
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %61

48:                                               ; preds = %38
  %49 = load ptr, ptr %21, align 8, !tbaa !5
  %50 = load ptr, ptr %23, align 8, !tbaa !5
  %51 = load i64, ptr %22, align 8, !tbaa !9
  %52 = load ptr, ptr %29, align 8, !tbaa !5
  %53 = call i32 @eax_encryptx(ptr noundef %49, ptr noundef %50, i64 noundef %51, ptr noundef %52)
  store i32 %53, ptr %28, align 4, !tbaa !11
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %60

55:                                               ; preds = %48
  %56 = load ptr, ptr %24, align 8, !tbaa !5
  %57 = load i64, ptr %25, align 8, !tbaa !9
  %58 = load ptr, ptr %29, align 8, !tbaa !5
  %59 = call i32 @eax_done(ptr noundef %56, i64 noundef %57, ptr noundef %58)
  store i32 %59, ptr %28, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %55, %48
  br label %61

61:                                               ; preds = %60, %38
  br label %107

62:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #5
  %63 = load ptr, ptr %27, align 8, !tbaa !5
  store i32 1, ptr %63, align 4, !tbaa !11
  %64 = load i64, ptr %25, align 8, !tbaa !9
  %65 = call noalias ptr @malloc(i64 noundef %64) #6
  store ptr %65, ptr %30, align 8, !tbaa !5
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  store i32 3, ptr %31, align 4
  br label %104

68:                                               ; preds = %62
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = load i64, ptr %16, align 8, !tbaa !9
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = load i64, ptr %18, align 8, !tbaa !9
  %73 = load ptr, ptr %19, align 8, !tbaa !5
  %74 = load i64, ptr %20, align 8, !tbaa !9
  %75 = load ptr, ptr %29, align 8, !tbaa !5
  %76 = call i32 @eax_init(ptr noundef %69, i64 noundef %70, ptr noundef %71, i64 noundef %72, ptr noundef %73, i64 noundef %74, ptr noundef %75)
  store i32 %76, ptr %28, align 4, !tbaa !11
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %102

78:                                               ; preds = %68
  %79 = load ptr, ptr %23, align 8, !tbaa !5
  %80 = load ptr, ptr %21, align 8, !tbaa !5
  %81 = load i64, ptr %22, align 8, !tbaa !9
  %82 = load ptr, ptr %29, align 8, !tbaa !5
  %83 = call i32 @eax_decryptx(ptr noundef %79, ptr noundef %80, i64 noundef %81, ptr noundef %82)
  store i32 %83, ptr %28, align 4, !tbaa !11
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %101

85:                                               ; preds = %78
  %86 = load ptr, ptr %30, align 8, !tbaa !5
  %87 = load i64, ptr %25, align 8, !tbaa !9
  %88 = load ptr, ptr %29, align 8, !tbaa !5
  %89 = call i32 @eax_done(ptr noundef %86, i64 noundef %87, ptr noundef %88)
  store i32 %89, ptr %28, align 4, !tbaa !11
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %100

91:                                               ; preds = %85
  %92 = load ptr, ptr %30, align 8, !tbaa !5
  %93 = load ptr, ptr %24, align 8, !tbaa !5
  %94 = load i64, ptr %25, align 8, !tbaa !9
  %95 = call i32 @memcmp(ptr noundef %92, ptr noundef %93, i64 noundef %94) #7
  %96 = icmp eq i32 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %91
  %98 = load ptr, ptr %27, align 8, !tbaa !5
  store i32 0, ptr %98, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %97, %91
  br label %100

100:                                              ; preds = %99, %85
  br label %101

101:                                              ; preds = %100, %78
  br label %102

102:                                              ; preds = %101, %68
  %103 = load ptr, ptr %30, align 8, !tbaa !5
  call void @free(ptr noundef %103) #5
  store i32 0, ptr %31, align 4
  br label %104

104:                                              ; preds = %102, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #5
  %105 = load i32, ptr %31, align 4
  switch i32 %105, label %112 [
    i32 0, label %106
    i32 3, label %108
  ]

106:                                              ; preds = %104
  br label %107

107:                                              ; preds = %106, %61
  br label %108

108:                                              ; preds = %107, %104
  %109 = load ptr, ptr %29, align 8, !tbaa !5
  call void @free(ptr noundef %109) #5
  br label %110

110:                                              ; preds = %108, %34
  %111 = load i32, ptr %28, align 4, !tbaa !11
  store i32 %111, ptr %14, align 4
  store i32 1, ptr %31, align 4
  br label %112

112:                                              ; preds = %110, %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #5
  %113 = load i32, ptr %14, align 4
  ret i32 %113
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

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 allocsize(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 willreturn memory(read) "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 = { nounwind allocsize(0) }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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: nounwind uwtable
declare dso_local i32 @eax_init(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eax_memory(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, ptr noundef %9, i64 noundef %10, i32 noundef %11, ptr nocapture noundef writeonly %12) local_unnamed_addr #0 {
  %14 = tail call noalias dereferenceable_or_null(992) ptr @malloc(i64 noundef 992) #4
  %15 = icmp eq ptr %14, null
  br i1 %15, label %43, label %16

16:                                               ; preds = %13
  %17 = icmp eq i32 %11, 0
  br i1 %17, label %18, label %26

18:                                               ; preds = %16
  %19 = tail call i32 @eax_init(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef nonnull %14)
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %42

21:                                               ; preds = %18
  %22 = tail call i32 @eax_encryptx(ptr noundef %6, ptr noundef %8, i64 noundef %7, ptr noundef nonnull %14)
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %42

24:                                               ; preds = %21
  %25 = tail call i32 @eax_done(ptr noundef %9, i64 noundef %10, ptr noundef nonnull %14)
  br label %42

26:                                               ; preds = %16
  store i32 1, ptr %12, align 4, !tbaa !5
  %27 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %28 = icmp eq ptr %27, null
  br i1 %28, label %42, label %29

29:                                               ; preds = %26
  %30 = tail call i32 @eax_init(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef nonnull %14)
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %41

32:                                               ; preds = %29
  %33 = tail call i32 @eax_decryptx(ptr noundef %8, ptr noundef %6, i64 noundef %7, ptr noundef nonnull %14)
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = tail call i32 @eax_done(ptr noundef nonnull %27, i64 noundef %10, ptr noundef nonnull %14)
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %bcmp = tail call i32 @bcmp(ptr nonnull %27, ptr %9, i64 %10)
  %39 = icmp eq i32 %bcmp, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %38
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %32, %38, %40, %35, %29
  %.040 = phi i32 [ 0, %40 ], [ 0, %38 ], [ %36, %35 ], [ %33, %32 ], [ %30, %29 ]
  tail call void @free(ptr noundef nonnull %27) #5
  br label %42

42:                                               ; preds = %41, %26, %21, %24, %18
  %.2 = phi i32 [ %25, %24 ], [ %22, %21 ], [ %19, %18 ], [ %.040, %41 ], [ 1, %26 ]
  tail call void @free(ptr noundef nonnull %14) #5
  br label %43

43:                                               ; preds = %42, %13
  %.039 = phi i32 [ 1, %13 ], [ %.2, %42 ]
  ret i32 %.039
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 willreturn memory(argmem: read) }
attributes #4 = { nounwind allocsize(0) }
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"}


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