; LLVM IR from control-flow-attestation/c-flat :: samples/soldering (Iron)

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

%struct.IronStruct = type { %struct.HistoryStruct, i32, i8, i8, i32, i8, i8, i8, i32, [2 x i32], i8, i32, i32, i16, i16, i8, i16, i8, i8, i8, i16, i32, i32, i8, i32, i32, i32 }
%struct.HistoryStruct = type { i8, [8 x i32] }

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

; Function Attrs: nounwind uwtable
define dso_local void @setTempHumanUnits(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.IronStruct, ptr %9, i32 0, i32 7
  %11 = load i8, ptr %10, align 2, !tbaa !11, !range !16, !noundef !17
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %33

13:                                               ; preds = %2
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 180
  br i1 %15, label %16, label %17

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

17:                                               ; preds = %16, %13
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = icmp sgt i32 %18, 400
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  store i32 400, ptr %4, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %20, %17
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.IronStruct, ptr %24, i32 0, i32 13
  %26 = load i16, ptr %25, align 4, !tbaa !18
  %27 = zext i16 %26 to i32
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.IronStruct, ptr %28, i32 0, i32 14
  %30 = load i16, ptr %29, align 2, !tbaa !19
  %31 = zext i16 %30 to i32
  %32 = call i32 @map(i32 noundef %23, i32 noundef 180, i32 noundef 400, i32 noundef %27, i32 noundef %31)
  store i32 %32, ptr %5, align 4, !tbaa !9
  br label %53

33:                                               ; preds = %2
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 356
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  store i32 356, ptr %4, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %36, %33
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp sgt i32 %38, 752
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  store i32 752, ptr %4, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %40, %37
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = add nsw i32 %42, 2
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.IronStruct, ptr %44, i32 0, i32 13
  %46 = load i16, ptr %45, align 4, !tbaa !18
  %47 = zext i16 %46 to i32
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.IronStruct, ptr %48, i32 0, i32 14
  %50 = load i16, ptr %49, align 2, !tbaa !19
  %51 = zext i16 %50 to i32
  %52 = call i32 @map(i32 noundef %43, i32 noundef 356, i32 noundef 752, i32 noundef %47, i32 noundef %51)
  store i32 %52, ptr %5, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %41, %21
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  store i8 0, ptr %6, align 1, !tbaa !20
  br label %54

54:                                               ; preds = %75, %53
  %55 = load i8, ptr %6, align 1, !tbaa !20
  %56 = zext i8 %55 to i32
  %57 = icmp slt i32 %56, 10
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 2, ptr %7, align 4
  br label %78

59:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = trunc i32 %61 to i16
  %63 = call zeroext i16 @temp2humanUnits(ptr noundef %60, i16 noundef zeroext %62)
  %64 = zext i16 %63 to i32
  store i32 %64, ptr %8, align 4, !tbaa !9
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = load i32, ptr %4, align 4, !tbaa !9
  %67 = icmp sle i32 %65, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %59
  store i32 2, ptr %7, align 4
  br label %72

69:                                               ; preds = %59
  %70 = load i32, ptr %5, align 4, !tbaa !9
  %71 = add nsw i32 %70, -1
  store i32 %71, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %7, align 4
  br label %72

72:                                               ; preds = %69, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %73 = load i32, ptr %7, align 4
  switch i32 %73, label %78 [
    i32 0, label %74
  ]

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74
  %76 = load i8, ptr %6, align 1, !tbaa !20
  %77 = add i8 %76, 1
  store i8 %77, ptr %6, align 1, !tbaa !20
  br label %54, !llvm.loop !21

78:                                               ; preds = %72, %58
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = load i32, ptr %5, align 4, !tbaa !9
  call void @setTemp(ptr noundef %80, i32 noundef %81)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

declare i32 @map(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @temp2humanUnits(ptr noundef, i16 noundef zeroext) #0

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

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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !14, i64 50}
!12 = !{!"IronStruct", !13, i64 0, !10, i64 36, !7, i64 40, !7, i64 41, !10, i64 44, !14, i64 48, !14, i64 49, !14, i64 50, !10, i64 52, !7, i64 56, !14, i64 64, !10, i64 68, !10, i64 72, !15, i64 76, !15, i64 78, !14, i64 80, !15, i64 82, !7, i64 84, !7, i64 85, !7, i64 86, !15, i64 88, !10, i64 92, !10, i64 96, !7, i64 100, !10, i64 104, !10, i64 108, !10, i64 112}
!13 = !{!"HistoryStruct", !7, i64 0, !7, i64 4}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!12, !15, i64 76}
!19 = !{!12, !15, i64 78}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

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

; Function Attrs: nounwind uwtable
define dso_local void @setTempHumanUnits(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 50
  %4 = load i8, ptr %3, align 2, !tbaa !5, !range !13, !noundef !14
  %5 = trunc nuw i8 %4 to i1
  %6 = getelementptr inbounds i8, ptr %0, i64 76
  %7 = load i16, ptr %6, align 4, !tbaa !15
  %8 = zext i16 %7 to i32
  %9 = getelementptr inbounds i8, ptr %0, i64 78
  %10 = load i16, ptr %9, align 2, !tbaa !16
  %11 = zext i16 %10 to i32
  br i1 %5, label %12, label %15

12:                                               ; preds = %2
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %1, i32 180)
  %spec.store.select2 = tail call i32 @llvm.umin.i32(i32 %spec.store.select, i32 400)
  %13 = add nuw nsw i32 %spec.store.select2, 1
  %14 = tail call i32 @map(i32 noundef %13, i32 noundef 180, i32 noundef 400, i32 noundef %8, i32 noundef %11) #3
  br label %18

