; LLVM IR from shellphish/how2heap :: glibc_2.23 (house_of_roman)

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

@shell = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [643 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [142 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [111 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [278 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [238 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @init() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  store ptr @.str.1, ptr %1, align 8, !tbaa !5
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = call i32 @puts(ptr noundef %13)
  %15 = call ptr @init()
  %16 = call i32 @puts(ptr noundef @.str.2)
  %17 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %18 = call noalias ptr @malloc(i64 noundef 96) #6
  store ptr %18, ptr %2, align 8, !tbaa !5
  %19 = call noalias ptr @malloc(i64 noundef 128) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %20 = call noalias ptr @malloc(i64 noundef 128) #6
  store ptr %20, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %21 = call noalias ptr @malloc(i64 noundef 96) #6
  store ptr %21, ptr %4, align 8, !tbaa !5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %22) #5
  %23 = call i32 @puts(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %24 = call noalias ptr @malloc(i64 noundef 96) #6
  store ptr %24, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds i64, ptr %25, i64 0
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = sub nsw i64 %27, 232
  store i64 %28, ptr %6, align 8, !tbaa !11
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %29) #5
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %30) #5
  %31 = call i32 @puts(ptr noundef @.str.5)
  %32 = call i32 @puts(ptr noundef @.str.6)
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 0
  store i8 0, ptr %34, align 1, !tbaa !13
  %35 = call i32 @puts(ptr noundef @.str.7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %36 = load i64, ptr %6, align 8, !tbaa !11
  %37 = sub nsw i64 %36, 35
  store i64 %37, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  %38 = load i64, ptr %7, align 8, !tbaa !11
  %39 = and i64 %38, 255
  %40 = trunc i64 %39 to i8
  store i8 %40, ptr %8, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  %41 = load i64, ptr %7, align 8, !tbaa !11
  %42 = and i64 %41, 65280
  %43 = ashr i64 %42, 8
  %44 = trunc i64 %43 to i8
  store i8 %44, ptr %9, align 1, !tbaa !13
  %45 = load i8, ptr %8, align 1, !tbaa !13
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 0
  store i8 %45, ptr %47, align 1, !tbaa !13
  %48 = load i8, ptr %9, align 1, !tbaa !13
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 1
  store i8 %48, ptr %50, align 1, !tbaa !13
  %51 = call i32 @puts(ptr noundef @.str.8)
  %52 = call i32 @puts(ptr noundef @.str.9)
  %53 = call noalias ptr @malloc(i64 noundef 96) #6
  %54 = call noalias ptr @malloc(i64 noundef 96) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %55 = call noalias ptr @malloc(i64 noundef 96) #6
  store ptr %55, ptr %10, align 8, !tbaa !5
  %56 = call i32 @puts(ptr noundef @.str.10)
  %57 = call i32 @puts(ptr noundef @.str.11)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %58 = call noalias ptr @malloc(i64 noundef 128) #6
  store ptr %58, ptr %11, align 8, !tbaa !5
  %59 = call noalias ptr @malloc(i64 noundef 48) #6
  %60 = call i32 @puts(ptr noundef @.str.12)
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %61) #5
  %62 = load i64, ptr %6, align 8, !tbaa !11
  %63 = sub nsw i64 %62, 16
  store i64 %63, ptr %7, align 8, !tbaa !11
  %64 = load i64, ptr %7, align 8, !tbaa !11
  %65 = and i64 %64, 255
  %66 = trunc i64 %65 to i8
  store i8 %66, ptr %8, align 1, !tbaa !13
  %67 = load i64, ptr %7, align 8, !tbaa !11
  %68 = and i64 %67, 65280
  %69 = ashr i64 %68, 8
  %70 = trunc i64 %69 to i8
  store i8 %70, ptr %9, align 1, !tbaa !13
  %71 = call i32 @puts(ptr noundef @.str.13)
  %72 = load i8, ptr %8, align 1, !tbaa !13
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i64 8
  store i8 %72, ptr %74, align 1, !tbaa !13
  %75 = load i8, ptr %9, align 1, !tbaa !13
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %76, i64 9
  store i8 %75, ptr %77, align 1, !tbaa !13
  %78 = call i32 @puts(ptr noundef @.str.14)
  %79 = call noalias ptr @malloc(i64 noundef 128) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %80 = call ptr @dlsym(ptr noundef inttoptr (i64 -1 to ptr), ptr noundef @.str.15) #5
  %81 = ptrtoint ptr %80 to i64
  store i64 %81, ptr %12, align 8, !tbaa !11
  %82 = call i32 @puts(ptr noundef @.str.16)
  %83 = call i32 @puts(ptr noundef @.str.17)
  %84 = call i32 @puts(ptr noundef @.str.18)
  %85 = load i64, ptr %12, align 8, !tbaa !11
  %86 = and i64 %85, 255
  %87 = trunc i64 %86 to i8
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %88, i64 19
  store i8 %87, ptr %89, align 1, !tbaa !13
  %90 = load i64, ptr %12, align 8, !tbaa !11
  %91 = ashr i64 %90, 8
  %92 = and i64 %91, 255
  %93 = trunc i64 %92 to i8
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %94, i64 20
  store i8 %93, ptr %95, align 1, !tbaa !13
  %96 = load i64, ptr %12, align 8, !tbaa !11
  %97 = ashr i64 %96, 16
  %98 = and i64 %97, 255
  %99 = trunc i64 %98 to i8
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  %101 = getelementptr inbounds i8, ptr %100, i64 21
  store i8 %99, ptr %101, align 1, !tbaa !13
  %102 = load i64, ptr %12, align 8, !tbaa !11
  %103 = ashr i64 %102, 24
  %104 = and i64 %103, 255
  %105 = trunc i64 %104 to i8
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %106, i64 22
  store i8 %105, ptr %107, align 1, !tbaa !13
  %108 = call i32 @puts(ptr noundef @.str.19)
  %109 = load ptr, ptr @shell, align 8, !tbaa !5
  %110 = ptrtoint ptr %109 to i64
  %111 = call noalias ptr @malloc(i64 noundef %110) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret i32 0
}

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

declare i32 @puts(ptr noundef) #2

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

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

; Function Attrs: nounwind
declare ptr @dlsym(ptr noundef, ptr noundef) #4

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

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 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 #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 = { nounwind allocsize(0) }

!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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!7, !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"

@.str.1 = external hidden unnamed_addr constant [643 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [142 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [111 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [278 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [238 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @init() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  %2 = tail call ptr @init()
  %3 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  %4 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %5 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.4)
  %6 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  %7 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.6)
  %8 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.7)
  %9 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.8)
  %10 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.9)
  %11 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.10)
  %12 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.11)
  %13 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.12)
  %14 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.13)
  %15 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.14)
  %16 = tail call ptr @dlsym(ptr noundef nonnull inttoptr (i64 -1 to ptr), ptr noundef nonnull @.str.15) #3
  %17 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.16)
  %18 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.17)
  %19 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.18)
  %20 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.19)
  ret i32 0
}

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

; Function Attrs: nounwind
declare ptr @dlsym(ptr noundef, ptr noundef) local_unnamed_addr #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 = { 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 = { 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 = { 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)"}


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