; 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 @resetPID(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @setTemp(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.IronStruct, ptr %5, i32 0, i32 5
  %7 = load i8, ptr %6, align 4, !tbaa !11, !range !16, !noundef !17
  %8 = trunc i8 %7 to i1
  br i1 %8, label %9, label %11

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  call void @resetPID(ptr noundef %10)
  br label %11

11:                                               ; preds = %9, %2
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.IronStruct, ptr %13, i32 0, i32 8
  store i32 %12, ptr %14, align 4, !tbaa !18
  ret void
}

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

!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 48}
!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, !10, i64 52}


; 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 @resetPID(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @setTemp(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load i8, ptr %3, align 4, !tbaa !5, !range !13, !noundef !14
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @resetPID(ptr noundef nonnull %0)
  br label %7

7:                                                ; preds = %6, %2
  %8 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %1, ptr %8, align 4, !tbaa !15
  ret void
}

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

!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 48}
!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, !10, i64 52}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,TailCallElimPass