; LLVM IR from gem5/gem5 :: src/systemc/tests/systemc/examples/aes (aes)

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

@_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str = external hidden global [17 x i8], align 16

; 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: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1 align 2

declare noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z11biguint2strN5sc_dt10sc_biguintILi128EEE(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  store i8 0, ptr getelementptr inbounds ([17 x i8], ptr @_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str, i64 0, i64 16), align 16, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !10
  br label %5

5:                                                ; preds = %102, %1
  %6 = load i32, ptr %3, align 4, !tbaa !10
  %7 = icmp slt i32 %6, 128
  br i1 %7, label %8, label %105

8:                                                ; preds = %5
  store i8 0, ptr %4, align 1, !tbaa !9
  %9 = load i32, ptr %3, align 4, !tbaa !10
  %10 = add nsw i32 %9, 0
  %11 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %10)
  %12 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = icmp ne i64 %12, 0
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 1, i32 0
  %16 = load i8, ptr %4, align 1, !tbaa !9
  %17 = sext i8 %16 to i32
  %18 = or i32 %17, %15
  %19 = trunc i32 %18 to i8
  store i8 %19, ptr %4, align 1, !tbaa !9
  %20 = load i32, ptr %3, align 4, !tbaa !10
  %21 = add nsw i32 %20, 1
  %22 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %21)
  %23 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %22)
  %24 = icmp ne i64 %23, 0
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, i32 2, i32 0
  %27 = load i8, ptr %4, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = or i32 %28, %26
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %4, align 1, !tbaa !9
  %31 = load i32, ptr %3, align 4, !tbaa !10
  %32 = add nsw i32 %31, 2
  %33 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %32)
  %34 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %33)
  %35 = icmp ne i64 %34, 0
  %36 = zext i1 %35 to i64
  %37 = select i1 %35, i32 4, i32 0
  %38 = load i8, ptr %4, align 1, !tbaa !9
  %39 = sext i8 %38 to i32
  %40 = or i32 %39, %37
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %4, align 1, !tbaa !9
  %42 = load i32, ptr %3, align 4, !tbaa !10
  %43 = add nsw i32 %42, 3
  %44 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %43)
  %45 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %44)
  %46 = icmp ne i64 %45, 0
  %47 = zext i1 %46 to i64
  %48 = select i1 %46, i32 8, i32 0
  %49 = load i8, ptr %4, align 1, !tbaa !9
  %50 = sext i8 %49 to i32
  %51 = or i32 %50, %48
  %52 = trunc i32 %51 to i8
  store i8 %52, ptr %4, align 1, !tbaa !9
  %53 = load i32, ptr %3, align 4, !tbaa !10
  %54 = add nsw i32 %53, 4
  %55 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %54)
  %56 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %55)
  %57 = icmp ne i64 %56, 0
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 16, i32 0
  %60 = load i8, ptr %4, align 1, !tbaa !9
  %61 = sext i8 %60 to i32
  %62 = or i32 %61, %59
  %63 = trunc i32 %62 to i8
  store i8 %63, ptr %4, align 1, !tbaa !9
  %64 = load i32, ptr %3, align 4, !tbaa !10
  %65 = add nsw i32 %64, 5
  %66 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %65)
  %67 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %66)
  %68 = icmp ne i64 %67, 0
  %69 = zext i1 %68 to i64
  %70 = select i1 %68, i32 32, i32 0
  %71 = load i8, ptr %4, align 1, !tbaa !9
  %72 = sext i8 %71 to i32
  %73 = or i32 %72, %70
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr %4, align 1, !tbaa !9
  %75 = load i32, ptr %3, align 4, !tbaa !10
  %76 = add nsw i32 %75, 6
  %77 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %76)
  %78 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %77)
  %79 = icmp ne i64 %78, 0
  %80 = zext i1 %79 to i64
  %81 = select i1 %79, i32 64, i32 0
  %82 = load i8, ptr %4, align 1, !tbaa !9
  %83 = sext i8 %82 to i32
  %84 = or i32 %83, %81
  %85 = trunc i32 %84 to i8
  store i8 %85, ptr %4, align 1, !tbaa !9
  %86 = load i32, ptr %3, align 4, !tbaa !10
  %87 = add nsw i32 %86, 7
  %88 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %87)
  %89 = call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %88)
  %90 = icmp ne i64 %89, 0
  %91 = zext i1 %90 to i64
  %92 = select i1 %90, i32 128, i32 0
  %93 = load i8, ptr %4, align 1, !tbaa !9
  %94 = sext i8 %93 to i32
  %95 = or i32 %94, %92
  %96 = trunc i32 %95 to i8
  store i8 %96, ptr %4, align 1, !tbaa !9
  %97 = load i8, ptr %4, align 1, !tbaa !9
  %98 = load i32, ptr %3, align 4, !tbaa !10
  %99 = sdiv i32 %98, 8
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [17 x i8], ptr @_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str, i64 0, i64 %100
  store i8 %97, ptr %101, align 1, !tbaa !9
  br label %102

