; 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.GUI_FONT = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, %union.anon, i8, i8, i8 }
%union.anon = type { ptr }

@GUI_FontRounded22 = external constant %struct.GUI_FONT, align 8
@GUI_Font16_ASCII = external constant %struct.GUI_FONT, align 8

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

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

declare i32 @GUI_Exec() #1

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_DrawBk(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_HideInfoWin() #2

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_ShowControlWin() #2

; Function Attrs: nounwind uwtable
define dso_local void @GUIDEMO_ShowIntro(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %12 = call i32 @LCD_GetXSize()
  store i32 %12, ptr %9, align 4, !tbaa !9
  %13 = call i32 @LCD_GetYSize()
  store i32 %13, ptr %10, align 4, !tbaa !9
  %14 = load i32, ptr %9, align 4, !tbaa !9
  %15 = ashr i32 %14, 1
  store i32 %15, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %10, align 4, !tbaa !9
  %17 = ashr i32 %16, 1
  store i32 %17, ptr %8, align 4, !tbaa !9
  call void @GUIDEMO_HideInfoWin()
  call void @GUIDEMO_ShowControlWin()
  %18 = call i32 @GUI_Exec()
  call void @GUIDEMO_DrawBk(i32 noundef 1)
  call void @GUI_SetColor(i64 noundef 16777215)
  %19 = call i32 @GUI_SetTextMode(i32 noundef 2)
  %20 = call ptr @GUI_SetFont(ptr noundef @GUI_FontRounded22)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !9
  call void @GUI_DispStringHCenterAt(ptr noundef %21, i32 noundef %22, i32 noundef 60)
  %23 = call ptr @GUI_SetFont(ptr noundef @GUI_Font16_ASCII)
  %24 = call i32 @GUI_GetFontDistY()
  store i32 %24, ptr %5, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sub nsw i32 %27, %28
  %30 = add nsw i32 %29, 10
  call void @GUI_DispStringHCenterAt(ptr noundef %25, i32 noundef %26, i32 noundef %30)
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %38, %2
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i8, ptr %32, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %31
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %11, align 4, !tbaa !9
  br label %31, !llvm.loop !12

41:                                               ; preds = %31
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = mul nsw i32 %42, 80
  store i32 %43, ptr %6, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !9
  call void @GUIDEMO_Wait(i32 noundef %44)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

declare i32 @LCD_GetXSize() #1

declare i32 @LCD_GetYSize() #1

declare void @GUI_SetColor(i64 noundef) #1

declare i32 @GUI_SetTextMode(i32 noundef) #1

declare ptr @GUI_SetFont(ptr noundef) #1

declare void @GUI_DispStringHCenterAt(ptr noundef, i32 noundef, i32 noundef) #1

declare i32 @GUI_GetFontDistY() #1

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_Wait(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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.GUI_FONT = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, %union.anon, i8, i8, i8 }
%union.anon = type { ptr }

@GUI_FontRounded22 = external constant %struct.GUI_FONT, align 8
@GUI_Font16_ASCII = external constant %struct.GUI_FONT, align 8

declare i32 @GUI_Exec() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_DrawBk(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_HideInfoWin() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_ShowControlWin() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @GUIDEMO_ShowIntro(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 @LCD_GetXSize() #2
  %4 = tail call i32 @LCD_GetYSize() #2
  %5 = ashr i32 %3, 1
  %6 = ashr i32 %4, 1
  tail call void @GUIDEMO_HideInfoWin()
  tail call void @GUIDEMO_ShowControlWin()
  %7 = tail call i32 @GUI_Exec() #2
  tail call void @GUIDEMO_DrawBk(i32 noundef 1)
  tail call void @GUI_SetColor(i64 noundef 16777215) #2
  %8 = tail call i32 @GUI_SetTextMode(i32 noundef 2) #2
  %9 = tail call ptr @GUI_SetFont(ptr noundef nonnull @GUI_FontRounded22) #2
  tail call void @GUI_DispStringHCenterAt(ptr noundef %0, i32 noundef %5, i32 noundef 60) #2
  %10 = tail call ptr @GUI_SetFont(ptr noundef nonnull @GUI_Font16_ASCII) #2
  %11 = tail call i32 @GUI_GetFontDistY() #2
  %12 = add nsw i32 %6, 10
  %13 = sub i32 %12, %11
  tail call void @GUI_DispStringHCenterAt(ptr noundef %1, i32 noundef %5, i32 noundef %13) #2
  br label %14

14:                                               ; preds = %14, %2
  %indvars.iv = phi i64 [ %indvars.iv.next, %14 ], [ 0, %2 ]
  %15 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not = icmp eq i8 %16, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not, label %17, label %14, !llvm.loop !8

17:                                               ; preds = %14
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  %19 = mul nuw nsw i32 %18, 80
  tail call void @GUIDEMO_Wait(i32 noundef %19)
  ret void
}

declare i32 @LCD_GetXSize() local_unnamed_addr #0

declare i32 @LCD_GetYSize() local_unnamed_addr #0

declare void @GUI_SetColor(i64 noundef) local_unnamed_addr #0

declare i32 @GUI_SetTextMode(i32 noundef) local_unnamed_addr #0

declare ptr @GUI_SetFont(ptr noundef) local_unnamed_addr #0

declare void @GUI_DispStringHCenterAt(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @GUI_GetFontDistY() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @GUIDEMO_Wait(i32 noundef) local_unnamed_addr #1

attributes #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 = { 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 #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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,TailCallElimPass