; LLVM IR from HANDS-FREE/OpenRE :: 3_OS/STM32F1/GUI/STemWin/Demo (GUIDEMO)

; 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.GUIDEMO_CONFIG = type { ptr, i32, i16 }
%struct.FRAMEWIN_SKINFLEX_PROPS = type { [3 x i64], [2 x i64], i32, i32, i32, i32, i32, i32 }

@_pfDrawBk = external hidden global ptr, align 8
@_GUIDemoConfig = external hidden global %struct.GUIDEMO_CONFIG, align 8
@_Pressed = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_SetDrawLogo(i8 noundef zeroext) #0

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

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

declare i64 @WM_GetDesktopWindow() #2

declare i32 @GUI_SetTextMode(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @GUIDEMO_Main() #0 {
  %1 = alloca %struct.FRAMEWIN_SKINFLEX_PROPS, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 64, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @GUI_MEMDEV_SetAnimationCallback(ptr noundef @_cbEffect, ptr noundef @_Pressed)
  %4 = call i64 @WM_GetDesktopWindow()
  %5 = call ptr @WM_SetCallback(i64 noundef %4, ptr noundef @_cbBk)
  call void @BUTTON_SetReactOnLevel()
  call void @FRAMEWIN_GetSkinFlexProps(ptr noundef %1, i32 noundef 0)
  %6 = getelementptr inbounds %struct.FRAMEWIN_SKINFLEX_PROPS, ptr %1, i32 0, i32 2
  store i32 0, ptr %6, align 8, !tbaa !5
  call void @FRAMEWIN_SetSkinFlexProps(ptr noundef %1, i32 noundef 0)
  call void @FRAMEWIN_GetSkinFlexProps(ptr noundef %1, i32 noundef 1)
  %7 = getelementptr inbounds %struct.FRAMEWIN_SKINFLEX_PROPS, ptr %1, i32 0, i32 2
  store i32 0, ptr %7, align 8, !tbaa !5
  call void @FRAMEWIN_SetSkinFlexProps(ptr noundef %1, i32 noundef 1)
  %8 = call ptr @FRAMEWIN_SetDefaultSkin(ptr noundef @_FRAMEWIN_DrawSkinFlex)
  %9 = call ptr @PROGBAR_SetDefaultSkin(ptr noundef @PROGBAR_DrawSkinFlex)
  %10 = call ptr @BUTTON_SetDefaultSkin(ptr noundef @BUTTON_DrawSkinFlex)
  %11 = call ptr @SCROLLBAR_SetDefaultSkin(ptr noundef @SCROLLBAR_DrawSkinFlex)
  %12 = call ptr @SLIDER_SetDefaultSkin(ptr noundef @SLIDER_DrawSkinFlex)
  %13 = call ptr @HEADER_SetDefaultSkin(ptr noundef @HEADER_DrawSkinFlex)
  %14 = call i32 @GUI_SetTextMode(i32 noundef 2)
  call void @GUIDEMO_Config(ptr noundef @_GUIDemoConfig)
  %15 = call i32 @LCD_GetBitsPerPixel()
  store i32 %15, ptr %3, align 4, !tbaa !10
  %16 = load i32, ptr %3, align 4, !tbaa !10
  %17 = icmp sge i32 %16, 16
  br i1 %17, label %18, label %30

18:                                               ; preds = %0
  %19 = call zeroext i16 @GUIDEMO_GetConfFlag(i16 noundef zeroext 4)
  %20 = zext i16 %19 to i32
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %30

22:                                               ; preds = %18
  %23 = call i64 @GUI_ALLOC_GetNumFreeBytes()
  %24 = trunc i64 %23 to i32
  store i32 %24, ptr %2, align 4, !tbaa !10
  %25 = load i32, ptr %2, align 4, !tbaa !10
  %26 = icmp sgt i32 %25, 2097152
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  store ptr @_DrawBkCircle, ptr @_pfDrawBk, align 8, !tbaa !11
  br label %29

28:                                               ; preds = %22
  store ptr @_DrawBk, ptr @_pfDrawBk, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %28, %27
  br label %31

30:                                               ; preds = %18, %0
  store ptr @_DrawBkSimple, ptr @_pfDrawBk, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %30, %29
  call void @GUIDEMO_SetDrawLogo(i8 noundef zeroext 1)
  br label %32

32:                                               ; preds = %33, %31
  br label %33

33:                                               ; preds = %32
  call void @_Main()
  br label %32
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @_cbEffect(i32 noundef, ptr noundef) #0

declare ptr @WM_SetCallback(i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @_cbBk(ptr noundef) #0

declare void @BUTTON_SetReactOnLevel() #2

declare void @FRAMEWIN_GetSkinFlexProps(ptr noundef, i32 noundef) #2

declare void @FRAMEWIN_SetSkinFlexProps(ptr noundef, i32 noundef) #2

declare ptr @FRAMEWIN_SetDefaultSkin(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @_FRAMEWIN_DrawSkinFlex(ptr noundef) #0

declare ptr @PROGBAR_SetDefaultSkin(ptr noundef) #2

declare i32 @PROGBAR_DrawSkinFlex(ptr noundef) #2

declare ptr @BUTTON_SetDefaultSkin(ptr noundef) #2

declare i32 @BUTTON_DrawSkinFlex(ptr noundef) #2

declare ptr @SCROLLBAR_SetDefaultSkin(ptr noundef) #2

declare i32 @SCROLLBAR_DrawSkinFlex(ptr noundef) #2

declare ptr @SLIDER_SetDefaultSkin(ptr noundef) #2

declare i32 @SLIDER_DrawSkinFlex(ptr noundef) #2

declare ptr @HEADER_SetDefaultSkin(ptr noundef) #2

declare i32 @HEADER_DrawSkinFlex(ptr noundef) #2

declare void @GUIDEMO_Config(ptr noundef) #2

declare i32 @LCD_GetBitsPerPixel() #2

declare i64 @GUI_ALLOC_GetNumFreeBytes() #2

; Function Attrs: nounwind uwtable
declare hidden void @_DrawBkCircle(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @_DrawBk(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @_DrawBkSimple(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @_Main() #0

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, !9, i64 40}
!6 = !{!"", !7, i64 0, !7, i64 24, !9, i64 40, !9, i64 44, !9, i64 48, !9, i64 52, !9, i64 56, !9, i64 60}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


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

%struct.GUIDEMO_CONFIG = type { ptr, i32, i16 }
%struct.FRAMEWIN_SKINFLEX_PROPS = type { [3 x i64], [2 x i64], i32, i32, i32, i32, i32, i32 }

@_pfDrawBk = external hidden local_unnamed_addr global ptr, align 8
@_GUIDemoConfig = external hidden global %struct.GUIDEMO_CONFIG, align 8
@_Pressed = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_SetDrawLogo(i8 noundef zeroext) local_unnamed_addr #0

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

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

declare i64 @WM_GetDesktopWindow() local_unnamed_addr #2

declare i32 @GUI_SetTextMode(i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind uwtable
define dso_local void @GUIDEMO_Main() local_unnamed_addr #3 {
  %1 = alloca %struct.FRAMEWIN_SKINFLEX_PROPS, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %1) #4
  tail call void @GUI_MEMDEV_SetAnimationCallback(ptr noundef nonnull @_cbEffect, ptr noundef nonnull @_Pressed) #4
  %2 = tail call i64 @WM_GetDesktopWindow() #4
  %3 = tail call ptr @WM_SetCallback(i64 noundef %2, ptr noundef nonnull @_cbBk) #4
  tail call void @BUTTON_SetReactOnLevel() #4
  call void @FRAMEWIN_GetSkinFlexProps(ptr noundef nonnull %1, i32 noundef 0) #4
  %4 = getelementptr inbounds i8, ptr %1, i64 40
  store i32 0, ptr %4, align 8, !tbaa !5
  call void @FRAMEWIN_SetSkinFlexProps(ptr noundef nonnull %1, i32 noundef 0) #4
  call void @FRAMEWIN_GetSkinFlexProps(ptr noundef nonnull %1, i32 noundef 1) #4
  store i32 0, ptr %4, align 8, !tbaa !5
  call void @FRAMEWIN_SetSkinFlexProps(ptr noundef nonnull %1, i32 noundef 1) #4
  %5 = call ptr @FRAMEWIN_SetDefaultSkin(ptr noundef nonnull @_FRAMEWIN_DrawSkinFlex) #4
  %6 = call ptr @PROGBAR_SetDefaultSkin(ptr noundef nonnull @PROGBAR_DrawSkinFlex) #4
  %7 = call ptr @BUTTON_SetDefaultSkin(ptr noundef nonnull @BUTTON_DrawSkinFlex) #4
  %8 = call ptr @SCROLLBAR_SetDefaultSkin(ptr noundef nonnull @SCROLLBAR_DrawSkinFlex) #4
  %9 = call ptr @SLIDER_SetDefaultSkin(ptr noundef nonnull @SLIDER_DrawSkinFlex) #4
  %10 = call ptr @HEADER_SetDefaultSkin(ptr noundef nonnull @HEADER_DrawSkinFlex) #4
  %11 = call i32 @GUI_SetTextMode(i32 noundef 2) #4
  call void @GUIDEMO_Config(ptr noundef nonnull @_GUIDemoConfig) #4
  %12 = call i32 @LCD_GetBitsPerPixel() #4
  %13 = icmp sgt i32 %12, 15
  br i1 %13, label %14, label %20

14:                                               ; preds = %0
  %15 = call zeroext i16 @GUIDEMO_GetConfFlag(i16 noundef zeroext 4)
  %.not = icmp eq i16 %15, 0
  br i1 %.not, label %20, label %16

16:                                               ; preds = %14
  %17 = call i64 @GUI_ALLOC_GetNumFreeBytes() #4
  %18 = trunc i64 %17 to i32
  %19 = icmp sgt i32 %18, 2097152
  %_DrawBkCircle._DrawBk = select i1 %19, ptr @_DrawBkCircle, ptr @_DrawBk
  br label %20

20:                                               ; preds = %0, %14, %16
  %_DrawBkCircle.sink = phi ptr [ %_DrawBkCircle._DrawBk, %16 ], [ @_DrawBkSimple, %14 ], [ @_DrawBkSimple, %0 ]
  store ptr %_DrawBkCircle.sink, ptr @_pfDrawBk, align 8, !tbaa !10
  call void @GUIDEMO_SetDrawLogo(i8 noundef zeroext 1)
  br label %21

21:                                               ; preds = %21, %20
  call void @_Main()
  br label %21
}

declare void @GUI_MEMDEV_SetAnimationCallback(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @_cbEffect(i32 noundef, ptr noundef) #0

declare ptr @WM_SetCallback(i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @_cbBk(ptr noundef) #0

declare void @BUTTON_SetReactOnLevel() local_unnamed_addr #2

declare void @FRAMEWIN_GetSkinFlexProps(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @FRAMEWIN_SetSkinFlexProps(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @FRAMEWIN_SetDefaultSkin(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @_FRAMEWIN_DrawSkinFlex(ptr noundef) #0

declare ptr @PROGBAR_SetDefaultSkin(ptr noundef) local_unnamed_addr #2

declare i32 @PROGBAR_DrawSkinFlex(ptr noundef) #2

declare ptr @BUTTON_SetDefaultSkin(ptr noundef) local_unnamed_addr #2

declare i32 @BUTTON_DrawSkinFlex(ptr noundef) #2

declare ptr @SCROLLBAR_SetDefaultSkin(ptr noundef) local_unnamed_addr #2

declare i32 @SCROLLBAR_DrawSkinFlex(ptr noundef) #2

declare ptr @SLIDER_SetDefaultSkin(ptr noundef) local_unnamed_addr #2

declare i32 @SLIDER_DrawSkinFlex(ptr noundef) #2

declare ptr @HEADER_SetDefaultSkin(ptr noundef) local_unnamed_addr #2

declare i32 @HEADER_DrawSkinFlex(ptr noundef) #2

declare void @GUIDEMO_Config(ptr noundef) local_unnamed_addr #2

declare i32 @LCD_GetBitsPerPixel() local_unnamed_addr #2

declare i64 @GUI_ALLOC_GetNumFreeBytes() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @_DrawBkCircle(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @_DrawBk(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @_DrawBkSimple(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @_Main() local_unnamed_addr #0

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 = { mustprogress 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 = { noreturn 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 #4 = { 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, !9, i64 40}
!6 = !{!"", !7, i64 0, !7, i64 24, !9, i64 40, !9, i64 44, !9, i64 48, !9, i64 52, !9, i64 56, !9, i64 60}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}


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