; LLVM IR from paroj/gltut :: Tut 01 Hello Triangle/Tut1.ll (Z13CreateProgramRKSt6vectorIjSaIjEE)

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

@stderr = external global ptr, align 8
@_funcptr_glCreateProgram = external global ptr, align 8
@_funcptr_glAttachShader = external global ptr, align 8
@_funcptr_glLinkProgram = external global ptr, align 8
@_funcptr_glGetProgramiv = external global ptr, align 8
@_funcptr_glGetProgramInfoLog = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1
@_funcptr_glDetachShader = external global ptr, 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z13CreateProgramRKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(24) %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %9 = load ptr, ptr @_funcptr_glCreateProgram, align 8, !tbaa !5
  %10 = call i32 %9()
  store i32 %10, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %24, %1
  %12 = load i64, ptr %4, align 8, !tbaa !11
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #6
  %15 = icmp ult i64 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %27

17:                                               ; preds = %11
  %18 = load ptr, ptr @_funcptr_glAttachShader, align 8, !tbaa !5
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = load i64, ptr %4, align 8, !tbaa !11
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %20, i64 noundef %21) #6
  %23 = load i32, ptr %22, align 4, !tbaa !9
  call void %18(i32 noundef %19, i32 noundef %23)
  br label %24

24:                                               ; preds = %17
  %25 = load i64, ptr %4, align 8, !tbaa !11
  %26 = add i64 %25, 1
  store i64 %26, ptr %4, align 8, !tbaa !11
  br label %11, !llvm.loop !13

27:                                               ; preds = %16
  %28 = load ptr, ptr @_funcptr_glLinkProgram, align 8, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !9
  call void %28(i32 noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %30 = load ptr, ptr @_funcptr_glGetProgramiv, align 8, !tbaa !5
  %31 = load i32, ptr %3, align 4, !tbaa !9
  call void %30(i32 noundef %31, i32 noundef 35714, ptr noundef %5)
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %52

34:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %35 = load ptr, ptr @_funcptr_glGetProgramiv, align 8, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !9
  call void %35(i32 noundef %36, i32 noundef 35716, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = call noalias noundef nonnull ptr @_Znam(i64 noundef %39) #7
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr @_funcptr_glGetProgramInfoLog, align 8, !tbaa !5
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  call void %41(i32 noundef %42, i32 noundef %43, ptr noundef null, ptr noundef %44)
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.4, ptr noundef %46) #6
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = icmp eq ptr %48, null
  br i1 %49, label %51, label %50

50:                                               ; preds = %34
  call void @_ZdaPv(ptr noundef %48) #8
  br label %51

51:                                               ; preds = %50, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %52

52:                                               ; preds = %51, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %53

53:                                               ; preds = %66, %52
  %54 = load i64, ptr %8, align 8, !tbaa !11
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %55) #6
  %57 = icmp ult i64 %54, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %69

59:                                               ; preds = %53
  %60 = load ptr, ptr @_funcptr_glDetachShader, align 8, !tbaa !5
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = load i64, ptr %8, align 8, !tbaa !11
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %63) #6
  %65 = load i32, ptr %64, align 4, !tbaa !9
  call void %60(i32 noundef %61, i32 noundef %65)
  br label %66

66:                                               ; preds = %59
  %67 = load i64, ptr %8, align 8, !tbaa !11
  %68 = add i64 %67, 1
  store i64 %68, ptr %8, align 8, !tbaa !11
  br label %53, !llvm.loop !15

69:                                               ; preds = %58
  %70 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret i32 %70
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin 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 #2 = { 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 = { nobuiltin 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 #4 = { 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 #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 }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@stderr = external local_unnamed_addr global ptr, align 8
@_funcptr_glCreateProgram = external local_unnamed_addr global ptr, align 8
@_funcptr_glAttachShader = external local_unnamed_addr global ptr, align 8
@_funcptr_glLinkProgram = external local_unnamed_addr global ptr, align 8
@_funcptr_glGetProgramiv = external local_unnamed_addr global ptr, align 8
@_funcptr_glGetProgramInfoLog = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1
@_funcptr_glDetachShader = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; 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 uwtable
define dso_local noundef i32 @_Z13CreateProgramRKSt6vectorIjSaIjEE(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #4 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load ptr, ptr @_funcptr_glCreateProgram, align 8, !tbaa !5
  %5 = tail call i32 %4()
  %6 = tail call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %7 = load ptr, ptr @_funcptr_glLinkProgram, align 8, !tbaa !5
  tail call void %7(i32 noundef %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %8 = load ptr, ptr @_funcptr_glGetProgramiv, align 8, !tbaa !5
  call void %8(i32 noundef %5, i32 noundef 35714, ptr noundef nonnull %2)
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %17, label %26

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.01920 = phi i64 [ %14, %.lr.ph ], [ 0, %1 ]
  %11 = load ptr, ptr @_funcptr_glAttachShader, align 8, !tbaa !5
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.01920) #6
  %13 = load i32, ptr %12, align 4, !tbaa !9
  tail call void %11(i32 noundef %5, i32 noundef %13)
  %14 = add nuw i64 %.01920, 1
  %15 = tail call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !11

17:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %18 = load ptr, ptr @_funcptr_glGetProgramiv, align 8, !tbaa !5
  call void %18(i32 noundef %5, i32 noundef 35716, ptr noundef nonnull %3)
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = call noalias noundef nonnull ptr @_Znam(i64 noundef %21) #7
  %23 = load ptr, ptr @_funcptr_glGetProgramInfoLog, align 8, !tbaa !5
  call void %23(i32 noundef %5, i32 noundef %19, ptr noundef null, ptr noundef nonnull %22)
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.4, ptr noundef nonnull %22) #8
  call void @_ZdaPv(ptr noundef nonnull %22) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  br label %26

26:                                               ; preds = %17, %._crit_edge
  %27 = call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  %.not25 = icmp eq i64 %27, 0
  br i1 %.not25, label %._crit_edge24, label %.lr.ph23

._crit_edge24:                                    ; preds = %.lr.ph23, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  ret i32 %5

.lr.ph23:                                         ; preds = %26, %.lr.ph23
  %.021 = phi i64 [ %31, %.lr.ph23 ], [ 0, %26 ]
  %28 = load ptr, ptr @_funcptr_glDetachShader, align 8, !tbaa !5
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.021) #6
  %30 = load i32, ptr %29, align 4, !tbaa !9
  call void %28(i32 noundef %5, i32 noundef %30)
  %31 = add nuw i64 %.021, 1
  %32 = call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %.lr.ph23, label %._crit_edge24, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #5 align 2

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass