; LLVM IR from vul337/PrIntFuzz :: config/linux/firmware/carl9170fw/config (expr)

; 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.expr = type { i32, %union.expr_data, %union.expr_data }
%union.expr_data = type { ptr }
%struct.symbol = type { ptr, ptr, i32, %struct.symbol_value, [4 x %struct.symbol_value], i32, i32, ptr, %struct.expr_value, %struct.expr_value }
%struct.symbol_value = type { ptr, i32 }
%struct.expr_value = type { ptr, i32 }

@.str.4 = external hidden unnamed_addr constant [22 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @expr_calc_value(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %1
  store i32 2, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

12:                                               ; preds = %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.expr, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !9
  switch i32 %15, label %113 [
    i32 7, label %16
    i32 2, label %26
    i32 1, label %44
    i32 3, label %62
    i32 4, label %69
    i32 5, label %91
  ]

16:                                               ; preds = %12
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.expr, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  call void @sym_calc_value(ptr noundef %19)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.expr, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = getelementptr inbounds %struct.symbol, ptr %22, i32 0, i32 3
  %24 = getelementptr inbounds %struct.symbol_value, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !13
  store i32 %25, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

26:                                               ; preds = %12
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.expr, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %30 = call i32 @expr_calc_value(ptr noundef %29)
  store i32 %30, ptr %4, align 4, !tbaa !17
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.expr, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = call i32 @expr_calc_value(ptr noundef %33)
  store i32 %34, ptr %5, align 4, !tbaa !17
  %35 = load i32, ptr %4, align 4, !tbaa !17
  %36 = load i32, ptr %5, align 4, !tbaa !17
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %26
  %39 = load i32, ptr %4, align 4, !tbaa !17
  br label %42

40:                                               ; preds = %26
  %41 = load i32, ptr %5, align 4, !tbaa !17
  br label %42

42:                                               ; preds = %40, %38
  %43 = phi i32 [ %39, %38 ], [ %41, %40 ]
  store i32 %43, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

44:                                               ; preds = %12
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.expr, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !12
  %48 = call i32 @expr_calc_value(ptr noundef %47)
  store i32 %48, ptr %4, align 4, !tbaa !17
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.expr, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !12
  %52 = call i32 @expr_calc_value(ptr noundef %51)
  store i32 %52, ptr %5, align 4, !tbaa !17
  %53 = load i32, ptr %4, align 4, !tbaa !17
  %54 = load i32, ptr %5, align 4, !tbaa !17
  %55 = icmp ugt i32 %53, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %44
  %57 = load i32, ptr %4, align 4, !tbaa !17
  br label %60

58:                                               ; preds = %44
  %59 = load i32, ptr %5, align 4, !tbaa !17
  br label %60

60:                                               ; preds = %58, %56
  %61 = phi i32 [ %57, %56 ], [ %59, %58 ]
  store i32 %61, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

62:                                               ; preds = %12
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.expr, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !12
  %66 = call i32 @expr_calc_value(ptr noundef %65)
  store i32 %66, ptr %4, align 4, !tbaa !17
  %67 = load i32, ptr %4, align 4, !tbaa !17
  %68 = sub i32 2, %67
  store i32 %68, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

69:                                               ; preds = %12
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.expr, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !12
  call void @sym_calc_value(ptr noundef %72)
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.expr, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !12
  call void @sym_calc_value(ptr noundef %75)
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.expr, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !12
  %79 = call ptr @sym_get_string_value(ptr noundef %78)
  store ptr %79, ptr %6, align 8, !tbaa !5
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.expr, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !12
  %83 = call ptr @sym_get_string_value(ptr noundef %82)
  store ptr %83, ptr %7, align 8, !tbaa !5
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = call i32 @strcmp(ptr noundef %84, ptr noundef %85) #5
  %87 = icmp ne i32 %86, 0
  %88 = xor i1 %87, true
  %89 = zext i1 %88 to i64
  %90 = select i1 %88, i32 2, i32 0
  store i32 %90, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

91:                                               ; preds = %12
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.expr, ptr %92, i32 0, i32 1
  %94 = load ptr, ptr %93, align 8, !tbaa !12
  call void @sym_calc_value(ptr noundef %94)
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.expr, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !12
  call void @sym_calc_value(ptr noundef %97)
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.expr, ptr %98, i32 0, i32 1
  %100 = load ptr, ptr %99, align 8, !tbaa !12
  %101 = call ptr @sym_get_string_value(ptr noundef %100)
  store ptr %101, ptr %6, align 8, !tbaa !5
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.expr, ptr %102, i32 0, i32 2
  %104 = load ptr, ptr %103, align 8, !tbaa !12
  %105 = call ptr @sym_get_string_value(ptr noundef %104)
  store ptr %105, ptr %7, align 8, !tbaa !5
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %108 = call i32 @strcmp(ptr noundef %106, ptr noundef %107) #5
  %109 = icmp ne i32 %108, 0
  %110 = xor i1 %109, true
  %111 = zext i1 %110 to i64
  %112 = select i1 %110, i32 0, i32 2
  store i32 %112, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

113:                                              ; preds = %12
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.expr, ptr %114, i32 0, i32 0
  %116 = load i32, ptr %115, align 8, !tbaa !9
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %116)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %118

118:                                              ; preds = %113, %91, %69, %62, %60, %42, %16, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %119 = load i32, ptr %2, align 4
  ret i32 %119
}

declare void @sym_calc_value(ptr noundef) #1

declare ptr @sym_get_string_value(ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"expr", !11, i64 0, !7, i64 8, !7, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !11, i64 32}
!14 = !{!"symbol", !6, i64 0, !6, i64 8, !11, i64 16, !15, i64 24, !7, i64 40, !11, i64 104, !11, i64 108, !6, i64 112, !16, i64 120, !16, i64 136}
!15 = !{!"symbol_value", !6, i64 0, !11, i64 8}
!16 = !{!"expr_value", !6, i64 0, !11, i64 8}
!17 = !{!11, !11, 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"

@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @expr_calc_value(ptr noundef readonly %0) local_unnamed_addr #1 {
  %.not54 = icmp eq ptr %0, null
  br i1 %.not54, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1, %tailrecurse
  %.tr56 = phi ptr [ %13, %tailrecurse ], [ %0, %1 ]
  %accumulator.tr55 = phi i32 [ %14, %tailrecurse ], [ -1, %1 ]
  %2 = load i32, ptr %.tr56, align 8, !tbaa !5
  switch i32 %2, label %50 [
    i32 7, label %3
    i32 2, label %tailrecurse
    i32 1, label %15
    i32 3, label %23
    i32 4, label %28
    i32 5, label %39
  ]

3:                                                ; preds = %.lr.ph
  %4 = getelementptr inbounds i8, ptr %.tr56, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  tail call void @sym_calc_value(ptr noundef %5) #5
  %6 = load ptr, ptr %4, align 8, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %6, i64 32
  %8 = load i32, ptr %7, align 8, !tbaa !11
  br label %.loopexit

tailrecurse:                                      ; preds = %.lr.ph
  %9 = getelementptr inbounds i8, ptr %.tr56, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !10
  %11 = tail call i32 @expr_calc_value(ptr noundef %10)
  %12 = getelementptr inbounds i8, ptr %.tr56, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  %14 = tail call i32 @llvm.umin.i32(i32 %11, i32 %accumulator.tr55)
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %.loopexit, label %.lr.ph

common.ret152:                                    ; preds = %23, %15, %.loopexit
  %common.ret152.op = phi i32 [ %accumulator.ret.tr35, %.loopexit ], [ %accumulator.ret.tr, %15 ], [ %accumulator.ret.tr34, %23 ]
  ret i32 %common.ret152.op

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %.tr56, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !10
  %18 = tail call i32 @expr_calc_value(ptr noundef %17)
  %19 = getelementptr inbounds i8, ptr %.tr56, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !10
  %21 = tail call i32 @expr_calc_value(ptr noundef %20)
  %22 = tail call i32 @llvm.umax.i32(i32 %18, i32 %21)
  %accumulator.ret.tr = tail call i32 @llvm.umin.i32(i32 %22, i32 %accumulator.tr55)
  br label %common.ret152

23:                                               ; preds = %.lr.ph
  %24 = getelementptr inbounds i8, ptr %.tr56, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !10
  %26 = tail call i32 @expr_calc_value(ptr noundef %25)
  %27 = sub i32 2, %26
  %accumulator.ret.tr34 = tail call i32 @llvm.umin.i32(i32 %27, i32 %accumulator.tr55)
  br label %common.ret152

28:                                               ; preds = %.lr.ph
  %29 = getelementptr inbounds i8, ptr %.tr56, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !10
  tail call void @sym_calc_value(ptr noundef %30) #5
  %31 = getelementptr inbounds i8, ptr %.tr56, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !10
  tail call void @sym_calc_value(ptr noundef %32) #5
  %33 = load ptr, ptr %29, align 8, !tbaa !10
  %34 = tail call ptr @sym_get_string_value(ptr noundef %33) #5
  %35 = load ptr, ptr %31, align 8, !tbaa !10
  %36 = tail call ptr @sym_get_string_value(ptr noundef %35) #5
  %37 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %34, ptr noundef nonnull dereferenceable(1) %36) #6
  %.not33 = icmp eq i32 %37, 0
  %38 = select i1 %.not33, i32 2, i32 0
  br label %.loopexit

39:                                               ; preds = %.lr.ph
  %40 = getelementptr inbounds i8, ptr %.tr56, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !10
  tail call void @sym_calc_value(ptr noundef %41) #5
  %42 = getelementptr inbounds i8, ptr %.tr56, i64 16
  %43 = load ptr, ptr %42, align 8, !tbaa !10
  tail call void @sym_calc_value(ptr noundef %43) #5
  %44 = load ptr, ptr %40, align 8, !tbaa !10
  %45 = tail call ptr @sym_get_string_value(ptr noundef %44) #5
  %46 = load ptr, ptr %42, align 8, !tbaa !10
  %47 = tail call ptr @sym_get_string_value(ptr noundef %46) #5
  %48 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %45, ptr noundef nonnull dereferenceable(1) %47) #6
  %.not32 = icmp eq i32 %48, 0
  %49 = select i1 %.not32, i32 0, i32 2
  br label %.loopexit

50:                                               ; preds = %.lr.ph
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %2)
  br label %.loopexit

.loopexit:                                        ; preds = %tailrecurse, %1, %50, %39, %28, %3
  %accumulator.tr48 = phi i32 [ %accumulator.tr55, %50 ], [ %accumulator.tr55, %39 ], [ %accumulator.tr55, %28 ], [ %accumulator.tr55, %3 ], [ -1, %1 ], [ %14, %tailrecurse ]
  %.0 = phi i32 [ 0, %50 ], [ %49, %39 ], [ %38, %28 ], [ %8, %3 ], [ 2, %1 ], [ 2, %tailrecurse ]
  %accumulator.ret.tr35 = tail call i32 @llvm.umin.i32(i32 %.0, i32 %accumulator.tr48)
  br label %common.ret152
}

declare void @sym_calc_value(ptr noundef) local_unnamed_addr #2

declare ptr @sym_get_string_value(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #4

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 = { 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 = { "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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"expr", !7, i64 0, !8, i64 8, !8, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !7, i64 32}
!12 = !{!"symbol", !13, i64 0, !13, i64 8, !7, i64 16, !14, i64 24, !8, i64 40, !7, i64 104, !7, i64 108, !13, i64 112, !15, i64 120, !15, i64 136}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"symbol_value", !13, i64 0, !7, i64 8}
!15 = !{!"expr_value", !13, i64 0, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass