#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 */
unsigned short atoi(char *);
unsigned int readNextName(char *, char **, char **, unsigned int *);
int /*<<< orphan*/ readNextValue(char *, char **, char **, unsigned char *);
void getSetting(unsigned int settingHash, char *rule, unsigned short *value) {
  char *first;
  char *last;
  char temp;
  unsigned int hash;
  unsigned char type;
  unsigned int result = readNextName(rule, &first, &last, &hash);
  while (result == 0) {
    readNextValue(last, &first, &last, &type);
    if (hash == settingHash) {
      temp = first[last - first + 1];
      first[last - first + 1] = '\0';
      *value = atoi(first);
      first[last - first + 1] = temp;
      break;
    }
    result = readNextName(last, &first, &last, &hash);
  }
}


x86 assembly (clang, -O0):
<getSetting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1040 <readNextName@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    11fb <getSetting+0xcb>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x31(%rbp),%rcx
call   1030 <readNextValue@plt>
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11de <getSetting+0xae>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
sub    %rdx,%rcx
mov    0x1(%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
mov    -0x29(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rsi
sub    %rsi,%rcx
mov    %dl,0x1(%rax,%rcx,1)
jmp    11fb <getSetting+0xcb>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1040 <readNextName@plt>
mov    %eax,-0x38(%rbp)
jmp    115b <getSetting+0x2b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSetting>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%rax
mov    %edi,%r15d
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x1c(%rsp),%rcx
mov    %rax,%rdi
call   1040 <readNextName@plt>
test   %eax,%eax
jne    11d5 <getSetting+0xa5>
lea    0x20(%rsp),%rbx
lea    0x10(%rsp),%rbp
lea    0xf(%rsp),%r12
lea    0x1c(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1030 <readNextValue@plt>
cmp    %r15d,0x1c(%rsp)
je     11b3 <getSetting+0x83>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
call   1040 <readNextName@plt>
test   %eax,%eax
je     1180 <getSetting+0x50>
jmp    11d5 <getSetting+0xa5>
mov    0x10(%rsp),%rax
mov    0x1(%rax),%bl
movb   $0x0,0x1(%rax)
mov    0x20(%rsp),%rdi
call   1050 <atoi@plt>
mov    %ax,(%r14)
mov    0x10(%rsp),%rax
mov    %bl,0x1(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @getSetting(i32 %0, i8* %1, i16* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i16*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i16* %2, i16** %6
%13 = load i8*, i8** %5
%14 = call i32 @readNextName(i8* %13, i8** %7, i8** %8, i32* %10)
store i32 %14, i32* %12
br label %15
15: ; preds = %54, %3
%16 = load i32, i32* %12
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %57
18: ; preds = %15
%19 = load i8*, i8** %8
%20 = call i32 @readNextValue(i8* %19, i8** %7, i8** %8, i8* %11)
%21 = load i32, i32* %10
%22 = load i32, i32* %4
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %54
24: ; preds = %18
%25 = load i8*, i8** %7
%26 = load i8*, i8** %8
%27 = load i8*, i8** %7
%28 = ptrtoint i8* %26 to i64
%29 = ptrtoint i8* %27 to i64
%30 = sub i64 %28, %29
%31 = add nsw i64 %30, 1
%32 = getelementptr inbounds i8, i8* %25, i64 %31
%33 = load i8, i8* %32
store i8 %33, i8* %9
%34 = load i8*, i8** %7
%35 = load i8*, i8** %8
%36 = load i8*, i8** %7
%37 = ptrtoint i8* %35 to i64
%38 = ptrtoint i8* %36 to i64
%39 = sub i64 %37, %38
%40 = add nsw i64 %39, 1
%41 = getelementptr inbounds i8, i8* %34, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %7
%43 = call zeroext i16 @atoi(i8* %42)
%44 = load i16*, i16** %6
store i16 %43, i16* %44
%45 = load i8, i8* %9
%46 = load i8*, i8** %7
%47 = load i8*, i8** %8
%48 = load i8*, i8** %7
%49 = ptrtoint i8* %47 to i64
%50 = ptrtoint i8* %48 to i64
%51 = sub i64 %49, %50
%52 = add nsw i64 %51, 1
%53 = getelementptr inbounds i8, i8* %46, i64 %52
store i8 %45, i8* %53
br label %57
54: ; preds = %18
%55 = load i8*, i8** %8
%56 = call i32 @readNextName(i8* %55, i8** %7, i8** %8, i32* %10)
store i32 %56, i32* %12
br label %15
57: ; preds = %24, %15
ret void
}

LLVM IR (-O2):
define void @getSetting(i32 %0, i8* %1, i16* nocapture writeonly %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = bitcast i8** %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32 @readNextName(i8* %1, i8** %4, i8** %5, i32* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %39
13: ; preds = %3, %35
%14 = load i8*, i8** %5
%15 = call i32 @readNextValue(i8* %14, i8** %4, i8** %5, i8* %7)
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %35
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = ptrtoint i8* %20 to i64
%22 = ptrtoint i8* %19 to i64
%23 = sub i64 1, %22
%24 = add i64 %23, %21
%25 = getelementptr inbounds i8, i8* %19, i64 %24
%26 = load i8, i8* %25
store i8 0, i8* %25
%27 = load i8*, i8** %4
%28 = call zeroext i16 @atoi(i8* %27)
store i16 %28, i16* %2
%29 = load i8*, i8** %5
%30 = ptrtoint i8* %29 to i64
%31 = ptrtoint i8* %27 to i64
%32 = sub i64 1, %31
%33 = add i64 %32, %30
%34 = getelementptr inbounds i8, i8* %27, i64 %33
store i8 %26, i8* %34
br label %39
35: ; preds = %13
%36 = load i8*, i8** %5
%37 = call i32 @readNextName(i8* %36, i8** %4, i8** %5, i32* %6)
%38 = icmp eq i32 %37, 0
br i1 %38, label %13, label %39
39: ; preds = %35, %3, %18
ret void
}