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

; 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
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [28 x i8], align 1
@cur_icon_color = external hidden global i32, align 4
@glad_glClear = external global ptr, align 8

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

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !9
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str.11) #5
  call void @exit(i32 noundef 1) #6
  unreachable

12:                                               ; preds = %2
  %13 = call ptr @glfwCreateWindow(i32 noundef 200, i32 noundef 200, ptr noundef @.str.12, ptr noundef null, ptr noundef null)
  store ptr %13, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %19, label %16

16:                                               ; preds = %12
  call void @glfwTerminate()
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.13) #5
  call void @exit(i32 noundef 1) #6
  unreachable

19:                                               ; preds = %12
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  call void @glfwMakeContextCurrent(ptr noundef %20)
  %21 = call i32 @gladLoadGLLoader(ptr noundef @glfwGetProcAddress)
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = call ptr @glfwSetKeyCallback(ptr noundef %22, ptr noundef @key_callback)
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = load i32, ptr @cur_icon_color, align 4, !tbaa !5
  call void @set_icon(ptr noundef %24, i32 noundef %25)
  br label %26

26:                                               ; preds = %31, %19
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = call i32 @glfwWindowShouldClose(ptr noundef %27)
  %29 = icmp ne i32 %28, 0
  %30 = xor i1 %29, true
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  %32 = load ptr, ptr @glad_glClear, align 8, !tbaa !9
  call void %32(i32 noundef 16384)
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  call void @glfwSwapBuffers(ptr noundef %33)
  call void @glfwWaitEvents()
  br label %26, !llvm.loop !11

34:                                               ; preds = %26
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  call void @glfwDestroyWindow(ptr noundef %35)
  call void @glfwTerminate()
  call void @exit(i32 noundef 0) #6
  unreachable
}

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

declare i32 @glfwInit() #2

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

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

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 ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) #2

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

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

declare i32 @glfwWindowShouldClose(ptr noundef) #2

declare void @glfwSwapBuffers(ptr noundef) #2

declare void @glfwWaitEvents() #2

declare void @glfwDestroyWindow(ptr noundef) #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 = { 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 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"int", !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"}


; 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
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [28 x i8], align 1
@cur_icon_color = external hidden local_unnamed_addr global i32, align 4
@glad_glClear = external local_unnamed_addr global ptr, align 8

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

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.11) #6
  tail call void @exit(i32 noundef 1) #7
  unreachable

7:                                                ; preds = %2
  %8 = tail call ptr @glfwCreateWindow(i32 noundef 200, i32 noundef 200, ptr noundef nonnull @.str.12, ptr noundef null, ptr noundef null) #5
  %.not7 = icmp eq ptr %8, null
  br i1 %.not7, label %9, label %12

9:                                                ; preds = %7
  tail call void @glfwTerminate() #5
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.13) #6
  tail call void @exit(i32 noundef 1) #7
  unreachable

12:                                               ; preds = %7
  tail call void @glfwMakeContextCurrent(ptr noundef nonnull %8) #5
  %13 = tail call i32 @gladLoadGLLoader(ptr noundef nonnull @glfwGetProcAddress) #5
  %14 = tail call ptr @glfwSetKeyCallback(ptr noundef nonnull %8, ptr noundef nonnull @key_callback) #5
  %15 = load i32, ptr @cur_icon_color, align 4, !tbaa !9
  tail call void @set_icon(ptr noundef nonnull %8, i32 noundef %15)
  %16 = tail call i32 @glfwWindowShouldClose(ptr noundef nonnull %8) #5
  %.not89 = icmp eq i32 %16, 0
  br i1 %.not89, label %.lr.ph, label %._crit_edge

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

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

declare i32 @glfwInit() 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: 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 ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden void @set_icon(ptr noundef, i32 noundef) local_unnamed_addr #4

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

declare void @glfwDestroyWindow(ptr noundef) 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 = { 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 = { 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 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 = { cold nounwind }
attributes #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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