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

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

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [38 x i8], align 1
@_ySpace = external hidden global i32, align 4
@bmSTLogo70x35 = external constant %struct.GUI_BITMAP, align 8
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@_ShowMSec = external hidden global i32, align 4
@GUI_FontRounded22 = external constant %struct.GUI_FONT, align 8
@_ShowGear = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @GUIDEMO_Automotive() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, 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 @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @GUIDEMO_ShowIntro(ptr noundef @.str, ptr noundef @.str.1)
  %5 = call i32 @LCD_GetXSize()
  store i32 %5, ptr %2, align 4, !tbaa !5
  %6 = call i32 @LCD_GetYSize()
  store i32 %6, ptr %3, align 4, !tbaa !5
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = sub nsw i32 %7, 196
  %9 = sdiv i32 %8, 3
  store i32 %9, ptr @_ySpace, align 4, !tbaa !5
  %10 = load i16, ptr @bmSTLogo70x35, align 8, !tbaa !9
  %11 = zext i16 %10 to i32
  %12 = add nsw i32 %11, 5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sub nsw i32 %13, 200
  %15 = ashr i32 %14, 1
  %16 = icmp slt i32 %12, %15
  br i1 %16, label %23, label %17

17:                                               ; preds = %0
  %18 = load i16, ptr getelementptr inbounds (%struct.GUI_BITMAP, ptr @bmSTLogo70x35, i32 0, i32 1), align 2, !tbaa !13
  %19 = zext i16 %18 to i32
  %20 = add nsw i32 %19, 5
  %21 = load i32, ptr @_ySpace, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %17, %0
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %23, %17
  %25 = call i32 @GUI_GetStringDistX(ptr noundef @.str.2)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sub nsw i32 %26, 200
  %28 = ashr i32 %27, 1
  %29 = icmp slt i32 %25, %28
  br i1 %29, label %37, label %30

30:                                               ; preds = %24
  %31 = load i32, ptr @_ySpace, align 4, !tbaa !5
  %32 = add nsw i32 %31, 98
  %33 = mul nsw i32 2, %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sub nsw i32 %34, 40
  %36 = icmp slt i32 %33, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %30, %24
  store i32 1, ptr @_ShowMSec, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %37, %30
  %39 = call ptr @GUI_SetFont(ptr noundef @GUI_FontRounded22)
  store ptr %39, ptr %1, align 8, !tbaa !14
  %40 = load i32, ptr @_ySpace, align 4, !tbaa !5
  %41 = call i32 @GUI_GetFontDistY()
  %42 = add nsw i32 %41, 1
  %43 = icmp sgt i32 %40, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  store i32 1, ptr @_ShowGear, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %44, %38
  %46 = load ptr, ptr %1, align 8, !tbaa !14
  %47 = call ptr @GUI_SetFont(ptr noundef %46)
  %48 = load i32, ptr %4, align 4, !tbaa !5
  call void @_DrawBk(i32 noundef %48)
  call void @GUI_AA_EnableHiRes()
  call void @GUI_AA_SetFactor(i32 noundef 3)
  call void @_AutomotiveDemo()
  call void @GUI_AA_DisableHiRes()
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #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 @GUIDEMO_ShowIntro(ptr noundef, ptr noundef) #2

declare i32 @LCD_GetXSize() #2

declare i32 @LCD_GetYSize() #2

declare i32 @GUI_GetStringDistX(ptr noundef) #2

declare ptr @GUI_SetFont(ptr noundef) #2

declare i32 @GUI_GetFontDistY() #2

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

declare void @GUI_AA_EnableHiRes() #2

declare void @GUI_AA_SetFactor(i32 noundef) #2

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

declare void @GUI_AA_DisableHiRes() #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !12, i64 8, !12, i64 16, !12, i64 24}
!11 = !{!"short", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !11, i64 2}
!14 = !{!12, !12, 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.GUI_BITMAP = type { i16, i16, i16, i16, ptr, ptr, ptr }
%struct.GUI_FONT = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, %union.anon, i8, i8, i8 }
%union.anon = type { ptr }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [38 x i8], align 1
@_ySpace = external hidden local_unnamed_addr global i32, align 4
@bmSTLogo70x35 = external local_unnamed_addr constant %struct.GUI_BITMAP, align 8
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@_ShowMSec = external hidden local_unnamed_addr global i32, align 4
@GUI_FontRounded22 = external constant %struct.GUI_FONT, align 8
@_ShowGear = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @GUIDEMO_Automotive() local_unnamed_addr #0 {
  tail call void @GUIDEMO_ShowIntro(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #2
  %1 = tail call i32 @LCD_GetXSize() #2
  %2 = tail call i32 @LCD_GetYSize() #2
  %3 = add nsw i32 %2, -196
  %4 = sdiv i32 %3, 3
  store i32 %4, ptr @_ySpace, align 4, !tbaa !5
  %5 = load i16, ptr @bmSTLogo70x35, align 8, !tbaa !9
  %6 = zext i16 %5 to i32
  %7 = add nuw nsw i32 %6, 5
  %8 = add nsw i32 %1, -200
  %9 = ashr i32 %8, 1
  %10 = icmp slt i32 %7, %9
  br i1 %10, label %16, label %11

11:                                               ; preds = %0
  %12 = load i16, ptr getelementptr inbounds (i8, ptr @bmSTLogo70x35, i64 2), align 2, !tbaa !13
  %13 = zext i16 %12 to i32
  %14 = add nuw nsw i32 %13, 5
  %15 = icmp slt i32 %14, %4
  br i1 %15, label %16, label %17

16:                                               ; preds = %11, %0
  br label %17

17:                                               ; preds = %16, %11
  %.0 = phi i32 [ 1, %16 ], [ 0, %11 ]
  %18 = tail call i32 @GUI_GetStringDistX(ptr noundef nonnull @.str.2) #2
  %19 = icmp slt i32 %18, %9
  br i1 %19, label %26, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr @_ySpace, align 4, !tbaa !5
  %22 = shl i32 %21, 1
  %23 = add i32 %22, 196
  %24 = add nsw i32 %2, -40
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %20, %17
  store i32 1, ptr @_ShowMSec, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %26, %20
  %28 = tail call ptr @GUI_SetFont(ptr noundef nonnull @GUI_FontRounded22) #2
  %29 = load i32, ptr @_ySpace, align 4, !tbaa !5
  %30 = tail call i32 @GUI_GetFontDistY() #2
  %31 = add nsw i32 %30, 1
  %32 = icmp sgt i32 %29, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store i32 1, ptr @_ShowGear, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %33, %27
  %35 = tail call ptr @GUI_SetFont(ptr noundef %28) #2
  tail call void @_DrawBk(i32 noundef %.0)
  tail call void @GUI_AA_EnableHiRes() #2
  tail call void @GUI_AA_SetFactor(i32 noundef 3) #2
  tail call void @_AutomotiveDemo()
  tail call void @GUI_AA_DisableHiRes() #2
  ret void
}

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

declare i32 @LCD_GetXSize() local_unnamed_addr #1

declare i32 @LCD_GetYSize() local_unnamed_addr #1

declare i32 @GUI_GetStringDistX(ptr noundef) local_unnamed_addr #1

declare ptr @GUI_SetFont(ptr noundef) local_unnamed_addr #1

declare i32 @GUI_GetFontDistY() local_unnamed_addr #1

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

declare void @GUI_AA_EnableHiRes() local_unnamed_addr #1

declare void @GUI_AA_SetFactor(i32 noundef) local_unnamed_addr #1

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

declare void @GUI_AA_DisableHiRes() 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !12, i64 8, !12, i64 16, !12, i64 24}
!11 = !{!"short", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !11, i64 2}


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