; LLVM IR from Erkaman/fluid_sim :: deps/glfw-3.2/tests (title)

; 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 = external hidden unnamed_addr constant [49 x i8], align 1
@glad_glClear = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %3 = call ptr @glfwSetErrorCallback(ptr noundef @error_callback)
  %4 = call i32 @glfwInit()
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %7, label %6

6:                                                ; preds = %0
  call void @exit(i32 noundef 1) #5
  unreachable

7:                                                ; preds = %0
  %8 = call ptr @glfwCreateWindow(i32 noundef 400, i32 noundef 400, ptr noundef @.str, ptr noundef null, ptr noundef null)
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @glfwTerminate()
  call void @exit(i32 noundef 1) #5
  unreachable

12:                                               ; preds = %7
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glfwMakeContextCurrent(ptr noundef %13)
  %14 = call i32 @gladLoadGLLoader(ptr noundef @glfwGetProcAddress)
  call void @glfwSwapInterval(i32 noundef 1)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call ptr @glfwSetFramebufferSizeCallback(ptr noundef %15, ptr noundef @framebuffer_size_callback)
  br label %17

17:                                               ; preds = %22, %12
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = call i32 @glfwWindowShouldClose(ptr noundef %18)
  %20 = icmp ne i32 %19, 0
  %21 = xor i1 %20, true
  br i1 %21, label %22, label %25

22:                                               ; preds = %17
  %23 = load ptr, ptr @glad_glClear, align 8, !tbaa !5
  call void %23(i32 noundef 16384)
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glfwSwapBuffers(ptr noundef %24)
  call void @glfwWaitEvents()
  br label %17, !llvm.loop !9

25:                                               ; preds = %17
  call void @glfwTerminate()
  call void @exit(i32 noundef 0) #5
  unreachable
}

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

declare ptr @glfwSetErrorCallback(ptr noundef) #2

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

declare i32 @glfwInit() #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

declare ptr @glfwCreateWindow(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @glfwTerminate() #2

declare void @glfwMakeContextCurrent(ptr noundef) #2

declare i32 @gladLoadGLLoader(ptr noundef) #2

declare ptr @glfwGetProcAddress(ptr noundef) #2

declare void @glfwSwapInterval(i32 noundef) #2

declare ptr @glfwSetFramebufferSizeCallback(ptr noundef, ptr noundef) #2

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

declare i32 @glfwWindowShouldClose(ptr noundef) #2

declare void @glfwSwapBuffers(ptr noundef) #2

declare void @glfwWaitEvents() #2

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 = { noreturn 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 = { nounwind }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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 = external hidden unnamed_addr constant [49 x i8], align 1
@glad_glClear = external local_unnamed_addr global ptr, align 8

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @glfwSetErrorCallback(ptr noundef nonnull @error_callback) #4
  %2 = tail call i32 @glfwInit() #4
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %3, label %4

3:                                                ; preds = %0
  tail call void @exit(i32 noundef 1) #5
  unreachable

4:                                                ; preds = %0
  %5 = tail call ptr @glfwCreateWindow(i32 noundef 400, i32 noundef 400, ptr noundef nonnull @.str, ptr noundef null, ptr noundef null) #4
  %.not5 = icmp eq ptr %5, null
  br i1 %.not5, label %6, label %7

6:                                                ; preds = %4
  tail call void @glfwTerminate() #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

7:                                                ; preds = %4
  tail call void @glfwMakeContextCurrent(ptr noundef nonnull %5) #4
  %8 = tail call i32 @gladLoadGLLoader(ptr noundef nonnull @glfwGetProcAddress) #4
  tail call void @glfwSwapInterval(i32 noundef 1) #4
  %9 = tail call ptr @glfwSetFramebufferSizeCallback(ptr noundef nonnull %5, ptr noundef nonnull @framebuffer_size_callback) #4
  %10 = tail call i32 @glfwWindowShouldClose(ptr noundef nonnull %5) #4
  %.not67 = icmp eq i32 %10, 0
  br i1 %.not67, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7, %.lr.ph
  %11 = load ptr, ptr @glad_glClear, align 8, !tbaa !5
  tail call void %11(i32 noundef 16384) #4
  tail call void @glfwSwapBuffers(ptr noundef nonnull %5) #4
  tail call void @glfwWaitEvents() #4
  %12 = tail call i32 @glfwWindowShouldClose(ptr noundef nonnull %5) #4
  %.not6 = icmp eq i32 %12, 0
  br i1 %.not6, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %7
  tail call void @glfwTerminate() #4
  tail call void @exit(i32 noundef 0) #5
  unreachable
}

declare ptr @glfwSetErrorCallback(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @error_callback(i32 noundef, ptr noundef) #2

declare i32 @glfwInit() local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

declare ptr @glfwCreateWindow(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @glfwTerminate() local_unnamed_addr #1

declare void @glfwMakeContextCurrent(ptr noundef) local_unnamed_addr #1

declare i32 @gladLoadGLLoader(ptr noundef) local_unnamed_addr #1

declare ptr @glfwGetProcAddress(ptr noundef) #1

declare void @glfwSwapInterval(i32 noundef) local_unnamed_addr #1

declare ptr @glfwSetFramebufferSizeCallback(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @framebuffer_size_callback(ptr noundef, i32 noundef, i32 noundef) #2

declare i32 @glfwWindowShouldClose(ptr noundef) local_unnamed_addr #1

declare void @glfwSwapBuffers(ptr noundef) local_unnamed_addr #1

declare void @glfwWaitEvents() local_unnamed_addr #1

attributes #0 = { noreturn 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 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 = { noreturn 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 = { nounwind }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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