; LLVM IR from sysprog21/shecc :: src (ssa)

; 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.var = type { [32 x i8], [32 x i8], i32, i8, i8, i32, i32, i32, i32, i32, ptr, i32, [64 x ptr], i32, %struct.rename_t, %struct.ref_block_list, ptr, ptr, ptr, i32, i8, i8, i8 }
%struct.rename_t = type { i32, [64 x i32], i32 }
%struct.ref_block_list = type { ptr, ptr }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @new_name(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %10, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.var, ptr %11, i32 0, i32 10
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp ne ptr %13, null
  br i1 %14, label %19, label %15

15:                                               ; preds = %2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.var, ptr %17, i32 0, i32 10
  store ptr %16, ptr %18, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %15, %2
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.var, ptr %20, i32 0, i32 4
  %22 = load i8, ptr %21, align 1, !tbaa !15, !range !16, !noundef !17
  %23 = trunc i8 %22 to i1
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  store i32 1, ptr %6, align 4
  br label %72

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.var, ptr %26, i32 0, i32 10
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.var, ptr %28, i32 0, i32 14
  %30 = getelementptr inbounds %struct.rename_t, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 4, !tbaa !18
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %30, align 4, !tbaa !18
  store i32 %31, ptr %7, align 4, !tbaa !19
  %33 = load i32, ptr %7, align 4, !tbaa !19
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.var, ptr %34, i32 0, i32 10
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.var, ptr %36, i32 0, i32 14
  %38 = getelementptr inbounds %struct.rename_t, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.var, ptr %39, i32 0, i32 10
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.var, ptr %41, i32 0, i32 14
  %43 = getelementptr inbounds %struct.rename_t, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !20
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %43, align 4, !tbaa !20
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds [64 x i32], ptr %38, i64 0, i64 %46
  store i32 %33, ptr %47, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = call ptr @require_var(ptr noundef %48)
  store ptr %49, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %50, ptr align 8 %52, i64 944, i1 false)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.var, ptr %55, i32 0, i32 10
  store ptr %54, ptr %56, align 8, !tbaa !9
  %57 = load i32, ptr %7, align 4, !tbaa !19
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.var, ptr %58, i32 0, i32 11
  store i32 %57, ptr %59, align 8, !tbaa !21
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.var, ptr %61, i32 0, i32 12
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.var, ptr %63, i32 0, i32 13
  %65 = load i32, ptr %64, align 8, !tbaa !22
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %64, align 8, !tbaa !22
  %67 = sext i32 %65 to i64
  %68 = getelementptr inbounds [64 x ptr], ptr %62, i64 0, i64 %67
  store ptr %60, ptr %68, align 8, !tbaa !5
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds ptr, ptr %70, i64 0
  store ptr %69, ptr %71, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  store i32 0, ptr %6, align 4
  br label %72

72:                                               ; preds = %25, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %73 = load i32, ptr %6, align 4
  switch i32 %73, label %75 [
    i32 0, label %74
    i32 1, label %74
  ]

74:                                               ; preds = %72, %72
  ret void

75:                                               ; preds = %72
  unreachable
}

declare ptr @require_var(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !6, i64 96}
!10 = !{!"var", !7, i64 0, !7, i64 32, !11, i64 64, !12, i64 68, !12, i64 69, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !11, i64 104, !7, i64 112, !11, i64 624, !13, i64 628, !14, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !11, i64 936, !12, i64 940, !12, i64 941, !12, i64 942}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"", !11, i64 0, !7, i64 4, !11, i64 260}
!14 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!15 = !{!10, !12, i64 69}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !11, i64 628}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !11, i64 888}
!21 = !{!10, !11, i64 104}
!22 = !{!10, !11, i64 624}


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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
define dso_local void @new_name(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #1 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 96
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %2
  store ptr %3, ptr %4, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %6, %2
  %8 = phi ptr [ %3, %6 ], [ %5, %2 ]
  %9 = getelementptr inbounds i8, ptr %3, i64 69
  %10 = load i8, ptr %9, align 1, !tbaa !15, !range !16, !noundef !17
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %33, label %12

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %8, i64 628
  %14 = load i32, ptr %13, align 4, !tbaa !18
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %13, align 4, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %8, i64 632
  %17 = getelementptr inbounds i8, ptr %8, i64 888
  %18 = load i32, ptr %17, align 4, !tbaa !19
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !19
  %20 = sext i32 %18 to i64
  %21 = getelementptr inbounds [64 x i32], ptr %16, i64 0, i64 %20
  store i32 %14, ptr %21, align 4, !tbaa !20
  %22 = tail call ptr @require_var(ptr noundef %0) #3
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(944) %22, ptr noundef nonnull align 8 dereferenceable(944) %23, i64 944, i1 false)
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %22, i64 96
  store ptr %24, ptr %25, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %22, i64 104
  store i32 %14, ptr %26, align 8, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %3, i64 112
  %28 = getelementptr inbounds i8, ptr %3, i64 624
  %29 = load i32, ptr %28, align 8, !tbaa !22
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 8, !tbaa !22
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds [64 x ptr], ptr %27, i64 0, i64 %31
  store ptr %22, ptr %32, align 8, !tbaa !5
  store ptr %22, ptr %1, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %7, %12
  ret void
}

declare ptr @require_var(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 96}
!10 = !{!"var", !7, i64 0, !7, i64 32, !11, i64 64, !12, i64 68, !12, i64 69, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !11, i64 104, !7, i64 112, !11, i64 624, !13, i64 628, !14, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !11, i64 936, !12, i64 940, !12, i64 941, !12, i64 942}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"", !11, i64 0, !7, i64 4, !11, i64 260}
!14 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!15 = !{!10, !12, i64 69}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !11, i64 628}
!19 = !{!10, !11, i64 888}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 104}
!22 = !{!10, !11, i64 624}


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