; LLVM IR from paroj/gltut :: framework/Timer.ll (ZN9Framework5Timer6UpdateEv)

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

%"class.Framework::Timer" = type { i32, float, i8, i8, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN9Framework5Timer6UpdateEv(ptr noundef nonnull align 4 dereferenceable(20) %0) #0 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %8 = call i32 @glutGet(i32 noundef 700)
  %9 = sitofp i32 %8 to float
  %10 = fdiv float %9, 1.000000e+03
  store float %10, ptr %4, align 4, !tbaa !9
  %11 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 2
  %12 = load i8, ptr %11, align 4, !tbaa !11, !range !15, !noundef !16
  %13 = trunc i8 %12 to i1
  br i1 %13, label %18, label %14

14:                                               ; preds = %1
  %15 = load float, ptr %4, align 4, !tbaa !9
  %16 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 4
  store float %15, ptr %16, align 4, !tbaa !17
  %17 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 2
  store i8 1, ptr %17, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %14, %1
  %19 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 3
  %20 = load i8, ptr %19, align 1, !tbaa !18, !range !15, !noundef !16
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %25

22:                                               ; preds = %18
  %23 = load float, ptr %4, align 4, !tbaa !9
  %24 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 4
  store float %23, ptr %24, align 4, !tbaa !17
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %47

25:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %26 = load float, ptr %4, align 4, !tbaa !9
  %27 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 4
  %28 = load float, ptr %27, align 4, !tbaa !17
  %29 = fsub float %26, %28
  store float %29, ptr %6, align 4, !tbaa !9
  %30 = load float, ptr %6, align 4, !tbaa !9
  %31 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 5
  %32 = load float, ptr %31, align 4, !tbaa !19
  %33 = fadd float %32, %30
  store float %33, ptr %31, align 4, !tbaa !19
  %34 = load float, ptr %4, align 4, !tbaa !9
  %35 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 4
  store float %34, ptr %35, align 4, !tbaa !17
  %36 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 0
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %38 = icmp eq i32 %37, 1
  br i1 %38, label %39, label %45

39:                                               ; preds = %25
  %40 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 5
  %41 = load float, ptr %40, align 4, !tbaa !19
  %42 = getelementptr inbounds %"class.Framework::Timer", ptr %7, i32 0, i32 1
  %43 = load float, ptr %42, align 4, !tbaa !21
  %44 = fcmp ogt float %41, %43
  store i1 %44, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %46

45:                                               ; preds = %25
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %46

46:                                               ; preds = %45, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %47

47:                                               ; preds = %46, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %48 = load i1, ptr %2, align 1
  ret i1 %48
}

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

declare i32 @glutGet(i32 noundef) #2

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

attributes #0 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTSN9Framework5TimerE", !13, i64 0, !10, i64 4, !14, i64 8, !14, i64 9, !10, i64 12, !10, i64 16}
!13 = !{!"_ZTSN9Framework5Timer4TypeE", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !10, i64 12}
!18 = !{!12, !14, i64 9}
!19 = !{!12, !10, i64 16}
!20 = !{!12, !13, i64 0}
!21 = !{!12, !10, i64 4}


; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN9Framework5Timer6UpdateEv(ptr nocapture noundef nonnull align 4 dereferenceable(20) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call i32 @glutGet(i32 noundef 700)
  %3 = sitofp i32 %2 to float
  %4 = fdiv float %3, 1.000000e+03
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !12, !noundef !13
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %10, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  store float %4, ptr %9, align 4, !tbaa !14
  store i8 1, ptr %5, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %8, %1
  %11 = getelementptr inbounds i8, ptr %0, i64 9
  %12 = load i8, ptr %11, align 1, !tbaa !15, !range !12, !noundef !13
  %13 = trunc nuw i8 %12 to i1
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  br i1 %13, label %15, label %16

15:                                               ; preds = %10
  store float %4, ptr %14, align 4, !tbaa !14
  br label %27

16:                                               ; preds = %10
  %17 = load float, ptr %14, align 4, !tbaa !14
  %18 = fsub float %4, %17
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load float, ptr %19, align 4, !tbaa !16
  %21 = fadd float %20, %18
  store float %21, ptr %19, align 4, !tbaa !16
  store float %4, ptr %14, align 4, !tbaa !14
  %22 = load i32, ptr %0, align 4, !tbaa !17
  %23 = icmp eq i32 %22, 1
  %24 = getelementptr inbounds i8, ptr %0, i64 4
  %25 = load float, ptr %24, align 4
  %26 = fcmp ogt float %21, %25
  %.0 = select i1 %23, i1 %26, i1 false
  br label %27

27:                                               ; preds = %16, %15
  %.1 = phi i1 [ false, %15 ], [ %.0, %16 ]
  ret i1 %.1
}

declare i32 @glutGet(i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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" }

!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, !11, i64 8}
!6 = !{!"_ZTSN9Framework5TimerE", !7, i64 0, !10, i64 4, !11, i64 8, !11, i64 9, !10, i64 12, !10, i64 16}
!7 = !{!"_ZTSN9Framework5Timer4TypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !11, i64 9}
!16 = !{!6, !10, i64 16}
!17 = !{!6, !7, i64 0}


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