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

%union.foo_t = type { 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.test6.foo = external hidden unnamed_addr constant %union.foo_t, align 1
@__func__.test6 = 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 @test6() #3 {
  %1 = alloca %union.foo_t, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 @__const.test6.foo, i64 1, i1 false)
  %2 = load i8, ptr %1, align 1, !tbaa !5
  %3 = sext i8 %2 to i32
  %4 = icmp ne i32 %3, 1
  br i1 %4, label %5, label %10

5:                                                ; preds = %0
  %6 = load ptr, ptr @stderr, align 8, !tbaa !8
  %7 = load i8, ptr %1, align 1, !tbaa !5
  %8 = sext i8 %7 to i32
  %9 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test6, i32 noundef 419, i32 noundef %8, i32 noundef 1) #4
  br label %10

10:                                               ; preds = %5, %0
  %11 = load i8, ptr %1, align 1, !tbaa !5
  %12 = sext i8 %11 to i32
  %13 = icmp ne i32 %12, 1
  br i1 %13, label %14, label %19

14:                                               ; preds = %10
  %15 = load ptr, ptr @stderr, align 8, !tbaa !8
  %16 = load i8, ptr %1, align 1, !tbaa !5
  %17 = sext i8 %16 to i32
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test6, i32 noundef 420, i32 noundef %17, i32 noundef 1) #4
  br label %19

19:                                               ; preds = %14, %10
  %20 = load i8, ptr %1, align 1, !tbaa !5
  %21 = sext i8 %20 to i32
  %22 = icmp ne i32 %21, 1
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = load ptr, ptr @stderr, align 8, !tbaa !8
  %25 = load i8, ptr %1, align 1, !tbaa !5
  %26 = sext i8 %25 to i32
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test6, i32 noundef 421, i32 noundef %26, i32 noundef 1) #4
  br label %28

28:                                               ; preds = %23, %19
  %29 = load i8, ptr %1, align 1, !tbaa !5
  %30 = sext i8 %29 to i32
  %31 = icmp ne i32 %30, 1
  br i1 %31, label %32, label %37

32:                                               ; preds = %28
  %33 = load ptr, ptr @stderr, align 8, !tbaa !8
  %34 = load i8, ptr %1, align 1, !tbaa !5
  %35 = sext i8 %34 to i32
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.test6, i32 noundef 422, i32 noundef %35, i32 noundef 1) #4
  br label %37

37:                                               ; preds = %32, %28
  call void @llvm.lifetime.end.p0(i64 1, 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}


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

%union.foo_t = type { i8 }

@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.test6.foo = external hidden unnamed_addr constant %union.foo_t, align 1
@__func__.test6 = 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 @test6() local_unnamed_addr #1 {
  %.sroa.0.0.copyload = load i8, ptr @__const.test6.foo, align 1
  %.not = icmp eq i8 %.sroa.0.0.copyload, 1
  br i1 %.not, label %.critedge9, 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__.test6, i32 noundef 419, i32 noundef %1, 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__.test6, i32 noundef 420, i32 noundef %1, 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__.test6, i32 noundef 421, i32 noundef %1, i32 noundef 1) #2
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.test6, i32 noundef 422, i32 noundef %1, i32 noundef 1) #2
  br label %.critedge9

.critedge9:                                       ; preds = %0, %.critedge
  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