; LLVM IR from shellphish/how2heap :: glibc_2.27 (house_of_spirit)

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

@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [319 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [237 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [217 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [7 x ptr], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [10 x i64], align 16
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  %8 = load ptr, ptr @stdout, align 8, !tbaa !5
  call void @setbuf(ptr noundef %8, ptr noundef null) #7
  %9 = call i32 @puts(ptr noundef @.str)
  %10 = call i32 @puts(ptr noundef @.str.1)
  %11 = call i32 @puts(ptr noundef @.str.2)
  %12 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 56, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %22, %0
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 7
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %25

17:                                               ; preds = %13
  %18 = call noalias ptr @malloc(i64 noundef 48) #8
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [7 x ptr], ptr %2, i64 0, i64 %20
  store ptr %18, ptr %21, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %17
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %3, align 4, !tbaa !9
  br label %13, !llvm.loop !11

25:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %35, %25
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = icmp slt i32 %27, 7
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %38

30:                                               ; preds = %26
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [7 x ptr], ptr %2, i64 0, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  call void @free(ptr noundef %34) #7
  br label %35

35:                                               ; preds = %30
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %4, align 4, !tbaa !9
  br label %26, !llvm.loop !13

38:                                               ; preds = %29
  %39 = call i32 @puts(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #7
  %40 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 0
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %40)
  %42 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 1
  %43 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 9
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %42, ptr noundef %43)
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %46 = call i32 @puts(ptr noundef @.str.8)
  %47 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 1
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, ptr noundef %47)
  %49 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 1
  store i64 64, ptr %49, align 8, !tbaa !14
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %51 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 9
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef %51)
  %53 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 9
  store i64 4660, ptr %53, align 8, !tbaa !14
  %54 = call i32 @puts(ptr noundef @.str.12)
  %55 = call i32 @puts(ptr noundef @.str.13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %56 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 2
  store ptr %56, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %57) #7
  %58 = call i32 @puts(ptr noundef @.str.14)
  %59 = getelementptr inbounds [10 x i64], ptr %5, i64 0, i64 2
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, ptr noundef %59)
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %62 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 48) #9
  store ptr %62, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, ptr noundef %63, ptr noundef %64)
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = icmp eq ptr %66, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %38
  br label %71

70:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.19, i32 noundef 47, ptr noundef @__PRETTY_FUNCTION__.main) #10
  unreachable

71:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %2) #7
  %72 = load i32, ptr %1, align 4
  ret i32 %72
}

; Function Attrs: nounwind
declare void @setbuf(ptr noundef, ptr noundef) #1

declare i32 @puts(ptr noundef) #2

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #5

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #6

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 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind 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 #5 = { nounwind allocsize(0,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 #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind allocsize(0,1) }
attributes #10 = { 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"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}


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

@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [319 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [237 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [217 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader.preheader:
  %0 = alloca [10 x i64], align 16
  %1 = load ptr, ptr @stdout, align 8, !tbaa !5
  tail call void @setbuf(ptr noundef %1, ptr noundef null) #6
  %2 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str)
  %3 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  %4 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  %5 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %6 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.4)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %0) #6
  %7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull %0)
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %12 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.8)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef nonnull %8)
  store i64 64, ptr %8, align 8, !tbaa !9
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull %9)
  store i64 4660, ptr %9, align 8, !tbaa !9
  %16 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.12)
  %17 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.13)
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  call void @free(ptr noundef nonnull %18) #6
  %19 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.14)
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef nonnull %18)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %22 = call noalias dereferenceable_or_null(48) ptr @calloc(i64 noundef 1, i64 noundef 48) #7
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, ptr noundef %22, ptr noundef nonnull %18)
  call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.19, i32 noundef 47, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #8
  unreachable
}

; Function Attrs: nofree nounwind
declare void @setbuf(ptr nocapture noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { 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 = !{!"long", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass