#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct mstats_base {
  int dummy;
};

/* Variables and functions */
scalar_t__ mstats_base_parse(char const *, char const *, int *, int *);
int /*<<< orphan*/ mstats_base_set_thres(struct mstats_base *, int, int, int);
int mstats_base_init(struct mstats_base *stb, int keyrange, const char **items,
                     const char *ss) {
  int i = 0, sl = 0, val = 0;
  for (i = 1; i < keyrange; i++)
    if ((mstats_base_parse(ss, items[i], &sl, &val)) == 0)
      mstats_base_set_thres(stb, sl, i, val);
  return 0;
}


x86 assembly (clang, -O0):
<mstats_base_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ab <mstats_base_init+0x8b>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1030 <mstats_base_parse@plt>
cmp    $0x0,%rax
jne    1198 <mstats_base_init+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1040 <mstats_base_set_thres@plt>
jmp    119d <mstats_base_init+0x7d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1153 <mstats_base_init+0x33>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mstats_base_init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
cmp    $0x2,%esi
jl     11a6 <mstats_base_init+0x86>
mov    %rcx,%r14
mov    %rdx,%r12
mov    %esi,%r15d
mov    $0x1,%ebx
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbp
jmp    1179 <mstats_base_init+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     11a6 <mstats_base_init+0x86>
mov    (%r12,%rbx,8),%rsi
mov    %r14,%rdi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1030 <mstats_base_parse@plt>
test   %rax,%rax
jne    1170 <mstats_base_init+0x50>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%rdi
mov    %ebx,%edx
call   1040 <mstats_base_set_thres@plt>
jmp    1170 <mstats_base_init+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mstats_base = type { i32 }
define i32 @mstats_base_init(%struct.mstats_base* %0, i32 %1, i8** %2, i8* %3) {
%5 = alloca %struct.mstats_base*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.mstats_base* %0, %struct.mstats_base** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8* %3, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 1, i32* %9
br label %12
12: ; preds = %32, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %12
%17 = load i8*, i8** %8
%18 = load i8**, i8*** %7
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @mstats_base_parse(i8* %17, i8* %22, i32* %10, i32* %11)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %16
%26 = load %struct.mstats_base*, %struct.mstats_base** %5
%27 = load i32, i32* %10
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = call i32 @mstats_base_set_thres(%struct.mstats_base* %26, i32 %27, i32 %28, i32 %29)
br label %31
31: ; preds = %25, %16
br label %32
32: ; preds = %31
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %12
35: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
%struct.mstats_base = type { i32 }
define i32 @mstats_base_init(%struct.mstats_base* %0, i32 %1, i8** nocapture %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = icmp sgt i32 %1, 1
br i1 %9, label %10, label %26
10: ; preds = %4
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %23
%13 = phi i64 [ 1, %10 ], [ %24, %23 ]
%14 = getelementptr inbounds i8*, i8** %2, i64 %13
%15 = load i8*, i8** %14
%16 = call i64 @mstats_base_parse(i8* %3, i8* %15, i32* %5, i32* %6)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = trunc i64 %13 to i32
%22 = call i32 @mstats_base_set_thres(%struct.mstats_base* %0, i32 %19, i32 %21, i32 %20)
br label %23
23: ; preds = %12, %18
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, %11
br i1 %25, label %26, label %12
26: ; preds = %23, %4
ret i32 0
}