; LLVM IR from guanzhi/GmSSL :: tests (pemtest)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@__FUNCTION__.main = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %2 = call i32 @test_pem_unix_style()
  %3 = icmp ne i32 %2, 1
  br i1 %3, label %4, label %9

4:                                                ; preds = %0
  br label %5

5:                                                ; preds = %4
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 240, ptr noundef @__FUNCTION__.main) #2
  br label %8

8:                                                ; preds = %5
  store i32 1, ptr %1, align 4
  br label %34

9:                                                ; preds = %0
  %10 = call i32 @test_pem_unix_style_without_last_newline()
  %11 = icmp ne i32 %10, 1
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  br label %13

13:                                               ; preds = %12
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 241, ptr noundef @__FUNCTION__.main) #2
  br label %16

16:                                               ; preds = %13
  store i32 1, ptr %1, align 4
  br label %34

17:                                               ; preds = %9
  %18 = call i32 @test_pem_windows_style()
  %19 = icmp ne i32 %18, 1
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 242, ptr noundef @__FUNCTION__.main) #2
  br label %24

24:                                               ; preds = %21
  store i32 1, ptr %1, align 4
  br label %34

25:                                               ; preds = %17
  %26 = call i32 @test_pem_windows_style_without_last_newline()
  %27 = icmp ne i32 %26, 1
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 243, ptr noundef @__FUNCTION__.main) #2
  br label %32

32:                                               ; preds = %29
  store i32 1, ptr %1, align 4
  br label %34

33:                                               ; preds = %25
  store i32 0, ptr %1, align 4
  br label %34

34:                                               ; preds = %33, %32, %24, %16, %8
  %35 = load i32, ptr %1, align 4
  ret i32 %35
}

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_unix_style() #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_unix_style_without_last_newline() #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_windows_style() #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_windows_style_without_last_newline() #0

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 = { 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 }

!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"}


; 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 [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@__FUNCTION__.main = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 @test_pem_unix_style()
  %.not = icmp eq i32 %1, 1
  br i1 %.not, label %2, label %.sink.split

2:                                                ; preds = %0
  %3 = tail call i32 @test_pem_unix_style_without_last_newline()
  %.not1 = icmp eq i32 %3, 1
  br i1 %.not1, label %4, label %.sink.split

4:                                                ; preds = %2
  %5 = tail call i32 @test_pem_windows_style()
  %.not2 = icmp eq i32 %5, 1
  br i1 %.not2, label %6, label %.sink.split

6:                                                ; preds = %4
  %7 = tail call i32 @test_pem_windows_style_without_last_newline()
  %.not3 = icmp eq i32 %7, 1
  br i1 %.not3, label %10, label %.sink.split

.sink.split:                                      ; preds = %6, %4, %2, %0
  %.sink4 = phi i32 [ 240, %0 ], [ 241, %2 ], [ 242, %4 ], [ 243, %6 ]
  %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, i32 noundef %.sink4, ptr noundef nonnull @__FUNCTION__.main) #2
  br label %10

10:                                               ; preds = %.sink.split, %6
  %.0 = phi i32 [ 0, %6 ], [ 1, %.sink.split ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_unix_style() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_unix_style_without_last_newline() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_windows_style() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @test_pem_windows_style_without_last_newline() local_unnamed_addr #0

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 = { 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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass