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

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

@stdin = external global ptr, align 8
@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [82 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [123 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [99 x i8], align 1

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

20:                                               ; preds = %30, %0
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = icmp ult i64 %22, 7
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %33

25:                                               ; preds = %20
  %26 = call noalias ptr @malloc(i64 noundef 256) #7
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [7 x ptr], ptr %3, i64 0, i64 %28
  store ptr %26, ptr %29, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !9
  br label %20, !llvm.loop !11

33:                                               ; preds = %24
  %34 = call i32 @puts(ptr noundef @.str.7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %35 = call noalias ptr @malloc(i64 noundef 256) #7
  store ptr %35, ptr %5, align 8, !tbaa !5
  %36 = call i32 @puts(ptr noundef @.str.8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %37 = call noalias ptr @malloc(i64 noundef 256) #7
  store ptr %37, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, ptr noundef %38)
  %40 = call i32 @puts(ptr noundef @.str.10)
  %41 = call noalias ptr @malloc(i64 noundef 16) #7
  %42 = call i32 @puts(ptr noundef @.str.11)
  %43 = call i32 @puts(ptr noundef @.str.12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %53, %33
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 7
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %56

48:                                               ; preds = %44
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [7 x ptr], ptr %3, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  call void @free(ptr noundef %52) #6
  br label %53

53:                                               ; preds = %48
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %7, align 4, !tbaa !9
  br label %44, !llvm.loop !13

56:                                               ; preds = %47
  %57 = call i32 @puts(ptr noundef @.str.13)
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %58) #6
  %59 = call i32 @puts(ptr noundef @.str.14)
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %60) #6
  %61 = call i32 @puts(ptr noundef @.str.15)
  %62 = call noalias ptr @malloc(i64 noundef 256) #7
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %63) #6
  %64 = call i32 @puts(ptr noundef @.str.16)
  %65 = call i32 @puts(ptr noundef @.str.17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %66 = call noalias ptr @malloc(i64 noundef 288) #7
  store ptr %66, ptr %8, align 8, !tbaa !5
  %67 = call i32 @puts(ptr noundef @.str.18)
  %68 = getelementptr inbounds [4 x i64], ptr %2, i64 0, i64 0
  %69 = ptrtoint ptr %68 to i64
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds i64, ptr %70, i64 34
  store i64 %69, ptr %71, align 8, !tbaa !14
  %72 = call i32 @puts(ptr noundef @.str.19)
  %73 = call noalias ptr @malloc(i64 noundef 256) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %74 = call noalias ptr @malloc(i64 noundef 256) #7
  store ptr %74, ptr %9, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, ptr noundef %75)
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds [4 x i64], ptr %2, i64 0, i64 0
  %79 = icmp eq ptr %77, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %56
  br label %82

81:                                               ; preds = %56
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.22, i32 noundef 77, ptr noundef @__PRETTY_FUNCTION__.main) #8
  unreachable

82:                                               ; preds = %80
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.23)
  %84 = call i32 @puts(ptr noundef @.str.24)
  %85 = call i32 @puts(ptr noundef @.str.25)
  %86 = call i32 @puts(ptr noundef @.str.26)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 56, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #6
  ret i32 0
}

; 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

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

; 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

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

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 = { 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) }
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 = !{!"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"

@stdin = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [82 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [83 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 {
  %1 = alloca [4 x i64], align 16
  %2 = load ptr, ptr @stdin, align 8, !tbaa !5
  tail call void @setbuf(ptr noundef %2, ptr noundef null) #6
  %3 = load ptr, ptr @stdout, align 8, !tbaa !5
  tail call void @setbuf(ptr noundef %3, ptr noundef null) #6
  %4 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str)
  %5 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  %6 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #6
  %7 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %1)
  %9 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  %10 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.6)
  %11 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.7)
  %12 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.8)
  %13 = call noalias dereferenceable_or_null(256) ptr @malloc(i64 noundef 256) #7
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef %13)
  %15 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.10)
  %16 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.11)
  %17 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.12)
  %18 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.13)
  call void @free(ptr noundef %13) #6
  %19 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.14)
  %20 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.15)
  call void @free(ptr noundef %13) #6
  %21 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.16)
  %22 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.17)
  %23 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.18)
  %24 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.19)
  %25 = call noalias dereferenceable_or_null(256) ptr @malloc(i64 noundef 256) #7
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, ptr noundef %25)
  call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.22, i32 noundef 77, 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 #4 = { 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 #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) }
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"}


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