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

@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1

; 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
declare dso_local ptr @find_type(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @error(ptr noundef) #1

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

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.var, ptr %10, i32 0, i32 3
  %12 = load i8, ptr %11, align 4, !tbaa !15, !range !16, !noundef !17
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %15

14:                                               ; preds = %9, %1
  store i32 4, ptr %3, align 4, !tbaa !18
  br label %39

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.var, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds [32 x i8], ptr %17, i64 0, i64 0
  %19 = call ptr @find_type(ptr noundef %18, i32 noundef 0)
  store ptr %19, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %15
  call void @error(ptr noundef @.str.9)
  br label %23

23:                                               ; preds = %22, %15
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.type, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %25, align 8, !tbaa !19
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %34

28:                                               ; preds = %23
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.type, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %struct.type, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %32, align 8, !tbaa !19
  store i32 %33, ptr %3, align 4, !tbaa !18
  br label %38

34:                                               ; preds = %23
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.type, ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 8, !tbaa !19
  store i32 %37, ptr %3, align 4, !tbaa !18
  br label %38

38:                                               ; preds = %34, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %39

39:                                               ; preds = %38, %14
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.var, ptr %40, i32 0, i32 5
  %42 = load i32, ptr %41, align 8, !tbaa !22
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  %45 = load i32, ptr %3, align 4, !tbaa !18
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.var, ptr %46, i32 0, i32 5
  %48 = load i32, ptr %47, align 8, !tbaa !22
  %49 = mul nsw i32 %45, %48
  store i32 %49, ptr %3, align 4, !tbaa !18
  br label %50

50:                                               ; preds = %44, %39
  %51 = load i32, ptr %3, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %51
}

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 = { 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, !11, i64 64}
!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 68}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !11, i64 48}
!20 = !{!"type", !7, i64 0, !11, i64 32, !6, i64 40, !11, i64 48, !7, i64 56, !11, i64 60472}
!21 = !{!20, !6, i64 40}
!22 = !{!10, !11, i64 72}


; 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.9 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @find_type(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @error(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @size_var(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %21, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 68
  %7 = load i8, ptr %6, align 4, !tbaa !14, !range !15, !noundef !16
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %21, label %9

9:                                                ; preds = %5
  %10 = tail call ptr @find_type(ptr noundef nonnull %0, i32 noundef 0)
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %12

11:                                               ; preds = %9
  tail call void @error(ptr noundef nonnull @.str.9)
  br label %12

12:                                               ; preds = %11, %9
  %13 = getelementptr inbounds i8, ptr %10, i64 48
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %10, i64 40
  %18 = load ptr, ptr %17, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %18, i64 48
  %20 = load i32, ptr %19, align 8, !tbaa !17
  br label %21

21:                                               ; preds = %16, %12, %1, %5
  %.1 = phi i32 [ 4, %5 ], [ 4, %1 ], [ %20, %16 ], [ %14, %12 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 72
  %23 = load i32, ptr %22, align 8, !tbaa !20
  %24 = tail call i32 @llvm.smax.i32(i32 %23, i32 1)
  %spec.select = mul nsw i32 %24, %.1
  ret i32 %spec.select
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 speculatable willreturn memory(none) }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass