; LLVM IR from microsoft/PQCrypto-SIDH :: tests (PQCtestKAT_kem434)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @FindMarker(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [50 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 50, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call i64 @strlen(ptr noundef %11) #5
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = icmp sgt i32 %14, 49
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  store i32 49, ptr %8, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %16, %2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %34, %17
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %37

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call i32 @fgetc(ptr noundef %23)
  store i32 %24, ptr %9, align 4, !tbaa !9
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = trunc i32 %25 to i8
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %28
  store i8 %26, ptr %29, align 1, !tbaa !11
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = icmp eq i32 %30, -1
  br i1 %31, label %32, label %33

32:                                               ; preds = %22
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %84

33:                                               ; preds = %22
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %7, align 4, !tbaa !9
  br label %18, !llvm.loop !12

37:                                               ; preds = %18
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %39
  store i8 0, ptr %40, align 1, !tbaa !11
  br label %41

41:                                               ; preds = %80, %37
  br label %42

42:                                               ; preds = %41
  %43 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 0
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = call i32 @strncmp(ptr noundef %43, ptr noundef %44, i64 noundef %46) #5
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %50, label %49

49:                                               ; preds = %42
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %84

50:                                               ; preds = %42
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %65, %50
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = sub nsw i32 %53, 1
  %55 = icmp slt i32 %52, %54
  br i1 %55, label %56, label %68

56:                                               ; preds = %51
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %63
  store i8 %61, ptr %64, align 1, !tbaa !11
  br label %65

65:                                               ; preds = %56
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %7, align 4, !tbaa !9
  br label %51, !llvm.loop !14

68:                                               ; preds = %51
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = call i32 @fgetc(ptr noundef %69)
  store i32 %70, ptr %9, align 4, !tbaa !9
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = trunc i32 %71 to i8
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %75
  store i8 %72, ptr %76, align 1, !tbaa !11
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = icmp eq i32 %77, -1
  br i1 %78, label %79, label %80

79:                                               ; preds = %68
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %84

80:                                               ; preds = %68
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %82
  store i8 0, ptr %83, align 1, !tbaa !11
  br label %41

84:                                               ; preds = %79, %49, %32
  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
  call void @llvm.lifetime.end.p0(i64 50, ptr %6) #4
  %85 = load i32, ptr %3, align 4
  ret i32 %85
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

declare i32 @fgetc(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 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 = { 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 #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 }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @FindMarker(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca [50 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 50, ptr nonnull %3) #6
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #7
  %.fr = freeze i64 %4
  %5 = trunc i64 %.fr to i32
  %spec.store.select = tail call i32 @llvm.smin.i32(i32 %5, i32 49)
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %2
  %7 = sext i32 %spec.store.select to i64
  %8 = getelementptr inbounds [50 x i8], ptr %3, i64 0, i64 %7
  %9 = add i32 %spec.store.select, -1
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [50 x i8], ptr %3, i64 0, i64 %10
  br label %.split.preheader

.lr.ph.preheader:                                 ; preds = %2
  %smax = tail call i32 @llvm.smax.i32(i32 %spec.store.select, i32 1)
  %wide.trip.count = zext nneg i32 %smax to i64
  br label %.lr.ph

12:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

.lr.ph:                                           ; preds = %.lr.ph.preheader, %12
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %12 ]
  %13 = tail call i32 @fgetc(ptr noundef %0)
  %14 = trunc i32 %13 to i8
  %15 = getelementptr inbounds [50 x i8], ptr %3, i64 0, i64 %indvars.iv
  store i8 %14, ptr %15, align 1, !tbaa !7
  %16 = icmp eq i32 %13, -1
  br i1 %16, label %.loopexit, label %12

._crit_edge:                                      ; preds = %12
  %17 = zext nneg i32 %spec.store.select to i64
  %18 = getelementptr inbounds [50 x i8], ptr %3, i64 0, i64 %17
  %19 = add nsw i32 %spec.store.select, -1
  %.not41 = icmp eq i32 %5, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [50 x i8], ptr %3, i64 0, i64 %20
  br i1 %.not41, label %.split.preheader, label %.split.us.preheader

.split.preheader:                                 ; preds = %._crit_edge.thread, %._crit_edge
  %22 = phi ptr [ %11, %._crit_edge.thread ], [ %21, %._crit_edge ]
  %23 = phi ptr [ %8, %._crit_edge.thread ], [ %18, %._crit_edge ]
  %24 = phi i64 [ %7, %._crit_edge.thread ], [ %17, %._crit_edge ]
  br label %.split

.split.us.preheader:                              ; preds = %._crit_edge
  %scevgep = getelementptr inbounds i8, ptr %3, i64 1
  %smax34 = tail call i32 @llvm.smax.i32(i32 %19, i32 1)
  %25 = zext nneg i32 %smax34 to i64
  br label %.split.us

.split.us:                                        ; preds = %.split.us.preheader, %.preheader.us.preheader
  store i8 0, ptr %18, align 1, !tbaa !7
  %26 = call i32 @strncmp(ptr noundef nonnull %3, ptr noundef %1, i64 noundef %17) #7
  %.not.us = icmp eq i32 %26, 0
  br i1 %.not.us, label %.loopexit, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.split.us
  call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %3, ptr noundef nonnull align 1 dereferenceable(1) %scevgep, i64 %25, i1 false), !tbaa !7
  %27 = tail call i32 @fgetc(ptr noundef %0)
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %21, align 1, !tbaa !7
  %29 = icmp eq i32 %27, -1
  br i1 %29, label %.loopexit, label %.split.us

.split:                                           ; preds = %.split.preheader, %.preheader
  store i8 0, ptr %23, align 1, !tbaa !7
  %30 = call i32 @strncmp(ptr noundef nonnull %3, ptr noundef %1, i64 noundef %24) #7
  %.not = icmp eq i32 %30, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.split
  %31 = tail call i32 @fgetc(ptr noundef %0)
  %32 = trunc i32 %31 to i8
  store i8 %32, ptr %22, align 1, !tbaa !7
  %33 = icmp eq i32 %31, -1
  br i1 %33, label %.loopexit, label %.split

.loopexit:                                        ; preds = %.lr.ph, %.preheader.us.preheader, %.split.us, %.split, %.preheader
  %.022 = phi i32 [ 0, %.preheader ], [ 1, %.split ], [ 0, %.preheader.us.preheader ], [ 1, %.split.us ], [ 0, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 50, ptr nonnull %3) #6
  ret i32 %.022
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fgetc(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree 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 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass