; LLVM IR from beagleboard/librobotcontrol :: library/src/io (spi)

; 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.rc_spi_state_t = type { [12 x i8], [12 x i8], [12 x i8], [12 x i8], [12 x i32], [12 x i32] }

@stderr = external global ptr, align 8
@state = external hidden global [6 x %struct.rc_spi_state_t], align 16
@.str.11 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [77 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

declare i32 @rc_model() #1

declare i32 @rc_model_category() #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @__open_fd(i32 noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @ioctl(i32 noundef, i64 noundef, ...) #2

declare void @perror(ptr noundef) #1

declare i32 @close(i32 noundef) #1

declare i32 @rc_pinmux_set(i32 noundef, i32 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 @rc_spi_init_manual_slave(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #3 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 8, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %19 = call i32 @rc_model()
  store i32 %19, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %20 = call i32 @rc_model_category()
  store i32 %20, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %26, label %23

23:                                               ; preds = %6
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 5
  br i1 %25, label %26, label %29

26:                                               ; preds = %23, %6
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.11, i32 noundef 5) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

29:                                               ; preds = %23
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %35, label %32

32:                                               ; preds = %29
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = icmp sge i32 %33, 12
  br i1 %34, label %35, label %38

35:                                               ; preds = %32, %29
  %36 = load ptr, ptr @stderr, align 8, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.12, i32 noundef 11) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

38:                                               ; preds = %32
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = icmp sgt i32 %39, 24000000
  br i1 %40, label %44, label %41

41:                                               ; preds = %38
  %42 = load i32, ptr %11, align 4, !tbaa !5
  %43 = icmp slt i32 %42, 1000
  br i1 %43, label %44, label %47

44:                                               ; preds = %41, %38
  %45 = load ptr, ptr @stderr, align 8, !tbaa !9
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.13, i32 noundef 1000, i32 noundef 24000000) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

47:                                               ; preds = %41
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %65

50:                                               ; preds = %47
  %51 = load i32, ptr %10, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = icmp ne i64 %52, 1
  br i1 %53, label %54, label %65

54:                                               ; preds = %50
  %55 = load i32, ptr %10, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp ne i64 %56, 2
  br i1 %57, label %58, label %65

58:                                               ; preds = %54
  %59 = load i32, ptr %10, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = icmp ne i64 %60, 3
  br i1 %61, label %62, label %65

62:                                               ; preds = %58
  %63 = load ptr, ptr @stderr, align 8, !tbaa !9
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.14) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

65:                                               ; preds = %58, %54, %50, %47
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %68, label %80

68:                                               ; preds = %65
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = icmp eq i32 %69, 1
  br i1 %70, label %71, label %80

71:                                               ; preds = %68
  %72 = load i32, ptr %15, align 4, !tbaa !5
  %73 = icmp eq i32 %72, 2
  br i1 %73, label %77, label %74

74:                                               ; preds = %71
  %75 = load i32, ptr %15, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 4
  br i1 %76, label %77, label %80

77:                                               ; preds = %74, %71
  %78 = load ptr, ptr @stderr, align 8, !tbaa !9
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef @.str.15) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

80:                                               ; preds = %74, %68, %65
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = icmp sgt i32 %81, 1
  br i1 %82, label %83, label %89

83:                                               ; preds = %80
  %84 = load i32, ptr %16, align 4, !tbaa !5
  %85 = icmp eq i32 %84, 1
  br i1 %85, label %86, label %89

86:                                               ; preds = %83
  %87 = load ptr, ptr @stderr, align 8, !tbaa !9
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %87, ptr noundef @.str.16) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

89:                                               ; preds = %83, %80
  %90 = load i32, ptr %9, align 4, !tbaa !5
  %91 = icmp sgt i32 %90, 1
  br i1 %91, label %92, label %98

92:                                               ; preds = %89
  %93 = load i32, ptr %16, align 4, !tbaa !5
  %94 = icmp eq i32 %93, 1
  br i1 %94, label %95, label %98

95:                                               ; preds = %92
  %96 = load ptr, ptr @stderr, align 8, !tbaa !9
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %96, ptr noundef @.str.17) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

98:                                               ; preds = %92, %89
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %100
  %102 = getelementptr inbounds %struct.rc_spi_state_t, ptr %101, i32 0, i32 5
  %103 = getelementptr inbounds [12 x i32], ptr %102, i64 0, i64 0
  %104 = load i32, ptr %103, align 16, !tbaa !5
  %105 = icmp eq i32 %104, 0
  br i1 %105, label %106, label %134

106:                                              ; preds = %98
  %107 = load i32, ptr %8, align 4, !tbaa !5
  %108 = call i32 @__open_fd(i32 noundef %107, i32 noundef 0)
  store i32 %108, ptr %17, align 4, !tbaa !5
  %109 = load i32, ptr %17, align 4, !tbaa !5
  %110 = icmp eq i32 %109, -1
  br i1 %110, label %111, label %112

111:                                              ; preds = %106
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

112:                                              ; preds = %106
  %113 = load i32, ptr %17, align 4, !tbaa !5
  %114 = call i32 (i32, i64, ...) @ioctl(i32 noundef %113, i64 noundef 1073834753, ptr noundef %10) #4
  %115 = icmp eq i32 %114, -1
  br i1 %115, label %116, label %119

116:                                              ; preds = %112
  call void @perror(ptr noundef @.str.18)
  %117 = load i32, ptr %17, align 4, !tbaa !5
  %118 = call i32 @close(i32 noundef %117)
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

119:                                              ; preds = %112
  %120 = load i32, ptr %17, align 4, !tbaa !5
  %121 = call i32 (i32, i64, ...) @ioctl(i32 noundef %120, i64 noundef 1073834755, ptr noundef %14) #4
  %122 = icmp eq i32 %121, -1
  br i1 %122, label %123, label %126

123:                                              ; preds = %119
  call void @perror(ptr noundef @.str.19)
  %124 = load i32, ptr %17, align 4, !tbaa !5
  %125 = call i32 @close(i32 noundef %124)
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

126:                                              ; preds = %119
  %127 = load i32, ptr %17, align 4, !tbaa !5
  %128 = call i32 (i32, i64, ...) @ioctl(i32 noundef %127, i64 noundef 1074031364, ptr noundef %11) #4
  %129 = icmp eq i32 %128, -1
  br i1 %129, label %130, label %133

130:                                              ; preds = %126
  call void @perror(ptr noundef @.str.20)
  %131 = load i32, ptr %17, align 4, !tbaa !5
  %132 = call i32 @close(i32 noundef %131)
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

133:                                              ; preds = %126
  br label %141

134:                                              ; preds = %98
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %136
  %138 = getelementptr inbounds %struct.rc_spi_state_t, ptr %137, i32 0, i32 5
  %139 = getelementptr inbounds [12 x i32], ptr %138, i64 0, i64 0
  %140 = load i32, ptr %139, align 16, !tbaa !5
  store i32 %140, ptr %17, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %134, %133
  %142 = load i32, ptr %8, align 4, !tbaa !5
  %143 = icmp eq i32 %142, 1
  br i1 %143, label %144, label %157

144:                                              ; preds = %141
  %145 = load i32, ptr %9, align 4, !tbaa !5
  %146 = icmp eq i32 %145, 0
  br i1 %146, label %147, label %157

147:                                              ; preds = %144
  %148 = load i32, ptr %15, align 4, !tbaa !5
  %149 = icmp eq i32 %148, 7
  br i1 %149, label %150, label %157

150:                                              ; preds = %147
  %151 = call i32 @rc_pinmux_set(i32 noundef 29, i32 noundef 0)
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %153, label %156

153:                                              ; preds = %150
  %154 = load ptr, ptr @stderr, align 8, !tbaa !9
  %155 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %154, ptr noundef @.str.21) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

156:                                              ; preds = %150
  br label %214

157:                                              ; preds = %147, %144, %141
  %158 = load i32, ptr %8, align 4, !tbaa !5
  %159 = icmp eq i32 %158, 1
  br i1 %159, label %160, label %173

160:                                              ; preds = %157
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = icmp eq i32 %161, 1
  br i1 %162, label %163, label %173

163:                                              ; preds = %160
  %164 = load i32, ptr %15, align 4, !tbaa !5
  %165 = icmp eq i32 %164, 7
  br i1 %165, label %166, label %173

166:                                              ; preds = %163
  %167 = call i32 @rc_pinmux_set(i32 noundef 7, i32 noundef 0)
  %168 = icmp ne i32 %167, 0
  br i1 %168, label %169, label %172

169:                                              ; preds = %166
  %170 = load ptr, ptr @stderr, align 8, !tbaa !9
  %171 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %170, ptr noundef @.str.21) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

172:                                              ; preds = %166
  br label %213

173:                                              ; preds = %163, %160, %157
  %174 = load i32, ptr %8, align 4, !tbaa !5
  %175 = icmp eq i32 %174, 1
  br i1 %175, label %176, label %192

176:                                              ; preds = %173
  %177 = load i32, ptr %9, align 4, !tbaa !5
  %178 = icmp eq i32 %177, 0
  br i1 %178, label %179, label %192

179:                                              ; preds = %176
  %180 = load i32, ptr %15, align 4, !tbaa !5
  %181 = icmp eq i32 %180, 2
  br i1 %181, label %185, label %182

182:                                              ; preds = %179
  %183 = load i32, ptr %15, align 4, !tbaa !5
  %184 = icmp eq i32 %183, 4
  br i1 %184, label %185, label %192

185:                                              ; preds = %182, %179
  %186 = call i32 @rc_pinmux_set(i32 noundef 113, i32 noundef 0)
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %191

188:                                              ; preds = %185
  %189 = load ptr, ptr @stderr, align 8, !tbaa !9
  %190 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %189, ptr noundef @.str.21) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

191:                                              ; preds = %185
  br label %212

192:                                              ; preds = %182, %176, %173
  %193 = load i32, ptr %8, align 4, !tbaa !5
  %194 = icmp eq i32 %193, 1
  br i1 %194, label %195, label %211

195:                                              ; preds = %192
  %196 = load i32, ptr %9, align 4, !tbaa !5
  %197 = icmp eq i32 %196, 1
  br i1 %197, label %198, label %211

198:                                              ; preds = %195
  %199 = load i32, ptr %15, align 4, !tbaa !5
  %200 = icmp eq i32 %199, 2
  br i1 %200, label %204, label %201

201:                                              ; preds = %198
  %202 = load i32, ptr %15, align 4, !tbaa !5
  %203 = icmp eq i32 %202, 4
  br i1 %203, label %204, label %211

204:                                              ; preds = %201, %198
  %205 = call i32 @rc_pinmux_set(i32 noundef 49, i32 noundef 0)
  %206 = icmp ne i32 %205, 0
  br i1 %206, label %207, label %210

207:                                              ; preds = %204
  %208 = load ptr, ptr @stderr, align 8, !tbaa !9
  %209 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %208, ptr noundef @.str.21) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

210:                                              ; preds = %204
  br label %211

211:                                              ; preds = %210, %201, %195, %192
  br label %212

212:                                              ; preds = %211, %191
  br label %213

213:                                              ; preds = %212, %172
  br label %214

214:                                              ; preds = %213, %156
  %215 = load i32, ptr %12, align 4, !tbaa !5
  %216 = load i32, ptr %13, align 4, !tbaa !5
  %217 = call i32 @rc_gpio_init(i32 noundef %215, i32 noundef %216, i32 noundef 2)
  %218 = icmp ne i32 %217, 0
  br i1 %218, label %219, label %222

219:                                              ; preds = %214
  %220 = load ptr, ptr @stderr, align 8, !tbaa !9
  %221 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %220, ptr noundef @.str.22) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

222:                                              ; preds = %214
  %223 = load i32, ptr %12, align 4, !tbaa !5
  %224 = load i32, ptr %13, align 4, !tbaa !5
  %225 = call i32 @rc_gpio_set_value(i32 noundef %223, i32 noundef %224, i32 noundef 1)
  %226 = icmp ne i32 %225, 0
  br i1 %226, label %227, label %230

227:                                              ; preds = %222
  %228 = load ptr, ptr @stderr, align 8, !tbaa !9
  %229 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %228, ptr noundef @.str.23) #4
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

230:                                              ; preds = %222
  %231 = load i32, ptr %8, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %232
  %234 = getelementptr inbounds %struct.rc_spi_state_t, ptr %233, i32 0, i32 0
  %235 = load i32, ptr %9, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [12 x i8], ptr %234, i64 0, i64 %236
  store i8 1, ptr %237, align 1, !tbaa !11
  %238 = load i32, ptr %8, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %239
  %241 = getelementptr inbounds %struct.rc_spi_state_t, ptr %240, i32 0, i32 1
  %242 = load i32, ptr %9, align 4, !tbaa !5
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds [12 x i8], ptr %241, i64 0, i64 %243
  store i8 2, ptr %244, align 1, !tbaa !11
  %245 = load i32, ptr %12, align 4, !tbaa !5
  %246 = trunc i32 %245 to i8
  %247 = load i32, ptr %8, align 4, !tbaa !5
  %248 = sext i32 %247 to i64
  %249 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %248
  %250 = getelementptr inbounds %struct.rc_spi_state_t, ptr %249, i32 0, i32 2
  %251 = load i32, ptr %9, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [12 x i8], ptr %250, i64 0, i64 %252
  store i8 %246, ptr %253, align 1, !tbaa !11
  %254 = load i32, ptr %13, align 4, !tbaa !5
  %255 = trunc i32 %254 to i8
  %256 = load i32, ptr %8, align 4, !tbaa !5
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %257
  %259 = getelementptr inbounds %struct.rc_spi_state_t, ptr %258, i32 0, i32 3
  %260 = load i32, ptr %9, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [12 x i8], ptr %259, i64 0, i64 %261
  store i8 %255, ptr %262, align 1, !tbaa !11
  %263 = load i32, ptr %17, align 4, !tbaa !5
  %264 = load i32, ptr %8, align 4, !tbaa !5
  %265 = sext i32 %264 to i64
  %266 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %265
  %267 = getelementptr inbounds %struct.rc_spi_state_t, ptr %266, i32 0, i32 5
  %268 = load i32, ptr %9, align 4, !tbaa !5
  %269 = sext i32 %268 to i64
  %270 = getelementptr inbounds [12 x i32], ptr %267, i64 0, i64 %269
  store i32 %263, ptr %270, align 4, !tbaa !5
  %271 = load i32, ptr %17, align 4, !tbaa !5
  %272 = load i32, ptr %8, align 4, !tbaa !5
  %273 = sext i32 %272 to i64
  %274 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %273
  %275 = getelementptr inbounds %struct.rc_spi_state_t, ptr %274, i32 0, i32 5
  %276 = getelementptr inbounds [12 x i32], ptr %275, i64 0, i64 0
  store i32 %271, ptr %276, align 16, !tbaa !5
  %277 = load i32, ptr %11, align 4, !tbaa !5
  %278 = load i32, ptr %8, align 4, !tbaa !5
  %279 = sext i32 %278 to i64
  %280 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %279
  %281 = getelementptr inbounds %struct.rc_spi_state_t, ptr %280, i32 0, i32 4
  %282 = load i32, ptr %9, align 4, !tbaa !5
  %283 = sext i32 %282 to i64
  %284 = getelementptr inbounds [12 x i32], ptr %281, i64 0, i64 %283
  store i32 %277, ptr %284, align 4, !tbaa !5
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %285

285:                                              ; preds = %230, %227, %219, %207, %188, %169, %153, %130, %123, %116, %111, %95, %86, %77, %62, %44, %35, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %286 = load i32, ptr %7, align 4
  ret i32 %286
}

declare i32 @rc_gpio_init(i32 noundef, i32 noundef, i32 noundef) #1

declare i32 @rc_gpio_set_value(i32 noundef, i32 noundef, i32 noundef) #1

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 "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 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 = !{!"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 = !{!7, !7, 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"

%struct.rc_spi_state_t = type { [12 x i8], [12 x i8], [12 x i8], [12 x i8], [12 x i32], [12 x i32] }

@stderr = external local_unnamed_addr global ptr, align 8
@state = external hidden local_unnamed_addr global [6 x %struct.rc_spi_state_t], align 16
@.str.11 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [77 x i8], align 1

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

declare i32 @rc_model() local_unnamed_addr #1

declare i32 @rc_model_category() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @__open_fd(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @ioctl(i32 noundef, i64 noundef, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #2

declare i32 @close(i32 noundef) local_unnamed_addr #1

declare i32 @rc_pinmux_set(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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 range(i32 -1, 1) i32 @rc_spi_init_manual_slave(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #3 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #5
  store i32 8, ptr %9, align 4, !tbaa !5
  %10 = tail call i32 @rc_model() #5
  %11 = tail call i32 @rc_model_category() #5
  %or.cond = icmp ugt i32 %0, 5
  br i1 %or.cond, label %12, label %15

12:                                               ; preds = %6
  %13 = load ptr, ptr @stderr, align 8, !tbaa !9
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.11, i32 noundef 5) #6
  br label %122

15:                                               ; preds = %6
  %or.cond3 = icmp ugt i32 %1, 11
  br i1 %or.cond3, label %16, label %19

16:                                               ; preds = %15
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.12, i32 noundef 11) #6
  br label %122

19:                                               ; preds = %15
  %20 = add i32 %3, -24000001
  %or.cond5 = icmp ult i32 %20, -23999001
  br i1 %or.cond5, label %21, label %24

21:                                               ; preds = %19
  %22 = load ptr, ptr @stderr, align 8, !tbaa !9
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.13, i32 noundef 1000, i32 noundef 24000000) #6
  br label %122

24:                                               ; preds = %19
  %or.cond14 = icmp ugt i32 %2, 3
  br i1 %or.cond14, label %25, label %28

25:                                               ; preds = %24
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.14) #6
  br label %122

28:                                               ; preds = %24
  %29 = icmp eq i32 %0, 1
  %30 = icmp eq i32 %1, 1
  %or.cond16 = and i1 %29, %30
  br i1 %or.cond16, label %31, label %35

31:                                               ; preds = %28
  switch i32 %10, label %.thread107 [
    i32 4, label %32
    i32 2, label %32
  ]

32:                                               ; preds = %31, %31
  %33 = load ptr, ptr @stderr, align 8, !tbaa !9
  %34 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef nonnull @.str.15) #6
  br label %122

35:                                               ; preds = %28
  %36 = icmp ugt i32 %0, 1
  %37 = icmp eq i32 %11, 1
  %or.cond20 = select i1 %36, i1 %37, i1 false
  br i1 %or.cond20, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr @stderr, align 8, !tbaa !9
  %40 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.16) #6
  br label %122

41:                                               ; preds = %35
  %42 = icmp ugt i32 %1, 1
  %or.cond22 = select i1 %42, i1 %37, i1 false
  br i1 %or.cond22, label %43, label %.thread107

43:                                               ; preds = %41
  %44 = load ptr, ptr @stderr, align 8, !tbaa !9
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.17) #6
  br label %122

.thread107:                                       ; preds = %31, %41
  %46 = zext nneg i32 %0 to i64
  %47 = getelementptr inbounds [6 x %struct.rc_spi_state_t], ptr @state, i64 0, i64 %46
  %48 = getelementptr inbounds i8, ptr %47, i64 96
  %49 = load i32, ptr %48, align 16, !tbaa !5
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %69

51:                                               ; preds = %.thread107
  %52 = tail call i32 @__open_fd(i32 noundef %0, i32 noundef 0)
  %53 = icmp eq i32 %52, -1
  br i1 %53, label %122, label %54

54:                                               ; preds = %51
  %55 = call i32 (i32, i64, ...) @ioctl(i32 noundef %52, i64 noundef 1073834753, ptr noundef nonnull %7) #5
  %56 = icmp eq i32 %55, -1
  br i1 %56, label %57, label %59

57:                                               ; preds = %54
  call void @perror(ptr noundef nonnull @.str.18) #7
  %58 = call i32 @close(i32 noundef %52) #5
  br label %122

59:                                               ; preds = %54
  %60 = call i32 (i32, i64, ...) @ioctl(i32 noundef %52, i64 noundef 1073834755, ptr noundef nonnull %9) #5
  %61 = icmp eq i32 %60, -1
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  call void @perror(ptr noundef nonnull @.str.19) #7
  %63 = call i32 @close(i32 noundef %52) #5
  br label %122

64:                                               ; preds = %59
  %65 = call i32 (i32, i64, ...) @ioctl(i32 noundef %52, i64 noundef 1074031364, ptr noundef nonnull %8) #5
  %66 = icmp eq i32 %65, -1
  br i1 %66, label %67, label %69

67:                                               ; preds = %64
  call void @perror(ptr noundef nonnull @.str.20) #7
  %68 = call i32 @close(i32 noundef %52) #5
  br label %122

69:                                               ; preds = %.thread107, %64
  %.0 = phi i32 [ %52, %64 ], [ %49, %.thread107 ]
  %70 = icmp eq i32 %1, 0
  %or.cond24 = and i1 %29, %70
  %71 = icmp eq i32 %10, 7
  %or.cond26 = select i1 %or.cond24, i1 %71, i1 false
  br i1 %or.cond26, label %72, label %77

72:                                               ; preds = %69
  %73 = call i32 @rc_pinmux_set(i32 noundef 29, i32 noundef 0) #5
  %.not103 = icmp eq i32 %73, 0
  br i1 %.not103, label %97, label %74

74:                                               ; preds = %72
  %75 = load ptr, ptr @stderr, align 8, !tbaa !9
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef nonnull @.str.21) #6
  br label %122

77:                                               ; preds = %69
  %or.cond30 = select i1 %or.cond16, i1 %71, i1 false
  br i1 %or.cond30, label %78, label %83

78:                                               ; preds = %77
  %79 = call i32 @rc_pinmux_set(i32 noundef 7, i32 noundef 0) #5
  %.not102 = icmp eq i32 %79, 0
  br i1 %.not102, label %97, label %80

80:                                               ; preds = %78
  %81 = load ptr, ptr @stderr, align 8, !tbaa !9
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef nonnull @.str.21) #6
  br label %122

83:                                               ; preds = %77
  br i1 %or.cond24, label %84, label %90

84:                                               ; preds = %83
  switch i32 %10, label %90 [
    i32 4, label %85
    i32 2, label %85
  ]

85:                                               ; preds = %84, %84
  %86 = call i32 @rc_pinmux_set(i32 noundef 113, i32 noundef 0) #5
  %.not101 = icmp eq i32 %86, 0
  br i1 %.not101, label %97, label %87

87:                                               ; preds = %85
  %88 = load ptr, ptr @stderr, align 8, !tbaa !9
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef nonnull @.str.21) #6
  br label %122

90:                                               ; preds = %84, %83
  br i1 %or.cond16, label %91, label %97

91:                                               ; preds = %90
  switch i32 %10, label %97 [
    i32 4, label %92
    i32 2, label %92
  ]

92:                                               ; preds = %91, %91
  %93 = call i32 @rc_pinmux_set(i32 noundef 49, i32 noundef 0) #5
  %.not = icmp eq i32 %93, 0
  br i1 %.not, label %97, label %94

94:                                               ; preds = %92
  %95 = load ptr, ptr @stderr, align 8, !tbaa !9
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef nonnull @.str.21) #6
  br label %122

97:                                               ; preds = %91, %78, %90, %92, %85, %72
  %98 = call i32 @rc_gpio_init(i32 noundef %4, i32 noundef %5, i32 noundef 2) #5
  %.not104 = icmp eq i32 %98, 0
  br i1 %.not104, label %102, label %99

99:                                               ; preds = %97
  %100 = load ptr, ptr @stderr, align 8, !tbaa !9
  %101 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %100, ptr noundef nonnull @.str.22) #6
  br label %122

102:                                              ; preds = %97
  %103 = call i32 @rc_gpio_set_value(i32 noundef %4, i32 noundef %5, i32 noundef 1) #5
  %.not105 = icmp eq i32 %103, 0
  br i1 %.not105, label %107, label %104

104:                                              ; preds = %102
  %105 = load ptr, ptr @stderr, align 8, !tbaa !9
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %105, ptr noundef nonnull @.str.23) #6
  br label %122

107:                                              ; preds = %102
  %108 = zext nneg i32 %1 to i64
  %109 = getelementptr inbounds [12 x i8], ptr %47, i64 0, i64 %108
  store i8 1, ptr %109, align 1, !tbaa !11
  %110 = getelementptr inbounds i8, ptr %47, i64 12
  %111 = getelementptr inbounds [12 x i8], ptr %110, i64 0, i64 %108
  store i8 2, ptr %111, align 1, !tbaa !11
  %112 = trunc i32 %4 to i8
  %113 = getelementptr inbounds i8, ptr %47, i64 24
  %114 = getelementptr inbounds [12 x i8], ptr %113, i64 0, i64 %108
  store i8 %112, ptr %114, align 1, !tbaa !11
  %115 = trunc i32 %5 to i8
  %116 = getelementptr inbounds i8, ptr %47, i64 36
  %117 = getelementptr inbounds [12 x i8], ptr %116, i64 0, i64 %108
  store i8 %115, ptr %117, align 1, !tbaa !11
  %118 = getelementptr inbounds [12 x i32], ptr %48, i64 0, i64 %108
  store i32 %.0, ptr %118, align 4, !tbaa !5
  store i32 %.0, ptr %48, align 16, !tbaa !5
  %119 = load i32, ptr %8, align 4, !tbaa !5
  %120 = getelementptr inbounds i8, ptr %47, i64 48
  %121 = getelementptr inbounds [12 x i32], ptr %120, i64 0, i64 %108
  store i32 %119, ptr %121, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %51, %107, %104, %99, %94, %87, %80, %74, %67, %62, %57, %43, %38, %32, %25, %21, %16, %12
  %.096 = phi i32 [ -1, %12 ], [ -1, %16 ], [ -1, %21 ], [ -1, %25 ], [ -1, %32 ], [ -1, %38 ], [ -1, %43 ], [ -1, %57 ], [ -1, %62 ], [ -1, %67 ], [ -1, %74 ], [ -1, %99 ], [ -1, %104 ], [ 0, %107 ], [ -1, %80 ], [ -1, %87 ], [ -1, %94 ], [ -1, %51 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #5
  ret i32 %.096
}

declare i32 @rc_gpio_init(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @rc_gpio_set_value(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 #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 "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 = { cold nounwind }
attributes #7 = { cold }

!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 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass