; 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.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.write_string = external hidden unnamed_addr constant [35 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [28 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 willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @write_string(i32 noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 1
  br i1 %10, label %11, label %13

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

12:                                               ; preds = %11
  br label %14

13:                                               ; preds = %11, %3
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 147, ptr noundef @__PRETTY_FUNCTION__.write_string) #6
  unreachable

14:                                               ; preds = %12
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %21

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = call i64 @strlen(ptr noundef %18) #7
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %6, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %17, %14
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %43, %21
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %47

26:                                               ; preds = %22
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = sub nsw i32 %32, %33
  %35 = sext i32 %34 to i64
  %36 = call i64 @write(i32 noundef %27, ptr noundef %31, i64 noundef %35)
  %37 = trunc i64 %36 to i32
  store i32 %37, ptr %7, align 4, !tbaa !5
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = icmp sge i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %26
  br i1 true, label %41, label %42

41:                                               ; preds = %40
  br label %43

42:                                               ; preds = %40, %26
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.2, i32 noundef 154, ptr noundef @__PRETTY_FUNCTION__.write_string) #6
  unreachable

43:                                               ; preds = %41
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %22, !llvm.loop !11

47:                                               ; preds = %22
  br label %48

48:                                               ; preds = %58, %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = call i64 @write(i32 noundef %49, ptr noundef @.str.13, i64 noundef 1)
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %7, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = icmp sge i32 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %48
  br i1 true, label %55, label %56

55:                                               ; preds = %54
  br label %57

56:                                               ; preds = %54, %48
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.2, i32 noundef 160, ptr noundef @__PRETTY_FUNCTION__.write_string) #6
  unreachable

57:                                               ; preds = %55
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %48, label %61, !llvm.loop !13

61:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 0
}

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #4

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 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 = { 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 #4 = { "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 = { noreturn 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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.write_string = external hidden unnamed_addr constant [35 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [28 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @write_string(i32 noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = icmp sgt i32 %0, 1
  br i1 %4, label %6, label %5

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 147, ptr noundef nonnull @__PRETTY_FUNCTION__.write_string) #4
  unreachable

6:                                                ; preds = %3
  %7 = icmp slt i32 %2, 0
  br i1 %7, label %8, label %11

8:                                                ; preds = %6
  %9 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #5
  %10 = trunc i64 %9 to i32
  br label %11

11:                                               ; preds = %8, %6
  %.015 = phi i32 [ %10, %8 ], [ %2, %6 ]
  %12 = icmp sgt i32 %.015, 0
  br i1 %12, label %.lr.ph, label %.preheader.preheader

.preheader.preheader:                             ; preds = %13, %11
  br label %.preheader

13:                                               ; preds = %.lr.ph
  %14 = add nuw nsw i32 %.020, %21
  %15 = icmp slt i32 %14, %.015
  br i1 %15, label %.lr.ph, label %.preheader.preheader, !llvm.loop !5

.lr.ph:                                           ; preds = %11, %13
  %.020 = phi i32 [ %14, %13 ], [ 0, %11 ]
  %16 = zext nneg i32 %.020 to i64
  %17 = getelementptr inbounds i8, ptr %1, i64 %16
  %18 = sub nsw i32 %.015, %.020
  %19 = sext i32 %18 to i64
  %20 = tail call i64 @write(i32 noundef %0, ptr noundef %17, i64 noundef %19) #6
  %21 = trunc i64 %20 to i32
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %13, label %23

23:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.2, i32 noundef 154, ptr noundef nonnull @__PRETTY_FUNCTION__.write_string) #4
  unreachable

.preheader:                                       ; preds = %.preheader.preheader, %28
  %24 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull @.str.13, i64 noundef 1) #6
  %25 = trunc i64 %24 to i32
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %28, label %27

27:                                               ; preds = %.preheader
  tail call void @__assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.2, i32 noundef 160, ptr noundef nonnull @__PRETTY_FUNCTION__.write_string) #4
  unreachable

28:                                               ; preds = %.preheader
  %29 = icmp eq i32 %25, 0
  br i1 %29, label %.preheader, label %30, !llvm.loop !7

30:                                               ; preds = %28
  ret i32 0
}

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

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 = { 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 #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 = { nofree "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 = { noreturn nounwind }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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