; LLVM IR from ESPboy-edu/ESPboy_tinyphysicsengine :: programs (hello2)

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

@screen = external dso_local global [512 x i8], 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: nounwind uwtable
define dso_local void @printScreen() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %11, %0
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 20
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %14

9:                                                ; preds = %5
  %10 = call i32 @putchar(i32 noundef 10)
  br label %11

11:                                               ; preds = %9
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !9

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %39, %14
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 16
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %42

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %34, %19
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 32
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %37

24:                                               ; preds = %20
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = mul nsw i32 %25, 32
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = call i32 @putchar(i32 noundef %32)
  br label %34

34:                                               ; preds = %24
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %4, align 4, !tbaa !5
  br label %20, !llvm.loop !12

37:                                               ; preds = %23
  %38 = call i32 @putchar(i32 noundef 10)
  br label %39

39:                                               ; preds = %37
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !13

42:                                               ; preds = %18
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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

@screen = external dso_local local_unnamed_addr global [512 x i8], align 16

; Function Attrs: nofree nounwind uwtable
define dso_local void @printScreen() local_unnamed_addr #0 {
.preheader.preheader:
  %0 = tail call i32 @putchar(i32 noundef 10)
  %1 = tail call i32 @putchar(i32 noundef 10)
  %2 = tail call i32 @putchar(i32 noundef 10)
  %3 = tail call i32 @putchar(i32 noundef 10)
  %4 = tail call i32 @putchar(i32 noundef 10)
  %5 = tail call i32 @putchar(i32 noundef 10)
  %6 = tail call i32 @putchar(i32 noundef 10)
  %7 = tail call i32 @putchar(i32 noundef 10)
  %8 = tail call i32 @putchar(i32 noundef 10)
  %9 = tail call i32 @putchar(i32 noundef 10)
  %10 = tail call i32 @putchar(i32 noundef 10)
  %11 = tail call i32 @putchar(i32 noundef 10)
  %12 = tail call i32 @putchar(i32 noundef 10)
  %13 = tail call i32 @putchar(i32 noundef 10)
  %14 = tail call i32 @putchar(i32 noundef 10)
  %15 = tail call i32 @putchar(i32 noundef 10)
  %16 = tail call i32 @putchar(i32 noundef 10)
  %17 = tail call i32 @putchar(i32 noundef 10)
  %18 = tail call i32 @putchar(i32 noundef 10)
  %19 = tail call i32 @putchar(i32 noundef 10)
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %.preheader ]
  %20 = shl nuw nsw i64 %indvars.iv, 5
  %21 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %20
  %22 = load i8, ptr %21, align 16, !tbaa !5
  %23 = sext i8 %22 to i32
  %24 = tail call i32 @putchar(i32 noundef %23)
  %25 = or disjoint i64 %20, 1
  %26 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = sext i8 %27 to i32
  %29 = tail call i32 @putchar(i32 noundef %28)
  %30 = or disjoint i64 %20, 2
  %31 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %30
  %32 = load i8, ptr %31, align 2, !tbaa !5
  %33 = sext i8 %32 to i32
  %34 = tail call i32 @putchar(i32 noundef %33)
  %35 = or disjoint i64 %20, 3
  %36 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = sext i8 %37 to i32
  %39 = tail call i32 @putchar(i32 noundef %38)
  %40 = or disjoint i64 %20, 4
  %41 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %40
  %42 = load i8, ptr %41, align 4, !tbaa !5
  %43 = sext i8 %42 to i32
  %44 = tail call i32 @putchar(i32 noundef %43)
  %45 = or disjoint i64 %20, 5
  %46 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = sext i8 %47 to i32
  %49 = tail call i32 @putchar(i32 noundef %48)
  %50 = or disjoint i64 %20, 6
  %51 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %50
  %52 = load i8, ptr %51, align 2, !tbaa !5
  %53 = sext i8 %52 to i32
  %54 = tail call i32 @putchar(i32 noundef %53)
  %55 = or disjoint i64 %20, 7
  %56 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = sext i8 %57 to i32
  %59 = tail call i32 @putchar(i32 noundef %58)
  %60 = or disjoint i64 %20, 8
  %61 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %60
  %62 = load i8, ptr %61, align 8, !tbaa !5
  %63 = sext i8 %62 to i32
  %64 = tail call i32 @putchar(i32 noundef %63)
  %65 = or disjoint i64 %20, 9
  %66 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !5
  %68 = sext i8 %67 to i32
  %69 = tail call i32 @putchar(i32 noundef %68)
  %70 = or disjoint i64 %20, 10
  %71 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %70
  %72 = load i8, ptr %71, align 2, !tbaa !5
  %73 = sext i8 %72 to i32
  %74 = tail call i32 @putchar(i32 noundef %73)
  %75 = or disjoint i64 %20, 11
  %76 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %75
  %77 = load i8, ptr %76, align 1, !tbaa !5
  %78 = sext i8 %77 to i32
  %79 = tail call i32 @putchar(i32 noundef %78)
  %80 = or disjoint i64 %20, 12
  %81 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %80
  %82 = load i8, ptr %81, align 4, !tbaa !5
  %83 = sext i8 %82 to i32
  %84 = tail call i32 @putchar(i32 noundef %83)
  %85 = or disjoint i64 %20, 13
  %86 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %85
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = sext i8 %87 to i32
  %89 = tail call i32 @putchar(i32 noundef %88)
  %90 = or disjoint i64 %20, 14
  %91 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %90
  %92 = load i8, ptr %91, align 2, !tbaa !5
  %93 = sext i8 %92 to i32
  %94 = tail call i32 @putchar(i32 noundef %93)
  %95 = or disjoint i64 %20, 15
  %96 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %95
  %97 = load i8, ptr %96, align 1, !tbaa !5
  %98 = sext i8 %97 to i32
  %99 = tail call i32 @putchar(i32 noundef %98)
  %100 = or disjoint i64 %20, 16
  %101 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %100
  %102 = load i8, ptr %101, align 16, !tbaa !5
  %103 = sext i8 %102 to i32
  %104 = tail call i32 @putchar(i32 noundef %103)
  %105 = or disjoint i64 %20, 17
  %106 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %105
  %107 = load i8, ptr %106, align 1, !tbaa !5
  %108 = sext i8 %107 to i32
  %109 = tail call i32 @putchar(i32 noundef %108)
  %110 = or disjoint i64 %20, 18
  %111 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %110
  %112 = load i8, ptr %111, align 2, !tbaa !5
  %113 = sext i8 %112 to i32
  %114 = tail call i32 @putchar(i32 noundef %113)
  %115 = or disjoint i64 %20, 19
  %116 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %115
  %117 = load i8, ptr %116, align 1, !tbaa !5
  %118 = sext i8 %117 to i32
  %119 = tail call i32 @putchar(i32 noundef %118)
  %120 = or disjoint i64 %20, 20
  %121 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %120
  %122 = load i8, ptr %121, align 4, !tbaa !5
  %123 = sext i8 %122 to i32
  %124 = tail call i32 @putchar(i32 noundef %123)
  %125 = or disjoint i64 %20, 21
  %126 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %125
  %127 = load i8, ptr %126, align 1, !tbaa !5
  %128 = sext i8 %127 to i32
  %129 = tail call i32 @putchar(i32 noundef %128)
  %130 = or disjoint i64 %20, 22
  %131 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %130
  %132 = load i8, ptr %131, align 2, !tbaa !5
  %133 = sext i8 %132 to i32
  %134 = tail call i32 @putchar(i32 noundef %133)
  %135 = or disjoint i64 %20, 23
  %136 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %135
  %137 = load i8, ptr %136, align 1, !tbaa !5
  %138 = sext i8 %137 to i32
  %139 = tail call i32 @putchar(i32 noundef %138)
  %140 = or disjoint i64 %20, 24
  %141 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %140
  %142 = load i8, ptr %141, align 8, !tbaa !5
  %143 = sext i8 %142 to i32
  %144 = tail call i32 @putchar(i32 noundef %143)
  %145 = or disjoint i64 %20, 25
  %146 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %145
  %147 = load i8, ptr %146, align 1, !tbaa !5
  %148 = sext i8 %147 to i32
  %149 = tail call i32 @putchar(i32 noundef %148)
  %150 = or disjoint i64 %20, 26
  %151 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %150
  %152 = load i8, ptr %151, align 2, !tbaa !5
  %153 = sext i8 %152 to i32
  %154 = tail call i32 @putchar(i32 noundef %153)
  %155 = or disjoint i64 %20, 27
  %156 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %155
  %157 = load i8, ptr %156, align 1, !tbaa !5
  %158 = sext i8 %157 to i32
  %159 = tail call i32 @putchar(i32 noundef %158)
  %160 = or disjoint i64 %20, 28
  %161 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %160
  %162 = load i8, ptr %161, align 4, !tbaa !5
  %163 = sext i8 %162 to i32
  %164 = tail call i32 @putchar(i32 noundef %163)
  %165 = or disjoint i64 %20, 29
  %166 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %165
  %167 = load i8, ptr %166, align 1, !tbaa !5
  %168 = sext i8 %167 to i32
  %169 = tail call i32 @putchar(i32 noundef %168)
  %170 = or disjoint i64 %20, 30
  %171 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %170
  %172 = load i8, ptr %171, align 2, !tbaa !5
  %173 = sext i8 %172 to i32
  %174 = tail call i32 @putchar(i32 noundef %173)
  %175 = or disjoint i64 %20, 31
  %176 = getelementptr inbounds [512 x i8], ptr @screen, i64 0, i64 %175
  %177 = load i8, ptr %176, align 1, !tbaa !5
  %178 = sext i8 %177 to i32
  %179 = tail call i32 @putchar(i32 noundef %178)
  %180 = tail call i32 @putchar(i32 noundef 10)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16
  br i1 %exitcond.not, label %181, label %.preheader, !llvm.loop !8

181:                                              ; preds = %.preheader
  ret void
}

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { inlinehint 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" }

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


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass