; LLVM IR from holzschu/ios_system :: curl/curl/tests/libtest (stub_gssapi)

; 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.gss_buffer_desc_struct = type { i64, ptr }

@__const.gss_display_status.maj_str = external hidden unnamed_addr constant [15 x i8], align 1
@min_err_table = external hidden global [8 x ptr], align 16

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(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: nounwind uwtable
define dso_local i32 @gss_display_status(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca [15 x i8], align 1
  %15 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 15, ptr %14) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %14, ptr align 1 @__const.gss_display_status.maj_str, i64 15, i1 false)
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %21

19:                                               ; preds = %6
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %19, %6
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 0, ptr %25, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %24, %21
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %67

29:                                               ; preds = %26
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %30, i32 0, i32 1
  store ptr null, ptr %31, align 8, !tbaa !11
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %32, i32 0, i32 0
  store i64 0, ptr %33, align 8, !tbaa !14
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp uge i32 %34, 7
  br i1 %35, label %36, label %37

36:                                               ; preds = %29
  store i32 -2147483648, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %68

37:                                               ; preds = %29
  %38 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %38, label %52 [
    i32 1, label %39
    i32 2, label %44
  ]

39:                                               ; preds = %37
  %40 = getelementptr inbounds [15 x i8], ptr %14, i64 0, i64 0
  %41 = call noalias ptr @strdup(ptr noundef %40) #5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %42, i32 0, i32 1
  store ptr %41, ptr %43, align 8, !tbaa !11
  br label %53

44:                                               ; preds = %37
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds [8 x ptr], ptr @min_err_table, i64 0, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = call noalias ptr @strdup(ptr noundef %48) #5
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %50, i32 0, i32 1
  store ptr %49, ptr %51, align 8, !tbaa !11
  br label %53

52:                                               ; preds = %37
  store i32 -2147483648, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %68

53:                                               ; preds = %44, %39
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %65

58:                                               ; preds = %53
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = call i64 @strlen(ptr noundef %61) #6
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.gss_buffer_desc_struct, ptr %63, i32 0, i32 0
  store i64 %62, ptr %64, align 8, !tbaa !14
  br label %66

65:                                               ; preds = %53
  store i32 -2147483648, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %68

66:                                               ; preds = %58
  br label %67

67:                                               ; preds = %66, %26
  store i32 0, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %68

68:                                               ; preds = %67, %65, %52, %36
  call void @llvm.lifetime.end.p0(i64 15, ptr %14) #5
  %69 = load i32, ptr %7, align 4
  ret i32 %69
}

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

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #4

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

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"gss_buffer_desc_struct", !13, i64 0, !6, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, 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"

@__const.gss_display_status.maj_str = external hidden unnamed_addr constant [15 x i8], align 1
@min_err_table = external hidden local_unnamed_addr global [8 x ptr], align 16

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn uwtable
define dso_local range(i32 -2147483648, 1) i32 @gss_display_status(ptr noundef writeonly %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readnone %3, ptr noundef writeonly %4, ptr noundef writeonly %5) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %8, label %7

7:                                                ; preds = %6
  store i32 0, ptr %0, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %7, %6
  %.not21 = icmp eq ptr %4, null
  br i1 %.not21, label %10, label %9

9:                                                ; preds = %8
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %9, %8
  %.not22 = icmp eq ptr %5, null
  br i1 %.not22, label %25, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %5, i64 8
  %13 = icmp ugt i32 %1, 6
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  br i1 %13, label %25, label %14

14:                                               ; preds = %11
  switch i32 %2, label %25 [
    i32 1, label %15
    i32 2, label %17
  ]

15:                                               ; preds = %14
  %16 = tail call noalias ptr @strdup(ptr noundef nonnull @__const.gss_display_status.maj_str) #4
  br label %22

17:                                               ; preds = %14
  %18 = zext nneg i32 %1 to i64
  %19 = getelementptr inbounds [8 x ptr], ptr @min_err_table, i64 0, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = tail call noalias ptr @strdup(ptr noundef %20) #4
  br label %22

22:                                               ; preds = %17, %15
  %storemerge = phi ptr [ %21, %17 ], [ %16, %15 ]
  store ptr %storemerge, ptr %12, align 8, !tbaa !11
  %.not23 = icmp eq ptr %storemerge, null
  br i1 %.not23, label %25, label %23

23:                                               ; preds = %22
  %24 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %storemerge) #5
  store i64 %24, ptr %5, align 8, !tbaa !14
  br label %25

25:                                               ; preds = %10, %23, %22, %14, %11
  %.0 = phi i32 [ -2147483648, %11 ], [ -2147483648, %14 ], [ -2147483648, %22 ], [ 0, %23 ], [ 0, %10 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { mustprogress nofree nounwind willreturn 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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"gss_buffer_desc_struct", !13, i64 0, !10, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 0}


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