; LLVM IR from Dovyski/opengl-demos :: src/model-md2/main.ll (Z7Displayv)

; 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.CMD2Model = type <{ i32, i32, i32, [4 x i8], ptr, ptr, ptr, i32, %struct.animState_t, float, [4 x i8] }>
%struct.animState_t = type { i32, i32, i32, float, float, float, i32, i32, i32 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"struct.std::_Setprecision" = type { i32 }

@Ogro = external dso_local global %class.CMD2Model, align 8
@Weapon = external dso_local global %class.CMD2Model, align 8
@bAnimated = external dso_local global i8, align 1
@angle = external dso_local global float, align 4
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@g_angle = external global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7Displayv() #0 {
  %1 = alloca float, align 4
  %2 = alloca %"struct.std::_Setprecision", align 4
  call void @glClear(i32 noundef 16640)
  call void @glLoadIdentity()
  %3 = call noundef ptr @_ZN6CTimer11GetInstanceEv()
  call void @_ZN6CTimer6UpdateEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  %4 = call noundef ptr @_ZN6CTimer11GetInstanceEv()
  %5 = call noundef i64 @_ZN6CTimer11GetTimeMSecEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %6 = uitofp i64 %5 to double
  %7 = fdiv double %6, 1.000000e+03
  %8 = fptrunc double %7 to float
  store float %8, ptr %1, align 4, !tbaa !5
  %9 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %10 = call i32 @_ZSt12setprecisioni(i32 noundef 4)
  %11 = getelementptr inbounds %"struct.std::_Setprecision", ptr %2, i32 0, i32 0
  store i32 %10, ptr %11, align 4
  %12 = getelementptr inbounds %"struct.std::_Setprecision", ptr %2, i32 0, i32 0
  %13 = load i32, ptr %12, align 4
  %14 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision(ptr noundef nonnull align 8 dereferenceable(8) %9, i32 %13)
  %15 = call noundef ptr @_ZN6CTimer11GetInstanceEv()
  %16 = call noundef float @_ZN6CTimer6GetFpsEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEf(ptr noundef nonnull align 8 dereferenceable(8) %14, float noundef %16)
  %18 = load float, ptr @g_angle, align 4, !tbaa !5
  %19 = fpext float %18 to double
  %20 = fcmp ogt double %19, 3.600000e+02
  br i1 %20, label %21, label %26

21:                                               ; preds = %0
  %22 = load float, ptr @g_angle, align 4, !tbaa !5
  %23 = fpext float %22 to double
  %24 = fsub double %23, 3.600000e+02
  %25 = fptrunc double %24 to float
  store float %25, ptr @g_angle, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %21, %0
  %27 = load float, ptr @g_angle, align 4, !tbaa !5
  %28 = fpext float %27 to double
  %29 = fcmp olt double %28, 0.000000e+00
  br i1 %29, label %30, label %35

30:                                               ; preds = %26
  %31 = load float, ptr @g_angle, align 4, !tbaa !5
  %32 = fpext float %31 to double
  %33 = fadd double %32, 3.600000e+02
  %34 = fptrunc double %33 to float
  store float %34, ptr @g_angle, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %30, %26
  %36 = load float, ptr @angle, align 4, !tbaa !5
  %37 = fpext float %36 to double
  %38 = fcmp olt double %37, 0.000000e+00
  br i1 %38, label %39, label %44

39:                                               ; preds = %35
  %40 = load float, ptr @angle, align 4, !tbaa !5
  %41 = fpext float %40 to double
  %42 = fadd double %41, 3.600000e+02
  %43 = fptrunc double %42 to float
  store float %43, ptr @angle, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %39, %35
  %45 = load float, ptr @angle, align 4, !tbaa !5
  %46 = fpext float %45 to double
  %47 = fcmp ogt double %46, 3.600000e+02
  br i1 %47, label %48, label %53

48:                                               ; preds = %44
  %49 = load float, ptr @angle, align 4, !tbaa !5
  %50 = fpext float %49 to double
  %51 = fsub double %50, 3.600000e+02
  %52 = fptrunc double %51 to float
  store float %52, ptr @angle, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %48, %44
  call void @glTranslatef(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef -2.500000e+01)
  %54 = load float, ptr @angle, align 4, !tbaa !5
  call void @glRotatef(float noundef %54, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %55 = load i8, ptr @bAnimated, align 1, !tbaa !9, !range !11, !noundef !12
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %60

57:                                               ; preds = %53
  %58 = load float, ptr %1, align 4, !tbaa !5
  %59 = fpext float %58 to double
  br label %61

60:                                               ; preds = %53
  br label %61

61:                                               ; preds = %60, %57
  %62 = phi double [ %59, %57 ], [ 0.000000e+00, %60 ]
  %63 = fptrunc double %62 to float
  call void @_ZN9CMD2Model9DrawModelEf(ptr noundef nonnull align 8 dereferenceable(84) @Ogro, float noundef %63)
  %64 = load i8, ptr @bAnimated, align 1, !tbaa !9, !range !11, !noundef !12
  %65 = trunc i8 %64 to i1
  br i1 %65, label %66, label %69

66:                                               ; preds = %61
  %67 = load float, ptr %1, align 4, !tbaa !5
  %68 = fpext float %67 to double
  br label %70

69:                                               ; preds = %61
  br label %70

70:                                               ; preds = %69, %66
  %71 = phi double [ %68, %66 ], [ 0.000000e+00, %69 ]
  %72 = fptrunc double %71 to float
  call void @_ZN9CMD2Model9DrawModelEf(ptr noundef nonnull align 8 dereferenceable(84) @Weapon, float noundef %72)
  call void @glutSwapBuffers()
  call void @glutPostRedisplay()
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

declare void @glClear(i32 noundef) #1

declare void @glLoadIdentity() #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN6CTimer11GetInstanceEv() #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6CTimer6UpdateEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN6CTimer11GetTimeMSecEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision(ptr noundef nonnull align 8 dereferenceable(8), i32) #3

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i32 @_ZSt12setprecisioni(i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEf(ptr noundef nonnull align 8 dereferenceable(8), float noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN6CTimer6GetFpsEv(ptr noundef nonnull align 8 dereferenceable(16)) #5 align 2

declare void @glTranslatef(float noundef, float noundef, float noundef) #1

declare void @glRotatef(float noundef, float noundef, float noundef, float noundef) #1

declare void @_ZN9CMD2Model9DrawModelEf(ptr noundef nonnull align 8 dereferenceable(84), float noundef) #1

declare void @glutSwapBuffers() #1

declare void @glutPostRedisplay() #1

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

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" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { inlinehint mustprogress 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 #5 = { mustprogress 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 #6 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


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

%class.CMD2Model = type <{ i32, i32, i32, [4 x i8], ptr, ptr, ptr, i32, %struct.animState_t, float, [4 x i8] }>
%struct.animState_t = type { i32, i32, i32, float, float, float, i32, i32, i32 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@Ogro = external dso_local global %class.CMD2Model, align 8
@Weapon = external dso_local global %class.CMD2Model, align 8
@bAnimated = external dso_local local_unnamed_addr global i8, align 1
@angle = external dso_local local_unnamed_addr global float, align 4
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@g_angle = external local_unnamed_addr global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7Displayv() local_unnamed_addr #0 {
  tail call void @glClear(i32 noundef 16640)
  tail call void @glLoadIdentity()
  %1 = tail call noundef ptr @_ZN6CTimer11GetInstanceEv()
  tail call void @_ZN6CTimer6UpdateEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %2 = tail call noundef ptr @_ZN6CTimer11GetInstanceEv()
  %3 = tail call noundef i64 @_ZN6CTimer11GetTimeMSecEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  %5 = tail call i32 @_ZSt12setprecisioni(i32 noundef 4)
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 %5)
  %7 = tail call noundef ptr @_ZN6CTimer11GetInstanceEv()
  %8 = tail call noundef float @_ZN6CTimer6GetFpsEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEf(ptr noundef nonnull align 8 dereferenceable(8) %6, float noundef %8)
  %10 = load float, ptr @g_angle, align 4, !tbaa !5
  %11 = fcmp ogt float %10, 3.600000e+02
  %12 = fadd float %10, -3.600000e+02
  %13 = select i1 %11, float %12, float %10
  %14 = fcmp olt float %13, 0.000000e+00
  %15 = or i1 %11, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %0
  %17 = fadd float %13, 3.600000e+02
  %simplifycfg.merge = select i1 %14, float %17, float %13
  store float %simplifycfg.merge, ptr @g_angle, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %0, %16
  %19 = load float, ptr @angle, align 4, !tbaa !5
  %20 = fcmp olt float %19, 0.000000e+00
  %21 = fadd float %19, 3.600000e+02
  %22 = select i1 %20, float %21, float %19
  %23 = fcmp ogt float %22, 3.600000e+02
  %24 = or i1 %20, %23
  br i1 %24, label %25, label %27

25:                                               ; preds = %18
  %26 = fadd float %22, -3.600000e+02
  %simplifycfg.merge5 = select i1 %23, float %26, float %22
  store float %simplifycfg.merge5, ptr @angle, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %18, %25
  %28 = uitofp i64 %3 to double
  %29 = fdiv double %28, 1.000000e+03
  %30 = fptrunc double %29 to float
  tail call void @glTranslatef(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef -2.500000e+01)
  %31 = load float, ptr @angle, align 4, !tbaa !5
  tail call void @glRotatef(float noundef %31, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %32 = load i8, ptr @bAnimated, align 1, !tbaa !9, !range !11, !noundef !12
  %33 = trunc nuw i8 %32 to i1
  %34 = select i1 %33, float %30, float 0.000000e+00
  tail call void @_ZN9CMD2Model9DrawModelEf(ptr noundef nonnull align 8 dereferenceable(84) @Ogro, float noundef %34)
  %35 = load i8, ptr @bAnimated, align 1, !tbaa !9, !range !11, !noundef !12
  %36 = trunc nuw i8 %35 to i1
  %37 = select i1 %36, float %30, float 0.000000e+00
  tail call void @_ZN9CMD2Model9DrawModelEf(ptr noundef nonnull align 8 dereferenceable(84) @Weapon, float noundef %37)
  tail call void @glutSwapBuffers()
  tail call void @glutPostRedisplay()
  ret void
}

declare void @glClear(i32 noundef) local_unnamed_addr #1

declare void @glLoadIdentity() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN6CTimer11GetInstanceEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6CTimer6UpdateEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN6CTimer11GetTimeMSecEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision(ptr noundef nonnull align 8 dereferenceable(8), i32) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i32 @_ZSt12setprecisioni(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEf(ptr noundef nonnull align 8 dereferenceable(8), float noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN6CTimer6GetFpsEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

declare void @glTranslatef(float noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @glRotatef(float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @_ZN9CMD2Model9DrawModelEf(ptr noundef nonnull align 8 dereferenceable(84), float noundef) local_unnamed_addr #1

declare void @glutSwapBuffers() local_unnamed_addr #1

declare void @glutPostRedisplay() 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" }
attributes #2 = { inlinehint 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 #3 = { inlinehint mustprogress 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 = { mustprogress 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" }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


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