; LLVM IR from stamparm/cryptospecs :: symmetrical/sources (skipjack)

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

@__const.main.inp = external hidden unnamed_addr constant [8 x i8], align 1
@__const.main.key = external hidden unnamed_addr constant [10 x i8], align 1
@__const.main.chk = external hidden unnamed_addr constant [8 x i8], align 1
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @makeKey(ptr 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: 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 void @encrypt(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @decrypt(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [8 x i8], align 1
  %3 = alloca [10 x i8], align 1
  %4 = alloca [8 x i8], align 1
  %5 = alloca [8 x i8], align 1
  %6 = alloca [8 x i8], align 1
  %7 = alloca [10 x [256 x i8]], align 16
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %2, ptr align 1 @__const.main.inp, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 10, ptr %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 @__const.main.key, i64 10, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 @__const.main.chk, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 2560, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %10 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %11 = getelementptr inbounds [10 x [256 x i8]], ptr %7, i64 0, i64 0
  call void @makeKey(ptr noundef %10, ptr noundef %11)
  %12 = getelementptr inbounds [10 x [256 x i8]], ptr %7, i64 0, i64 0
  %13 = getelementptr inbounds [8 x i8], ptr %2, i64 0, i64 0
  %14 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 0
  call void @encrypt(ptr noundef %12, ptr noundef %13, ptr noundef %14)
  %15 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 0
  %16 = getelementptr inbounds [8 x i8], ptr %6, i64 0, i64 0
  %17 = call i32 @memcmp(ptr noundef %15, ptr noundef %16, i64 noundef 8) #7
  %18 = icmp eq i32 %17, 0
  %19 = zext i1 %18 to i64
  %20 = select i1 %18, ptr @.str, ptr @.str.1
  %21 = call i32 (ptr, ...) @printf(ptr noundef %20)
  %22 = getelementptr inbounds [10 x [256 x i8]], ptr %7, i64 0, i64 0
  %23 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 0
  %24 = getelementptr inbounds [8 x i8], ptr %5, i64 0, i64 0
  call void @decrypt(ptr noundef %22, ptr noundef %23, ptr noundef %24)
  %25 = getelementptr inbounds [8 x i8], ptr %5, i64 0, i64 0
  %26 = getelementptr inbounds [8 x i8], ptr %2, i64 0, i64 0
  %27 = call i32 @memcmp(ptr noundef %25, ptr noundef %26, i64 noundef 8) #7
  %28 = icmp eq i32 %27, 0
  %29 = zext i1 %28 to i64
  %30 = select i1 %28, ptr @.str.2, ptr @.str.3
  %31 = call i32 (ptr, ...) @printf(ptr noundef %30)
  %32 = call i64 @clock() #6
  %33 = sub nsw i64 0, %32
  store i64 %33, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %41, %0
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp slt i32 %35, 1000000
  br i1 %36, label %37, label %44

37:                                               ; preds = %34
  %38 = getelementptr inbounds [10 x [256 x i8]], ptr %7, i64 0, i64 0
  %39 = getelementptr inbounds [8 x i8], ptr %2, i64 0, i64 0
  %40 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 0
  call void @encrypt(ptr noundef %38, ptr noundef %39, ptr noundef %40)
  br label %41

41:                                               ; preds = %37
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %8, align 4, !tbaa !9
  br label %34, !llvm.loop !11

44:                                               ; preds = %34
  %45 = call i64 @clock() #6
  %46 = load i64, ptr %9, align 8, !tbaa !5
  %47 = add nsw i64 %46, %45
  store i64 %47, ptr %9, align 8, !tbaa !5
  %48 = load i64, ptr %9, align 8, !tbaa !5
  %49 = sitofp i64 %48 to float
  %50 = fdiv float %49, 1.000000e+06
  %51 = fpext float %50 to double
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %51)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 2560, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 10, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  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) #2

declare i32 @printf(ptr noundef, ...) #3

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

; Function Attrs: nounwind
declare i64 @clock() #5

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 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 "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 #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 = !{!6, !6, i64 0}
!6 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"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"

@__const.main.inp = external hidden unnamed_addr constant [8 x i8], align 1
@__const.main.key = external hidden unnamed_addr constant [10 x i8], align 1
@__const.main.chk = external hidden unnamed_addr constant [8 x i8], align 1
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @makeKey(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress 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 void @encrypt(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @decrypt(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [8 x i8], align 8
  %2 = alloca [10 x i8], align 1
  %3 = alloca [8 x i8], align 1
  %4 = alloca [8 x i8], align 1
  %5 = alloca [10 x [256 x i8]], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %6 = load i64, ptr @__const.main.inp, align 1
  store i64 %6, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(10) %2, ptr noundef nonnull align 1 dereferenceable(10) @__const.main.key, i64 10, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 2560, ptr nonnull %5) #6
  call void @makeKey(ptr noundef nonnull %2, ptr noundef nonnull %5)
  call void @encrypt(ptr noundef nonnull %5, ptr noundef nonnull %1, ptr noundef nonnull %3)
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(8) %3, ptr noundef nonnull dereferenceable(8) @__const.main.chk, i64 8)
  %7 = icmp eq i32 %bcmp, 0
  %8 = select i1 %7, ptr @.str, ptr @.str.1
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %8)
  call void @decrypt(ptr noundef nonnull %5, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %bcmp4 = call i32 @bcmp(ptr noundef nonnull dereferenceable(8) %4, ptr noundef nonnull dereferenceable(8) %1, i64 8)
  %10 = icmp eq i32 %bcmp4, 0
  %11 = select i1 %10, ptr @.str.2, ptr @.str.3
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %11)
  %13 = call i64 @clock() #6
  br label %14

14:                                               ; preds = %0, %14
  %.05 = phi i32 [ 0, %0 ], [ %15, %14 ]
  call void @encrypt(ptr noundef nonnull %5, ptr noundef nonnull %1, ptr noundef nonnull %3)
  %15 = add nuw nsw i32 %.05, 1
  %exitcond.not = icmp eq i32 %15, 1000000
  br i1 %exitcond.not, label %16, label %14, !llvm.loop !5

16:                                               ; preds = %14
  %17 = call i64 @clock() #6
  %18 = sub i64 %17, %13
  %19 = sitofp i64 %18 to float
  %20 = fdiv float %19, 1.000000e+06
  %21 = fpext float %20 to double
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %21)
  call void @llvm.lifetime.end.p0(i64 2560, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nounwind
declare i64 @clock() local_unnamed_addr #4

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { nofree nounwind willreturn memory(argmem: 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"}


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