; LLVM IR from NotManyIdeasDev/double-pendulum-sim :: double-pendulum-sim/Libraries/raygui-2.8/examples/controls_test_suite (GuiLoadIcons)

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

@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@guiIcons = external hidden global <{ [1599 x i32], [449 x i32] }>, align 16

; 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare i32 @fclose(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @GuiLoadIcons(ptr noundef %0, i1 noundef zeroext %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [5 x i8], align 1
  %8 = alloca i16, align 2
  %9 = alloca i16, align 2
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %13 = zext i1 %1 to i8
  store i8 %13, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call noalias ptr @fopen(ptr noundef %14, ptr noundef @.str.6)
  store ptr %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %96

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 5, ptr %7) #5
  call void @llvm.memset.p0.i64(ptr align 1 %7, i8 0, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #5
  store i16 0, ptr %8, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #5
  store i16 0, ptr %9, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #5
  store i16 0, ptr %10, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #5
  store i16 0, ptr %11, align 2, !tbaa !11
  %19 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 0
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i64 @fread(ptr noundef %19, i64 noundef 1, i64 noundef 4, ptr noundef %20)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call i64 @fread(ptr noundef %8, i64 noundef 1, i64 noundef 2, ptr noundef %22)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i64 @fread(ptr noundef %9, i64 noundef 1, i64 noundef 2, ptr noundef %24)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i64 @fread(ptr noundef %10, i64 noundef 1, i64 noundef 2, ptr noundef %26)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call i64 @fread(ptr noundef %11, i64 noundef 1, i64 noundef 2, ptr noundef %28)
  %30 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 0
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 114
  br i1 %33, label %34, label %93

34:                                               ; preds = %18
  %35 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 1
  %36 = load i8, ptr %35, align 1, !tbaa !13
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %37, 71
  br i1 %38, label %39, label %93

39:                                               ; preds = %34
  %40 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 2
  %41 = load i8, ptr %40, align 1, !tbaa !13
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, 73
  br i1 %43, label %44, label %93

44:                                               ; preds = %39
  %45 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 3
  %46 = load i8, ptr %45, align 1, !tbaa !13
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 32
  br i1 %48, label %49, label %93

49:                                               ; preds = %44
  %50 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %51 = trunc i8 %50 to i1
  br i1 %51, label %52, label %80

52:                                               ; preds = %49
  %53 = load i16, ptr %10, align 2, !tbaa !11
  %54 = sext i16 %53 to i64
  %55 = mul i64 %54, 8
  %56 = call noalias ptr @malloc(i64 noundef %55) #6
  store ptr %56, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !16
  br label %57

57:                                               ; preds = %76, %52
  %58 = load i32, ptr %12, align 4, !tbaa !16
  %59 = load i16, ptr %10, align 2, !tbaa !11
  %60 = sext i16 %59 to i32
  %61 = icmp slt i32 %58, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %79

63:                                               ; preds = %57
  %64 = call noalias ptr @malloc(i64 noundef 32) #6
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load i32, ptr %12, align 4, !tbaa !16
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  store ptr %64, ptr %68, align 8, !tbaa !5
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = load i32, ptr %12, align 4, !tbaa !16
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = call i64 @fread(ptr noundef %73, i64 noundef 32, i64 noundef 1, ptr noundef %74)
  br label %76

76:                                               ; preds = %63
  %77 = load i32, ptr %12, align 4, !tbaa !16
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %12, align 4, !tbaa !16
  br label %57, !llvm.loop !18

79:                                               ; preds = %62
  br label %80

80:                                               ; preds = %79, %49
  %81 = load i16, ptr %10, align 2, !tbaa !11
  %82 = sext i16 %81 to i32
  %83 = load i16, ptr %11, align 2, !tbaa !11
  %84 = sext i16 %83 to i32
  %85 = load i16, ptr %11, align 2, !tbaa !11
  %86 = sext i16 %85 to i32
  %87 = mul nsw i32 %84, %86
  %88 = sdiv i32 %87, 32
  %89 = mul nsw i32 %82, %88
  %90 = sext i32 %89 to i64
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = call i64 @fread(ptr noundef @guiIcons, i64 noundef %90, i64 noundef 4, ptr noundef %91)
  br label %93

93:                                               ; preds = %80, %44, %39, %34, %18
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = call i32 @fclose(ptr noundef %94)
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 5, ptr %7) #5
  br label %96

96:                                               ; preds = %93, %2
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret ptr %97
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 allocsize(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 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 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@guiIcons = external hidden global <{ [1599 x i32], [449 x i32] }>, align 16

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind uwtable
define dso_local noalias noundef ptr @GuiLoadIcons(ptr nocapture noundef readonly %0, i1 noundef zeroext %1) local_unnamed_addr #4 {
  %3 = alloca [5 x i8], align 4
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  %8 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.6)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %36, label %9

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %3) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(5) %3, i8 0, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #5
  store i16 0, ptr %4, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #5
  store i16 0, ptr %5, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %6) #5
  store i16 0, ptr %6, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %7) #5
  store i16 0, ptr %7, align 2, !tbaa !5
  %10 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 1, i64 noundef 4, ptr noundef nonnull %8)
  %11 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 2, ptr noundef nonnull %8)
  %12 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 1, i64 noundef 2, ptr noundef nonnull %8)
  %13 = call i64 @fread(ptr noundef nonnull %6, i64 noundef 1, i64 noundef 2, ptr noundef nonnull %8)
  %14 = call i64 @fread(ptr noundef nonnull %7, i64 noundef 1, i64 noundef 2, ptr noundef nonnull %8)
  %15 = load <4 x i8>, ptr %3, align 4
  %.fr = freeze <4 x i8> %15
  %.fr.scalar = bitcast <4 x i8> %.fr to i32
  %16 = icmp eq i32 %.fr.scalar, 541673330
  br i1 %16, label %17, label %34

17:                                               ; preds = %9
  %.pre = load i16, ptr %6, align 2, !tbaa !5
  br i1 %1, label %18, label %..loopexit_crit_edge

..loopexit_crit_edge:                             ; preds = %17
  %.pre32 = sext i16 %.pre to i32
  br label %.loopexit

18:                                               ; preds = %17
  %19 = sext i16 %.pre to i64
  %20 = shl nsw i64 %19, 3
  %21 = tail call noalias ptr @malloc(i64 noundef %20) #6
  %22 = sext i16 %.pre to i32
  %23 = icmp sgt i16 %.pre, 0
  br i1 %23, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %18
  %wide.trip.count = zext nneg i32 %22 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %24 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
  %25 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv
  store ptr %24, ptr %25, align 8, !tbaa !9
  %26 = tail call i64 @fread(ptr noundef %24, i64 noundef 32, i64 noundef 1, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph, %..loopexit_crit_edge, %18
  %.pre-phi = phi i32 [ %.pre32, %..loopexit_crit_edge ], [ %22, %18 ], [ %22, %.lr.ph ]
  %.028 = phi ptr [ null, %..loopexit_crit_edge ], [ %21, %18 ], [ %21, %.lr.ph ]
  %27 = load i16, ptr %7, align 2, !tbaa !5
  %28 = sext i16 %27 to i32
  %29 = mul nsw i32 %28, %28
  %30 = lshr i32 %29, 5
  %31 = mul nsw i32 %30, %.pre-phi
  %32 = sext i32 %31 to i64
  %33 = tail call i64 @fread(ptr noundef nonnull @guiIcons, i64 noundef %32, i64 noundef 4, ptr noundef nonnull %8)
  br label %34

34:                                               ; preds = %.loopexit, %9
  %.1 = phi ptr [ %.028, %.loopexit ], [ null, %9 ]
  %35 = tail call i32 @fclose(ptr noundef nonnull %8)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %3) #5
  br label %36

36:                                               ; preds = %34, %2
  %.2 = phi ptr [ %.1, %34 ], [ null, %2 ]
  ret ptr %.2
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nofree nounwind "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree 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 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass