; LLVM IR from DiTo97/gol :: src/cpu (gol)

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

%struct.life = type { i32, i32, i32, double, i32, ptr, ptr, ptr, ptr }

@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [102 x i8], align 1

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

declare i32 @fflush(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @printbig(ptr noundef byval(%struct.life) align 8 %0, i1 noundef zeroext %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %3, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %10 = getelementptr inbounds %struct.life, ptr %0, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  store i32 %11, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %12 = getelementptr inbounds %struct.life, ptr %0, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !15
  store i32 %13, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %14 = load i8, ptr %3, align 1, !tbaa !5, !range !16, !noundef !17
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %20

16:                                               ; preds = %2
  %17 = getelementptr inbounds %struct.life, ptr %0, i32 0, i32 8
  %18 = load ptr, ptr %17, align 8, !tbaa !18
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str.6)
  br label %24

20:                                               ; preds = %2
  %21 = getelementptr inbounds %struct.life, ptr %0, i32 0, i32 8
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %23 = call noalias ptr @fopen(ptr noundef %22, ptr noundef @.str.7)
  br label %24

24:                                               ; preds = %20, %16
  %25 = phi ptr [ %19, %16 ], [ %23, %20 ]
  store ptr %25, ptr %8, align 8, !tbaa !19
  %26 = load ptr, ptr %8, align 8, !tbaa !19
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  call void @perror(ptr noundef @.str.8)
  call void @exit(i32 noundef 1) #6
  unreachable

29:                                               ; preds = %24
  %30 = load i8, ptr %3, align 1, !tbaa !5, !range !16, !noundef !17
  %31 = trunc i8 %30 to i1
  br i1 %31, label %37, label %32

32:                                               ; preds = %29
  %33 = load ptr, ptr %8, align 8, !tbaa !19
  %34 = load i32, ptr %7, align 4, !tbaa !14
  %35 = load i32, ptr %6, align 4, !tbaa !14
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.9, i32 noundef %34, i32 noundef %35) #5
  br label %37

37:                                               ; preds = %32, %29
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %38

38:                                               ; preds = %71, %37
  %39 = load i32, ptr %4, align 4, !tbaa !14
  %40 = load i32, ptr %7, align 4, !tbaa !14
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %74

42:                                               ; preds = %38
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %43

43:                                               ; preds = %65, %42
  %44 = load i32, ptr %5, align 4, !tbaa !14
  %45 = load i32, ptr %6, align 4, !tbaa !14
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %68

47:                                               ; preds = %43
  %48 = load ptr, ptr %8, align 8, !tbaa !19
  %49 = getelementptr inbounds %struct.life, ptr %0, i32 0, i32 5
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  %51 = load i32, ptr %4, align 4, !tbaa !14
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %50, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = load i32, ptr %5, align 4, !tbaa !14
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !5, !range !16, !noundef !17
  %59 = trunc i8 %58 to i1
  %60 = zext i1 %59 to i32
  %61 = icmp eq i32 %60, 1
  %62 = zext i1 %61 to i64
  %63 = select i1 %61, i32 88, i32 32
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.10, i32 noundef %63) #5
  br label %65

65:                                               ; preds = %47
  %66 = load i32, ptr %5, align 4, !tbaa !14
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !14
  br label %43, !llvm.loop !21

68:                                               ; preds = %43
  %69 = load ptr, ptr %8, align 8, !tbaa !19
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.11) #5
  br label %71

71:                                               ; preds = %68
  %72 = load i32, ptr %4, align 4, !tbaa !14
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %4, align 4, !tbaa !14
  br label %38, !llvm.loop !23

74:                                               ; preds = %38
  %75 = load ptr, ptr %8, align 8, !tbaa !19
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.12) #5
  %77 = load ptr, ptr %8, align 8, !tbaa !19
  %78 = call i32 @fflush(ptr noundef %77)
  %79 = load ptr, ptr %8, align 8, !tbaa !19
  %80 = call i32 @fclose(ptr noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  ret void
}

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

declare void @perror(ptr noundef) #1

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

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

declare i32 @fclose(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"life", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !11, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 4}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !13, i64 56}
!19 = !{!13, !13, i64 0}
!20 = !{!10, !13, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


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

%struct.life = type { i32, i32, i32, double, i32, ptr, ptr, ptr, ptr }

@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [102 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @printbig(ptr nocapture noundef readonly byval(%struct.life) align 8 %0, i1 noundef zeroext %1) local_unnamed_addr #1 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  br i1 %1, label %8, label %.thread

8:                                                ; preds = %2
  %9 = tail call noalias ptr @fopen(ptr noundef %7, ptr noundef nonnull @.str.6)
  %10 = icmp eq ptr %9, null
  br i1 %10, label %13, label %15

.thread:                                          ; preds = %2
  %11 = tail call noalias ptr @fopen(ptr noundef %7, ptr noundef nonnull @.str.7)
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %.thread20

13:                                               ; preds = %.thread, %8
  tail call void @perror(ptr noundef nonnull @.str.8) #3
  tail call void @exit(i32 noundef 1) #4
  unreachable

.thread20:                                        ; preds = %.thread
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %11, ptr noundef nonnull @.str.9, i32 noundef %5, i32 noundef %3) #5
  br label %15

15:                                               ; preds = %8, %.thread20
  %16 = phi ptr [ %11, %.thread20 ], [ %9, %8 ]
  %17 = icmp sgt i32 %5, 0
  br i1 %17, label %.preheader.lr.ph, label %._crit_edge23

.preheader.lr.ph:                                 ; preds = %15
  %18 = icmp sgt i32 %3, 0
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = load ptr, ptr %19, align 8
  br i1 %18, label %.preheader.us.preheader, label %.preheader

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count30 = zext nneg i32 %5 to i64
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv27 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next28, %._crit_edge.us ]
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv27
  br label %22

22:                                               ; preds = %.preheader.us, %22
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %22 ]
  %23 = load ptr, ptr %21, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %23, i64 %indvars.iv
  %25 = load i8, ptr %24, align 1, !tbaa !15, !range !17, !noundef !18
  %26 = trunc nuw i8 %25 to i1
  %27 = select i1 %26, i32 88, i32 32
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %16, ptr noundef nonnull @.str.10, i32 noundef %27) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond26.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond26.not, label %._crit_edge.us, label %22, !llvm.loop !19

._crit_edge.us:                                   ; preds = %22
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %16, ptr noundef nonnull @.str.11) #5
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %exitcond31.not = icmp eq i64 %indvars.iv.next28, %wide.trip.count30
  br i1 %exitcond31.not, label %._crit_edge23, label %.preheader.us, !llvm.loop !21

.preheader:                                       ; preds = %.preheader.lr.ph, %.preheader
  %.022 = phi i32 [ %31, %.preheader ], [ 0, %.preheader.lr.ph ]
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %16, ptr noundef nonnull @.str.11) #5
  %31 = add nuw nsw i32 %.022, 1
  %exitcond.not = icmp eq i32 %31, %5
  br i1 %exitcond.not, label %._crit_edge23, label %.preheader, !llvm.loop !21

._crit_edge23:                                    ; preds = %.preheader, %._crit_edge.us, %15
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %16, ptr noundef nonnull @.str.12) #5
  %33 = tail call i32 @fflush(ptr noundef nonnull %16)
  %34 = tail call i32 @fclose(ptr noundef nonnull %16)
  ret void
}

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

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #0

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

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

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

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { cold }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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, !7, i64 0}
!6 = !{!"life", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !11, i64 56}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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