; LLVM IR from wgtdkp/wgtcc :: test (struct)

; 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.foo_t.6 = type { %union.anon.7, i8 }
%union.anon.7 = type { %struct.anon.8 }
%struct.anon.8 = type { i8, i8 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1
@__const.test9.foo = external hidden unnamed_addr constant { { i8, i8 }, i8 }, align 1
@__func__.test9 = external hidden unnamed_addr constant [6 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @test9() #3 {
  %1 = alloca %struct.foo_t.6, align 1
  call void @llvm.lifetime.start.p0(i64 3, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 @__const.test9.foo, i64 3, i1 false)
  %2 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 0
  %3 = getelementptr inbounds %struct.anon.8, ptr %2, i32 0, i32 0
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = icmp ne i32 3, %5
  br i1 %6, label %7, label %14

7:                                                ; preds = %0
  %8 = load ptr, ptr @stderr, align 8, !tbaa !8
  %9 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 0
  %10 = getelementptr inbounds %struct.anon.8, ptr %9, i32 0, i32 0
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = sext i8 %11 to i32
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test9, i32 noundef 470, i32 noundef 3, i32 noundef %12) #4
  br label %14

14:                                               ; preds = %7, %0
  %15 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 0
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 3, %17
  br i1 %18, label %19, label %25

19:                                               ; preds = %14
  %20 = load ptr, ptr @stderr, align 8, !tbaa !8
  %21 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 0
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = sext i8 %22 to i32
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test9, i32 noundef 477, i32 noundef 3, i32 noundef %23) #4
  br label %25

25:                                               ; preds = %19, %14
  %26 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 0
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = sext i8 %27 to i32
  %29 = icmp ne i32 3, %28
  br i1 %29, label %30, label %36

30:                                               ; preds = %25
  %31 = load ptr, ptr @stderr, align 8, !tbaa !8
  %32 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 0
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = sext i8 %33 to i32
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test9, i32 noundef 478, i32 noundef 3, i32 noundef %34) #4
  br label %36

36:                                               ; preds = %30, %25
  %37 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 1
  %38 = load i8, ptr %37, align 1, !tbaa !10
  %39 = sext i8 %38 to i32
  %40 = icmp ne i32 4, %39
  br i1 %40, label %41, label %47

41:                                               ; preds = %36
  %42 = load ptr, ptr @stderr, align 8, !tbaa !8
  %43 = getelementptr inbounds %struct.foo_t.6, ptr %1, i32 0, i32 1
  %44 = load i8, ptr %43, align 1, !tbaa !10
  %45 = sext i8 %44 to i32
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test9, i32 noundef 479, i32 noundef 4, i32 noundef %45) #4
  br label %47

47:                                               ; preds = %41, %36
  call void @llvm.lifetime.end.p0(i64 3, ptr %1) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !6, i64 2}
!11 = !{!"", !6, i64 0, !6, i64 2}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1
@__const.test9.foo = external hidden unnamed_addr constant { { i8, i8 }, i8 }, align 1
@__func__.test9 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @test9() local_unnamed_addr #1 {
  %.sroa.0.0.copyload = load i8, ptr @__const.test9.foo, align 1
  %.sroa.96.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.test9.foo, i64 2), align 1
  %.not = icmp eq i8 %.sroa.0.0.copyload, 3
  br i1 %.not, label %.critedge10, label %.critedge

.critedge:                                        ; preds = %0
  %1 = sext i8 %.sroa.0.0.copyload to i32
  %2 = load ptr, ptr @stderr, align 8, !tbaa !5
  %3 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.test9, i32 noundef 470, i32 noundef 3, i32 noundef %1) #2
  %4 = load ptr, ptr @stderr, align 8, !tbaa !5
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.test9, i32 noundef 477, i32 noundef 3, i32 noundef %1) #2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.test9, i32 noundef 478, i32 noundef 3, i32 noundef %1) #2
  br label %.critedge10

.critedge10:                                      ; preds = %0, %.critedge
  %.not9 = icmp eq i8 %.sroa.96.0.copyload, 4
  br i1 %.not9, label %12, label %8

8:                                                ; preds = %.critedge10
  %9 = sext i8 %.sroa.96.0.copyload to i32
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.test9, i32 noundef 479, i32 noundef 4, i32 noundef %9) #2
  br label %12

12:                                               ; preds = %8, %.critedge10
  ret void
}

attributes #0 = { 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 #1 = { nofree 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 = { cold 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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass