; 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 void @showScreenConfig(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 %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %7, i32 0, i32 2
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct.ScreenStruct, ptr %11, i32 0, i32 3
  %13 = load i8, ptr %12, align 8, !tbaa !15, !range !16, !noundef !17
  %14 = trunc i8 %13 to i1
  br i1 %14, label %23, label %15

15:                                               ; preds = %1
  %16 = call i64 @millis()
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %17, i32 0, i32 5
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = zext i32 %19 to i64
  %21 = icmp ult i64 %16, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %15
  store i32 1, ptr %5, align 4
  br label %63

23:                                               ; preds = %15, %1
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds %struct.ScreenStruct, ptr %25, i32 0, i32 3
  store i8 0, ptr %26, align 8, !tbaa !15
  %27 = call i64 @millis()
  %28 = add i64 %27, 10000
  %29 = trunc i64 %28 to i32
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %30, i32 0, i32 5
  store i32 %29, ptr %31, align 8, !tbaa !18
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %32, i32 0, i32 6
  %34 = load i8, ptr %33, align 4, !tbaa !19
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %58

37:                                               ; preds = %23
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %38, i32 0, i32 7
  %40 = load i8, ptr %39, align 1, !tbaa !20, !range !16, !noundef !17
  %41 = trunc i8 %40 to i1
  br i1 %41, label %42, label %58

42:                                               ; preds = %37
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %43, i32 0, i32 10
  %45 = load i8, ptr %44, align 8, !tbaa !21, !range !16, !noundef !17
  %46 = trunc i8 %45 to i1
  br i1 %46, label %47, label %52

47:                                               ; preds = %42
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %49, i32 0, i32 11
  %51 = getelementptr inbounds [4 x i8], ptr %50, i64 0, i64 0
  call void @message(ptr noundef %48, ptr noundef %51)
  br label %57

52:                                               ; preds = %42
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %54, i32 0, i32 12
  %56 = getelementptr inbounds [4 x i8], ptr %55, i64 0, i64 0
  call void @message(ptr noundef %53, ptr noundef %56)
  br label %57

57:                                               ; preds = %52, %47
  store i32 1, ptr %5, align 4
  br label %63

58:                                               ; preds = %37, %23
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ScreenConfigStruct, ptr %60, i32 0, i32 6
  %62 = load i8, ptr %61, align 4, !tbaa !19
  call void @setupMode(ptr noundef %59, i8 noundef zeroext %62)
  store i32 0, ptr %5, align 4
  br label %63

63:                                               ; preds = %58, %57, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %64 = load i32, ptr %5, align 4
  switch i32 %64, label %66 [
    i32 0, label %65
    i32 1, label %65
  ]

65:                                               ; preds = %63, %63
  ret void

66:                                               ; preds = %63
  unreachable
}

; 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 i64 @millis() #2

declare void @message(ptr noundef, ptr noundef) #2

declare void @setupMode(ptr noundef, i8 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 120}
!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 24}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !14, i64 144}
!19 = !{!10, !7, i64 148}
!20 = !{!10, !12, i64 149}
!21 = !{!10, !12, i64 152}


; 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 @showScreenConfig(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 24
  %5 = load i8, ptr %4, align 8, !tbaa !14, !range !15, !noundef !16
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %13, label %7

7:                                                ; preds = %1
  %8 = tail call i64 @millis() #2
  %9 = getelementptr inbounds i8, ptr %0, i64 144
  %10 = load i32, ptr %9, align 8, !tbaa !17
  %11 = zext i32 %10 to i64
  %12 = icmp ult i64 %8, %11
  br i1 %12, label %34, label %13

13:                                               ; preds = %7, %1
  store i8 0, ptr %4, align 8, !tbaa !14
  %14 = tail call i64 @millis() #2
  %15 = trunc i64 %14 to i32
  %16 = add i32 %15, 10000
  %17 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 %16, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 148
  %19 = load i8, ptr %18, align 4, !tbaa !18
  %20 = icmp eq i8 %19, 1
  br i1 %20, label %21, label %33

21:                                               ; preds = %13
  %22 = getelementptr inbounds i8, ptr %0, i64 149
  %23 = load i8, ptr %22, align 1, !tbaa !19, !range !15, !noundef !16
  %24 = trunc nuw i8 %23 to i1
  br i1 %24, label %25, label %33

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %0, i64 152
  %27 = load i8, ptr %26, align 8, !tbaa !20, !range !15, !noundef !16
  %28 = trunc nuw i8 %27 to i1
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %0, i64 153
  tail call void @message(ptr noundef %3, ptr noundef nonnull %30) #2
  br label %34

31:                                               ; preds = %25
  %32 = getelementptr inbounds i8, ptr %0, i64 157
  tail call void @message(ptr noundef %3, ptr noundef nonnull %32) #2
  br label %34

33:                                               ; preds = %21, %13
  tail call void @setupMode(ptr noundef %3, i8 noundef zeroext %19) #2
  br label %34

34:                                               ; preds = %29, %31, %7, %33
  ret void
}

declare i64 @millis() local_unnamed_addr #1

declare void @message(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @setupMode(ptr noundef, i8 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 = !{!"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 24}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!6, !13, i64 144}
!18 = !{!6, !9, i64 148}
!19 = !{!6, !11, i64 149}
!20 = !{!6, !11, i64 152}


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