15:                                               ; preds = %2
  %spec.store.select1 = tail call i32 @llvm.smax.i32(i32 %1, i32 356)
  %spec.store.select3 = tail call i32 @llvm.umin.i32(i32 %spec.store.select1, i32 752)
  %16 = add nuw nsw i32 %spec.store.select3, 2
  %17 = tail call i32 @map(i32 noundef %16, i32 noundef 356, i32 noundef 752, i32 noundef %8, i32 noundef %11) #3
  br label %18

18:                                               ; preds = %15, %12
  %.025 = phi i32 [ %14, %12 ], [ %17, %15 ]
  %.0 = phi i32 [ %spec.store.select2, %12 ], [ %spec.store.select3, %15 ]
  %19 = trunc nuw nsw i32 %.0 to i16
  %20 = trunc i32 %.025 to i16
  %21 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %20)
  %.not = icmp ugt i16 %21, %19
  br i1 %.not, label %22, label %59

22:                                               ; preds = %18
  %23 = add nsw i32 %.025, -1
  %24 = trunc i32 %23 to i16
  %25 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %24)
  %.not.1 = icmp ugt i16 %25, %19
  br i1 %.not.1, label %26, label %59

26:                                               ; preds = %22
  %27 = add nsw i32 %.025, -2
  %28 = trunc i32 %27 to i16
  %29 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %28)
  %.not.2 = icmp ugt i16 %29, %19
  br i1 %.not.2, label %30, label %59

30:                                               ; preds = %26
  %31 = add nsw i32 %.025, -3
  %32 = trunc i32 %31 to i16
  %33 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %32)
  %.not.3 = icmp ugt i16 %33, %19
  br i1 %.not.3, label %34, label %59

34:                                               ; preds = %30
  %35 = add nsw i32 %.025, -4
  %36 = trunc i32 %35 to i16
  %37 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %36)
  %.not.4 = icmp ugt i16 %37, %19
  br i1 %.not.4, label %38, label %59

38:                                               ; preds = %34
  %39 = add nsw i32 %.025, -5
  %40 = trunc i32 %39 to i16
  %41 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %40)
  %.not.5 = icmp ugt i16 %41, %19
  br i1 %.not.5, label %42, label %59

42:                                               ; preds = %38
  %43 = add nsw i32 %.025, -6
  %44 = trunc i32 %43 to i16
  %45 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %44)
  %.not.6 = icmp ugt i16 %45, %19
  br i1 %.not.6, label %46, label %59

46:                                               ; preds = %42
  %47 = add nsw i32 %.025, -7
  %48 = trunc i32 %47 to i16
  %49 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %48)
  %.not.7 = icmp ugt i16 %49, %19
  br i1 %.not.7, label %50, label %59

50:                                               ; preds = %46
  %51 = add nsw i32 %.025, -8
  %52 = trunc i32 %51 to i16
  %53 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %52)
  %.not.8 = icmp ugt i16 %53, %19
  br i1 %.not.8, label %54, label %59

54:                                               ; preds = %50
  %55 = add nsw i32 %.025, -9
  %56 = trunc i32 %55 to i16
  %57 = tail call zeroext i16 @temp2humanUnits(ptr noundef nonnull %0, i16 noundef zeroext %56)
  %.not.9 = icmp ugt i16 %57, %19
  %58 = add nsw i32 %.025, -10
  %spec.select = select i1 %.not.9, i32 %58, i32 %55
  br label %59

59:                                               ; preds = %54, %50, %46, %42, %38, %34, %30, %26, %22, %18
  %.1.lcssa = phi i32 [ %.025, %18 ], [ %23, %22 ], [ %27, %26 ], [ %31, %30 ], [ %35, %34 ], [ %39, %38 ], [ %43, %42 ], [ %47, %46 ], [ %51, %50 ], [ %spec.select, %54 ]
  tail call void @setTemp(ptr noundef nonnull %0, i32 noundef %.1.lcssa)
  ret void
}

declare i32 @map(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @temp2humanUnits(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

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

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

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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 50}
!6 = !{!"IronStruct", !7, i64 0, !10, i64 36, !8, i64 40, !8, i64 41, !10, i64 44, !11, i64 48, !11, i64 49, !11, i64 50, !10, i64 52, !8, i64 56, !11, i64 64, !10, i64 68, !10, i64 72, !12, i64 76, !12, i64 78, !11, i64 80, !12, i64 82, !8, i64 84, !8, i64 85, !8, i64 86, !12, i64 88, !10, i64 92, !10, i64 96, !8, i64 100, !10, i64 104, !10, i64 108, !10, i64 112}
!7 = !{!"HistoryStruct", !8, i64 0, !8, i64 4}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !12, i64 76}
!16 = !{!6, !12, i64 78}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass