; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/machsuite-aes (support)

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

@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.parse_string = external hidden unnamed_addr constant [38 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; 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 i32 @parse_string(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %12

10:                                               ; preds = %3
  br i1 true, label %11, label %12

11:                                               ; preds = %10
  br label %13

12:                                               ; preds = %10, %3
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.2, i32 noundef 79, ptr noundef @__PRETTY_FUNCTION__.parse_string) #5
  unreachable

13:                                               ; preds = %11
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %78

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

17:                                               ; preds = %74, %16
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %18, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %72

25:                                               ; preds = %17
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %26, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %72

34:                                               ; preds = %25
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = add nsw i32 %36, 2
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %35, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %72

43:                                               ; preds = %34
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %49, 10
  br i1 %50, label %51, label %69

51:                                               ; preds = %43
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %52, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !11
  %58 = sext i8 %57 to i32
  %59 = icmp eq i32 %58, 37
  br i1 %59, label %60, label %69

60:                                               ; preds = %51
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = add nsw i32 %62, 2
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %61, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %67, 37
  br label %69

69:                                               ; preds = %60, %51, %43
  %70 = phi i1 [ false, %51 ], [ false, %43 ], [ %68, %60 ]
  %71 = xor i1 %70, true
  br label %72

72:                                               ; preds = %69, %34, %25, %17
  %73 = phi i1 [ false, %34 ], [ false, %25 ], [ false, %17 ], [ %71, %69 ]
  br i1 %73, label %74, label %77

74:                                               ; preds = %72
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %7, align 4, !tbaa !9
  br label %17, !llvm.loop !12

77:                                               ; preds = %72
  br label %80

78:                                               ; preds = %13
  %79 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %79, ptr %7, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %78, %77
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %81, ptr align 1 %82, i64 %84, i1 false)
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = icmp slt i32 %85, 0
  br i1 %86, label %87, label %92

87:                                               ; preds = %80
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i8, ptr %88, i64 %90
  store i8 0, ptr %91, align 1, !tbaa !11
  br label %92

92:                                               ; preds = %87, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 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) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { noreturn 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.parse_string = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @parse_string(ptr noundef readonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.2, i32 noundef 79, ptr noundef nonnull @__PRETTY_FUNCTION__.parse_string) #3
  unreachable

5:                                                ; preds = %3
  %6 = icmp slt i32 %2, 0
  br i1 %6, label %.critedge30.preheader, label %.critedge.thread

.critedge30.preheader:                            ; preds = %5
  %.pre = load i8, ptr %0, align 1, !tbaa !5
  %invariant.gep = getelementptr inbounds i8, ptr %0, i64 2
  br label %.critedge30

.critedge.thread:                                 ; preds = %5
  %7 = zext nneg i32 %2 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr nonnull align 1 %0, i64 %7, i1 false)
  br label %20

.critedge30:                                      ; preds = %.critedge30.preheader, %14
  %8 = phi i8 [ %.pre, %.critedge30.preheader ], [ %11, %14 ]
  %indvars.iv = phi i64 [ 0, %.critedge30.preheader ], [ %indvars.iv.next, %14 ]
  %.not26 = icmp eq i8 %8, 0
  br i1 %.not26, label %.critedge, label %9

9:                                                ; preds = %.critedge30
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %.not27 = icmp eq i8 %11, 0
  br i1 %.not27, label %.critedge, label %12

12:                                               ; preds = %9
  %gep = getelementptr inbounds i8, ptr %invariant.gep, i64 %indvars.iv
  %13 = load i8, ptr %gep, align 1, !tbaa !5
  %.not28 = icmp eq i8 %13, 0
  br i1 %.not28, label %.critedge, label %14

14:                                               ; preds = %12
  %15 = icmp eq i8 %8, 10
  %16 = icmp eq i8 %11, 37
  %or.cond = and i1 %15, %16
  %17 = icmp eq i8 %13, 37
  %or.cond31 = and i1 %or.cond, %17
  br i1 %or.cond31, label %.critedge, label %.critedge30, !llvm.loop !8

.critedge:                                        ; preds = %14, %.critedge30, %9, %12
  %18 = and i64 %indvars.iv, 4294967295
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr nonnull align 1 %0, i64 %18, i1 false)
  %19 = getelementptr inbounds i8, ptr %1, i64 %18
  store i8 0, ptr %19, align 1, !tbaa !5
  br label %20

20:                                               ; preds = %.critedge.thread, %.critedge
  ret i32 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) #2

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


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass