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

; 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.ScreenConfigStruct = type { %struct.ScreenStruct, ptr, ptr, ptr, ptr, i32, i8, i8, i8, i8, 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 ptr @menu_longScreenConfig(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %6, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds %struct.ScreenStruct, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %40

12:                                               ; preds = %1
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %13, i32 0, i32 8
  %15 = load i8, ptr %14, align 2, !tbaa !15, !range !16, !noundef !17
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %35

17:                                               ; preds = %12
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %18, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %21, i32 0, i32 9
  %23 = load i8, ptr %22, align 1, !tbaa !19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %24, i32 0, i32 10
  %26 = load i8, ptr %25, align 8, !tbaa !20, !range !16, !noundef !17
  %27 = trunc i8 %26 to i1
  call void @saveConfig(ptr noundef %20, i8 noundef zeroext %23, i1 noundef zeroext %27)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %31, i32 0, i32 10
  %33 = load i8, ptr %32, align 8, !tbaa !20, !range !16, !noundef !17
  %34 = trunc i8 %33 to i1
  call void @setTempUnits(ptr noundef %30, i1 noundef zeroext %34)
  br label %35

35:                                               ; preds = %17, %12
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.ScreenStruct, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  store ptr %39, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %42

40:                                               ; preds = %1
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %41, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %42

42:                                               ; preds = %40, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %43 = load ptr, ptr %2, align 8
  ret ptr %43
}

; 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

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

declare void @setTempUnits(ptr noundef, i1 noundef zeroext) #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 = { 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 8}
!10 = !{!"ScreenConfigStruct", !11, i64 0, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !14, i64 144, !7, i64 148, !12, i64 149, !12, i64 150, !7, i64 151, !12, i64 152, !7, i64 153, !7, i64 157}
!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, !12, i64 150}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !6, i64 136}
!19 = !{!10, !7, i64 151}
!20 = !{!10, !12, i64 152}
!21 = !{!10, !6, i64 112}


; 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 ptr @menu_longScreenConfig(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %20, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 150
  %6 = load i8, ptr %5, align 2, !tbaa !14, !range !15, !noundef !16
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %20

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 136
  %10 = load ptr, ptr %9, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 151
  %12 = load i8, ptr %11, align 1, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %0, i64 152
  %14 = load i8, ptr %13, align 8, !tbaa !19, !range !15, !noundef !16
  %15 = trunc nuw i8 %14 to i1
  tail call void @saveConfig(ptr noundef %10, i8 noundef zeroext %12, i1 noundef zeroext %15) #2
  %16 = getelementptr inbounds i8, ptr %0, i64 112
  %17 = load ptr, ptr %16, align 8, !tbaa !20
  %18 = load i8, ptr %13, align 8, !tbaa !19, !range !15, !noundef !16
  %19 = trunc nuw i8 %18 to i1
  tail call void @setTempUnits(ptr noundef %17, i1 noundef zeroext %19) #2
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %4, %8, %1
  %.0 = phi ptr [ %0, %1 ], [ %.pre, %8 ], [ %3, %4 ]
  ret ptr %.0
}

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

declare void @setTempUnits(ptr noundef, i1 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 8}
!6 = !{!"ScreenConfigStruct", !7, i64 0, !8, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !13, i64 144, !9, i64 148, !11, i64 149, !11, i64 150, !9, i64 151, !11, i64 152, !9, i64 153, !9, i64 157}
!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, !11, i64 150}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!6, !8, i64 136}
!18 = !{!6, !9, i64 151}
!19 = !{!6, !11, i64 152}
!20 = !{!6, !8, i64 112}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass