#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 */

/* Variables and functions */
int strlen(char const *);
char *strstr(char const *, char const *);
scalar_t__ strtoul(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
unsigned mi_get(const char *config, const char *opt, unsigned def) {
  const char *ptr = strstr(config, opt);
  return (ptr ? (unsigned)strtoul(ptr + strlen(opt) + 1, NULL, 0) : def);
}


x86 assembly (clang, -O0):
<mi_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1190 <mi_get+0x60>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x24(%rbp)
jmp    1196 <mi_get+0x66>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mi_get>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
call   1050 <strstr@plt>
test   %rax,%rax
je     1166 <mi_get+0x36>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,%r14
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @mi_get(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i8* @strstr(i8* %8, i8* %9)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %22
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i64 @strtoul(i8* %19, i32* null, i32 0)
%21 = trunc i64 %20 to i32
br label %24
22: ; preds = %3
%23 = load i32, i32* %6
br label %24
24: ; preds = %22, %13
%25 = phi i32 [ %21, %13 ], [ %23, %22 ]
ret i32 %25
}

LLVM IR (-O2):
define i32 @mi_get(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %1)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call i64 @strtoul(i8* nocapture %10, i32* null, i32 0)
%12 = trunc i64 %11 to i32
br label %13
13: ; preds = %3, %6
%14 = phi i32 [ %12, %6 ], [ %2, %3 ]
ret i32 %14
}