102:                                              ; preds = %8
  %103 = load i32, ptr %3, align 4, !tbaa !10
  %104 = add nsw i32 %103, 8
  store i32 %104, ptr %3, align 4, !tbaa !10
  br label %5, !llvm.loop !12

105:                                              ; preds = %5
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret ptr @_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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"

@_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str = external hidden global [17 x i8], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

declare noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_Z11biguint2strN5sc_dt10sc_biguintILi128EEE(ptr noundef %0) local_unnamed_addr #0 {
  store i8 0, ptr getelementptr inbounds (i8, ptr @_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str, i64 16), align 16, !tbaa !5
  br label %2

2:                                                ; preds = %1, %2
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %2 ]
  %3 = trunc nuw nsw i64 %indvars.iv to i32
  %4 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %3)
  %5 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %.not = icmp ne i64 %5, 0
  %6 = trunc i64 %indvars.iv to i32
  %7 = or disjoint i32 %6, 1
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %7)
  %9 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %.not20 = icmp eq i64 %9, 0
  %10 = select i1 %.not20, i8 0, i8 2
  %11 = zext i1 %.not to i8
  %12 = or disjoint i8 %10, %11
  %13 = trunc i64 %indvars.iv to i32
  %14 = or disjoint i32 %13, 2
  %15 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %14)
  %16 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %15)
  %.not21 = icmp eq i64 %16, 0
  %17 = select i1 %.not21, i8 0, i8 4
  %18 = or disjoint i8 %12, %17
  %19 = trunc i64 %indvars.iv to i32
  %20 = or disjoint i32 %19, 3
  %21 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %20)
  %22 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  %.not22 = icmp eq i64 %22, 0
  %23 = select i1 %.not22, i8 0, i8 8
  %24 = or disjoint i8 %18, %23
  %25 = trunc i64 %indvars.iv to i32
  %26 = or disjoint i32 %25, 4
  %27 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %26)
  %28 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %27)
  %.not23 = icmp eq i64 %28, 0
  %29 = select i1 %.not23, i8 0, i8 16
  %30 = or disjoint i8 %24, %29
  %31 = trunc i64 %indvars.iv to i32
  %32 = or disjoint i32 %31, 5
  %33 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %32)
  %34 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %33)
  %.not24 = icmp eq i64 %34, 0
  %35 = select i1 %.not24, i8 0, i8 32
  %36 = or disjoint i8 %30, %35
  %37 = trunc i64 %indvars.iv to i32
  %38 = or disjoint i32 %37, 6
  %39 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %38)
  %40 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %39)
  %.not25 = icmp eq i64 %40, 0
  %41 = select i1 %.not25, i8 0, i8 64
  %42 = trunc i64 %indvars.iv to i32
  %43 = or disjoint i32 %42, 7
  %44 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5sc_dt11sc_unsignedixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %43)
  %45 = tail call noundef i64 @_ZNK5sc_dt20sc_unsigned_bitref_rcvyEv(ptr noundef nonnull align 8 dereferenceable(24) %44)
  %.not26 = icmp eq i64 %45, 0
  %46 = select i1 %.not26, i8 0, i8 -128
  %47 = or i8 %36, %41
  %48 = or i8 %47, %46
  %49 = lshr exact i64 %indvars.iv, 3
  %50 = getelementptr inbounds [17 x i8], ptr @_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str, i64 0, i64 %49
  store i8 %48, ptr %50, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 8
  %51 = icmp ult i64 %indvars.iv, 120
  br i1 %51, label %2, label %52, !llvm.loop !8

52:                                               ; preds = %2
  ret ptr @_ZZ11biguint2strN5sc_dt10sc_biguintILi128EEEE3str
}

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass