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

; 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.ScreenMainStruct = type { %struct.ScreenStruct, ptr, ptr, ptr, ptr, ptr, i8, i32, i8, i8, i8, [4 x i8], [4 x i8], [4 x i8] }
%struct.ScreenStruct = type { ptr, ptr, ptr, i8, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @initScreenMain(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  %8 = alloca i16, align 2
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ScreenMainStruct, ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ScreenMainStruct, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  store ptr %15, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  call void @switchPower(ptr noundef %16, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call zeroext i16 @getTemp(ptr noundef %17)
  store i16 %18, ptr %6, align 2, !tbaa !16
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ScreenMainStruct, ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = call zeroext i1 @Config_getTempUnits(ptr noundef %21)
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ScreenMainStruct, ptr %23, i32 0, i32 10
  %25 = zext i1 %22 to i8
  store i8 %25, ptr %24, align 2, !tbaa !18
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ScreenMainStruct, ptr %27, i32 0, i32 10
  %29 = load i8, ptr %28, align 2, !tbaa !18, !range !19, !noundef !20
  %30 = trunc i8 %29 to i1
  call void @setTempUnits(ptr noundef %26, i1 noundef zeroext %30)
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #3
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load i16, ptr %6, align 2, !tbaa !16
  %33 = call zeroext i16 @temp2humanUnits(ptr noundef %31, i16 noundef zeroext %32)
  store i16 %33, ptr %7, align 2, !tbaa !16
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ScreenMainStruct, ptr %34, i32 0, i32 10
  %36 = load i8, ptr %35, align 2, !tbaa !18, !range !19, !noundef !20
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %43

38:                                               ; preds = %1
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ScreenMainStruct, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !21
  %42 = load i16, ptr %7, align 2, !tbaa !16
  call void @initEncoder(ptr noundef %41, i16 noundef signext %42, i16 noundef signext 180, i16 noundef signext 400, i8 noundef zeroext 1, i8 noundef zeroext 5, i32 noundef 0)
  br label %48

43:                                               ; preds = %1
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ScreenMainStruct, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !21
  %47 = load i16, ptr %7, align 2, !tbaa !16
  call void @initEncoder(ptr noundef %46, i16 noundef signext %47, i16 noundef signext 356, i16 noundef signext 752, i8 noundef zeroext 1, i8 noundef zeroext 5, i32 noundef 0)
  br label %48

48:                                               ; preds = %43, %38
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ScreenMainStruct, ptr %49, i32 0, i32 6
  store i8 0, ptr %50, align 8, !tbaa !22
  %51 = call i64 @millis()
  %52 = trunc i64 %51 to i32
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ScreenMainStruct, ptr %53, i32 0, i32 7
  store i32 %52, ptr %54, align 4, !tbaa !23
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  call void @clear(ptr noundef %55)
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  call void @forceRedraw(ptr noundef %56)
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #3
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call zeroext i16 @Iron_temp(ptr noundef %57)
  store i16 %58, ptr %8, align 2, !tbaa !16
  %59 = load i16, ptr %8, align 2, !tbaa !16
  %60 = zext i16 %59 to i32
  %61 = icmp sgt i32 %60, 400
  br i1 %61, label %62, label %66

62:                                               ; preds = %48
  %63 = load i16, ptr %8, align 2, !tbaa !16
  %64 = zext i16 %63 to i32
  %65 = icmp slt i32 %64, 740
  br label %66

66:                                               ; preds = %62, %48
  %67 = phi i1 [ false, %48 ], [ %65, %62 ]
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ScreenMainStruct, ptr %68, i32 0, i32 8
  %70 = zext i1 %67 to i8
  store i8 %70, ptr %69, align 8, !tbaa !24
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ScreenMainStruct, ptr %71, i32 0, i32 8
  %73 = load i8, ptr %72, align 8, !tbaa !24, !range !19, !noundef !20
  %74 = trunc i8 %73 to i1
  %75 = xor i1 %74, true
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ScreenMainStruct, ptr %76, i32 0, i32 9
  %78 = zext i1 %75 to i8
  store i8 %78, ptr %77, align 1, !tbaa !25
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ScreenMainStruct, ptr %79, i32 0, i32 8
  %81 = load i8, ptr %80, align 8, !tbaa !24, !range !19, !noundef !20
  %82 = trunc i8 %81 to i1
  br i1 %82, label %83, label %89

83:                                               ; preds = %66
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ScreenMainStruct, ptr %84, i32 0, i32 5
  %86 = load ptr, ptr %85, align 8, !tbaa !17
  %87 = load i16, ptr %6, align 2, !tbaa !16
  %88 = call zeroext i1 @saveTemp(ptr noundef %86, i16 noundef zeroext %87)
  br label %89

89:                                               ; preds = %83, %66
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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 void @switchPower(ptr noundef, i1 noundef zeroext) #2

declare zeroext i16 @getTemp(ptr noundef) #2

declare zeroext i1 @Config_getTempUnits(ptr noundef) #2

declare void @setTempUnits(ptr noundef, i1 noundef zeroext) #2

declare zeroext i16 @temp2humanUnits(ptr noundef, i16 noundef zeroext) #2

declare void @initEncoder(ptr noundef, i16 noundef signext, i16 noundef signext, i16 noundef signext, i8 noundef zeroext, i8 noundef zeroext, i32 noundef) #2

declare i64 @millis() #2

declare void @clear(ptr noundef) #2

declare void @forceRedraw(ptr noundef) #2

declare zeroext i16 @Iron_temp(ptr noundef) #2

declare zeroext i1 @saveTemp(ptr noundef, i16 noundef zeroext) #2

; 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, !6, i64 120}
!10 = !{!"ScreenMainStruct", !11, i64 0, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !12, i64 152, !14, i64 156, !12, i64 160, !12, i64 161, !12, i64 162, !7, i64 163, !7, i64 167, !7, i64 171}
!11 = !{!"ScreenStruct", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !13, i64 26, !14, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !6, i64 112}
!16 = !{!13, !13, i64 0}
!17 = !{!10, !6, i64 144}
!18 = !{!10, !12, i64 162}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!10, !6, i64 128}
!22 = !{!10, !12, i64 152}
!23 = !{!10, !14, i64 156}
!24 = !{!10, !12, i64 160}
!25 = !{!10, !12, i64 161}


; 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
define dso_local void @initScreenMain(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 120
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 112
  %5 = load ptr, ptr %4, align 8, !tbaa !14
  tail call void @switchPower(ptr noundef %5, i1 noundef zeroext false) #2
  %6 = tail call zeroext i16 @getTemp(ptr noundef %5) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  %9 = tail call zeroext i1 @Config_getTempUnits(ptr noundef %8) #2
  %10 = getelementptr inbounds i8, ptr %0, i64 162
  %11 = zext i1 %9 to i8
  store i8 %11, ptr %10, align 2, !tbaa !16
  tail call void @setTempUnits(ptr noundef %5, i1 noundef zeroext %9) #2
  %12 = tail call zeroext i16 @temp2humanUnits(ptr noundef %5, i16 noundef zeroext %6) #2
  %13 = load i8, ptr %10, align 2, !tbaa !16, !range !17, !noundef !18
  %14 = trunc nuw i8 %13 to i1
  %15 = getelementptr inbounds i8, ptr %0, i64 128
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  br i1 %14, label %17, label %18

17:                                               ; preds = %1
  tail call void @initEncoder(ptr noundef %16, i16 noundef signext %12, i16 noundef signext 180, i16 noundef signext 400, i8 noundef zeroext 1, i8 noundef zeroext 5, i32 noundef 0) #2
  br label %19

18:                                               ; preds = %1
  tail call void @initEncoder(ptr noundef %16, i16 noundef signext %12, i16 noundef signext 356, i16 noundef signext 752, i8 noundef zeroext 1, i8 noundef zeroext 5, i32 noundef 0) #2
  br label %19

19:                                               ; preds = %18, %17
  %20 = getelementptr inbounds i8, ptr %0, i64 152
  store i8 0, ptr %20, align 8, !tbaa !20
  %21 = tail call i64 @millis() #2
  %22 = trunc i64 %21 to i32
  %23 = getelementptr inbounds i8, ptr %0, i64 156
  store i32 %22, ptr %23, align 4, !tbaa !21
  tail call void @clear(ptr noundef %3) #2
  tail call void @forceRedraw(ptr noundef nonnull %0) #2
  %24 = tail call zeroext i16 @Iron_temp(ptr noundef %5) #2
  %25 = add i16 %24, -401
  %26 = icmp ult i16 %25, 339
  %27 = getelementptr inbounds i8, ptr %0, i64 160
  %28 = zext i1 %26 to i8
  store i8 %28, ptr %27, align 8, !tbaa !22
  %29 = xor i1 %26, true
  %30 = getelementptr inbounds i8, ptr %0, i64 161
  %31 = zext i1 %29 to i8
  store i8 %31, ptr %30, align 1, !tbaa !23
  br i1 %26, label %32, label %35

32:                                               ; preds = %19
  %33 = load ptr, ptr %7, align 8, !tbaa !15
  %34 = tail call zeroext i1 @saveTemp(ptr noundef %33, i16 noundef zeroext %6) #2
  br label %35

35:                                               ; preds = %32, %19
  ret void
}

declare void @switchPower(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare zeroext i16 @getTemp(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @Config_getTempUnits(ptr noundef) local_unnamed_addr #1

declare void @setTempUnits(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare zeroext i16 @temp2humanUnits(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

declare void @initEncoder(ptr noundef, i16 noundef signext, i16 noundef signext, i16 noundef signext, i8 noundef zeroext, i8 noundef zeroext, i32 noundef) local_unnamed_addr #1

declare i64 @millis() local_unnamed_addr #1

declare void @clear(ptr noundef) local_unnamed_addr #1

declare void @forceRedraw(ptr noundef) local_unnamed_addr #1

declare zeroext i16 @Iron_temp(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @saveTemp(ptr noundef, i16 noundef zeroext) local_unnamed_addr #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 = { "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 }

!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, !8, i64 120}
!6 = !{!"ScreenMainStruct", !7, i64 0, !8, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !11, i64 152, !13, i64 156, !11, i64 160, !11, i64 161, !11, i64 162, !9, i64 163, !9, i64 167, !9, i64 171}
!7 = !{!"ScreenStruct", !8, i64 0, !8, i64 8, !8, i64 16, !11, i64 24, !12, i64 26, !13, i64 28, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"_Bool", !9, i64 0}
!12 = !{!"short", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!6, !8, i64 112}
!15 = !{!6, !8, i64 144}
!16 = !{!6, !11, i64 162}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!6, !8, i64 128}
!20 = !{!6, !11, i64 152}
!21 = !{!6, !13, i64 156}
!22 = !{!6, !11, i64 160}
!23 = !{!6, !11, i64 161}


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