#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 in_addr {
  int /*<<< orphan*/ s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ evdns_nameserver_add(int /*<<< orphan*/);
int /*<<< orphan*/ evdns_set_option(char const *, char const *, int);
void *evdns_strtok_r(char *const, char const *const, char **);
scalar_t__ inet_aton(char const *const, struct in_addr *);
int /*<<< orphan*/ search_postfix_add(char const *);
int /*<<< orphan*/ search_postfix_clear();
int /*<<< orphan*/ search_reverse();
char *strchr(char const *, char);
int /*<<< orphan*/ strcmp(char *const, char *);
void resolv_conf_parse_line(char *const start, int flags) {
  char *strtok_state = NULL;
  static const char *const delims = " \t";
  char *const first_token = evdns_strtok_r(start, delims, &strtok_state);
  if (!first_token)
    return;
  if (!strcmp(first_token, "nameserver") && (flags & 2)) {
    const char *const nameserver = evdns_strtok_r(NULL, delims, &strtok_state);
    struct in_addr ina;
    if (inet_aton(nameserver, &ina)) {
      evdns_nameserver_add(ina.s_addr);
    }
  } else if (!strcmp(first_token, "domain") && (flags & 1)) {
    const char *const domain = evdns_strtok_r(NULL, delims, &strtok_state);
    if (domain) {
      search_postfix_clear();
      search_postfix_add(domain);
    }
  } else if (!strcmp(first_token, "search") && (flags & 1)) {
    const char *domain;
    search_postfix_clear();
    while ((domain = evdns_strtok_r(NULL, delims, &strtok_state))) {
      search_postfix_add(domain);
    }
    search_reverse();
  } else if (!strcmp(first_token, "options")) {
    const char *option;
    while ((option = evdns_strtok_r(NULL, delims, &strtok_state))) {
      const char *val = strchr(option, ':');
      evdns_set_option(option, val ? val + 1 : "", flags);
    }
  }
}


x86 assembly (clang, -O0):
<resolv_conf_parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <evdns_strtok_r@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11cf <resolv_conf_parse_line+0x3f>
jmp    13ad <resolv_conf_parse_line+0x21d>
mov    -0x20(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1233 <resolv_conf_parse_line+0xa3>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1233 <resolv_conf_parse_line+0xa3>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdfe(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <evdns_strtok_r@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <inet_aton@plt>
cmp    $0x0,%rax
je     122e <resolv_conf_parse_line+0x9e>
mov    -0x30(%rbp),%edi
call   10b0 <evdns_nameserver_add@plt>
jmp    13ad <resolv_conf_parse_line+0x21d>
mov    -0x20(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1293 <resolv_conf_parse_line+0x103>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1293 <resolv_conf_parse_line+0x103>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd9a(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <evdns_strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     128e <resolv_conf_parse_line+0xfe>
mov    $0x0,%al
call   1090 <search_postfix_clear@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <search_postfix_add@plt>
jmp    13a8 <resolv_conf_parse_line+0x218>
mov    -0x20(%rbp),%rdi
lea    0xd77(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12fe <resolv_conf_parse_line+0x16e>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     12fe <resolv_conf_parse_line+0x16e>
mov    $0x0,%al
call   1090 <search_postfix_clear@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd33(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <evdns_strtok_r@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     12f2 <resolv_conf_parse_line+0x162>
mov    -0x40(%rbp),%rdi
call   10a0 <search_postfix_add@plt>
jmp    12c2 <resolv_conf_parse_line+0x132>
mov    $0x0,%al
call   1040 <search_reverse@plt>
jmp    13a3 <resolv_conf_parse_line+0x213>
mov    -0x20(%rbp),%rdi
lea    0xd13(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    139e <resolv_conf_parse_line+0x20e>
jmp    131c <resolv_conf_parse_line+0x18c>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcd9(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <evdns_strtok_r@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     1399 <resolv_conf_parse_line+0x209>
mov    -0x48(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1374 <resolv_conf_parse_line+0x1e4>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1384 <resolv_conf_parse_line+0x1f4>
lea    0xc87(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    1384 <resolv_conf_parse_line+0x1f4>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <evdns_set_option@plt>
jmp    131c <resolv_conf_parse_line+0x18c>
jmp    139e <resolv_conf_parse_line+0x20e>
jmp    13a3 <resolv_conf_parse_line+0x213>
jmp    13a8 <resolv_conf_parse_line+0x218>
jmp    13ad <resolv_conf_parse_line+0x21d>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resolv_conf_parse_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
movq   $0x0,(%rsp)
lea    0xe53(%rip),%rsi
mov    %rsp,%rdx
call   1060 <evdns_strtok_r@plt>
test   %rax,%rax
je     1337 <resolv_conf_parse_line+0x1a7>
mov    %rax,%rbx
lea    0xe3b(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
test   $0x2,%bpl
je     120f <resolv_conf_parse_line+0x7f>
test   %eax,%eax
jne    120f <resolv_conf_parse_line+0x7f>
lea    0xe1f(%rip),%rsi
mov    %rsp,%rdx
xor    %edi,%edi
call   1060 <evdns_strtok_r@plt>
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1080 <inet_aton@plt>
test   %rax,%rax
je     1337 <resolv_conf_parse_line+0x1a7>
mov    0x8(%rsp),%edi
call   10b0 <evdns_nameserver_add@plt>
jmp    1337 <resolv_conf_parse_line+0x1a7>
lea    0xdf8(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   $0x1,%bpl
je     1259 <resolv_conf_parse_line+0xc9>
test   %eax,%eax
jne    1259 <resolv_conf_parse_line+0xc9>
lea    0xdd1(%rip),%rsi
mov    %rsp,%rdx
xor    %edi,%edi
call   1060 <evdns_strtok_r@plt>
test   %rax,%rax
je     1337 <resolv_conf_parse_line+0x1a7>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <search_postfix_clear@plt>
mov    %rbx,%rdi
call   10a0 <search_postfix_add@plt>
jmp    1337 <resolv_conf_parse_line+0x1a7>
lea    0xdb5(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   $0x1,%bpl
je     12c3 <resolv_conf_parse_line+0x133>
test   %eax,%eax
jne    12c3 <resolv_conf_parse_line+0x133>
xor    %eax,%eax
call   1090 <search_postfix_clear@plt>
lea    0xd80(%rip),%rsi
mov    %rsp,%rdx
xor    %edi,%edi
call   1060 <evdns_strtok_r@plt>
test   %rax,%rax
je     12ba <resolv_conf_parse_line+0x12a>
lea    0xd6a(%rip),%rbx
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %rax,%rdi
call   10a0 <search_postfix_add@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1060 <evdns_strtok_r@plt>
test   %rax,%rax
jne    12a0 <resolv_conf_parse_line+0x110>
xor    %eax,%eax
call   1040 <search_reverse@plt>
jmp    1337 <resolv_conf_parse_line+0x1a7>
lea    0xd52(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1337 <resolv_conf_parse_line+0x1a7>
lea    0xd23(%rip),%rsi
mov    %rsp,%rdx
xor    %edi,%edi
call   1060 <evdns_strtok_r@plt>
test   %rax,%rax
je     1337 <resolv_conf_parse_line+0x1a7>
mov    %rax,%rbx
lea    0xd0c(%rip),%r12
lea    0xd03(%rip),%r14
mov    %rsp,%r15
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rsi
test   %rax,%rax
cmove  %r12,%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <evdns_set_option@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <evdns_strtok_r@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1300 <resolv_conf_parse_line+0x170>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@resolv_conf_parse_line.delims = internal constant i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)
@.str = [3 x i8] c" \09\00"
@.str.1 = [11 x i8] c"nameserver\00"
@.str.2 = [7 x i8] c"domain\00"
@.str.3 = [7 x i8] c"search\00"
@.str.4 = [8 x i8] c"options\00"
@.str.5 = [1 x i8] zeroinitializer
define void @resolv_conf_parse_line(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.in_addr
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* null, i8** %5
%13 = load i8*, i8** %3
%14 = call i8* @evdns_strtok_r(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %5)
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %2
br label %97
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %18
%23 = load i32, i32* %4
%24 = and i32 %23, 2
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %22
%27 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %5)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = call i64 @inet_aton(i8* %28, %struct.in_addr* %8)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i32 @evdns_nameserver_add(i32 %33)
br label %35
35: ; preds = %31, %26
br label %97
36: ; preds = %22, %18
%37 = load i8*, i8** %6
%38 = call i32 @strcmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %53, label %40
40: ; preds = %36
%41 = load i32, i32* %4
%42 = and i32 %41, 1
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %5)
store i8* %45, i8** %9
%46 = load i8*, i8** %9
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = call i32 (...) @search_postfix_clear()
%50 = load i8*, i8** %9
%51 = call i32 @search_postfix_add(i8* %50)
br label %52
52: ; preds = %48, %44
br label %96
53: ; preds = %40, %36
%54 = load i8*, i8** %6
%55 = call i32 @strcmp(i8* %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %71, label %57
57: ; preds = %53
%58 = load i32, i32* %4
%59 = and i32 %58, 1
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = call i32 (...) @search_postfix_clear()
br label %63
63: ; preds = %66, %61
%64 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %5)
store i8* %64, i8** %10
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i8*, i8** %10
%68 = call i32 @search_postfix_add(i8* %67)
br label %63
69: ; preds = %63
%70 = call i32 (...) @search_reverse()
br label %95
71: ; preds = %57, %53
%72 = load i8*, i8** %6
%73 = call i32 @strcmp(i8* %72, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%74 = icmp ne i32 %73, 0
br i1 %74, label %94, label %75
75: ; preds = %71
br label %76
76: ; preds = %89, %75
%77 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %5)
store i8* %77, i8** %11
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %93
79: ; preds = %76
%80 = load i8*, i8** %11
%81 = call i8* @strchr(i8* %80, i8 signext 58)
store i8* %81, i8** %12
%82 = load i8*, i8** %11
%83 = load i8*, i8** %12
%84 = icmp ne i8* %83, null
br i1 %84, label %85, label %88
85: ; preds = %79
%86 = load i8*, i8** %12
%87 = getelementptr inbounds i8, i8* %86, i64 1
br label %89
88: ; preds = %79
br label %89
89: ; preds = %88, %85
%90 = phi i8* [ %87, %85 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %88 ]
%91 = load i32, i32* %4
%92 = call i32 @evdns_set_option(i8* %82, i8* %90, i32 %91)
br label %76
93: ; preds = %76
br label %94
94: ; preds = %93, %71
br label %95
95: ; preds = %94, %69
br label %96
96: ; preds = %95, %52
br label %97
97: ; preds = %17, %96, %35
ret void
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [3 x i8] c" \09\00"
@.str.1 = [11 x i8] c"nameserver\00"
@.str.2 = [7 x i8] c"domain\00"
@.str.3 = [7 x i8] c"search\00"
@.str.4 = [8 x i8] c"options\00"
@.str.5 = [1 x i8] zeroinitializer
define void @resolv_conf_parse_line(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.in_addr
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = call i8* @evdns_strtok_r(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %66, label %8
8: ; preds = %2
%9 = call i32 @strcmp(i8* %6, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
%11 = and i32 %1, 2
%12 = icmp eq i32 %11, 0
%13 = or i1 %12, %10
br i1 %13, label %24, label %14
14: ; preds = %8
%15 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%16 = bitcast %struct.in_addr* %4 to i8*
%17 = call i64 @inet_aton(i8* %15, %struct.in_addr* %4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i64 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @evdns_nameserver_add(i32 %21)
br label %23
23: ; preds = %19, %14
br label %66
24: ; preds = %8
%25 = call i32 @strcmp(i8* %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
%27 = and i32 %1, 1
%28 = icmp eq i32 %27, 0
%29 = or i1 %28, %26
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%32 = icmp eq i8* %31, null
br i1 %32, label %66, label %33
33: ; preds = %30
%34 = call i32 (...) @search_postfix_clear()
%35 = call i32 @search_postfix_add(i8* %31)
br label %66
36: ; preds = %24
%37 = call i32 @strcmp(i8* %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
%39 = or i1 %28, %38
br i1 %39, label %51, label %40
40: ; preds = %36
%41 = call i32 (...) @search_postfix_clear()
%42 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%43 = icmp eq i8* %42, null
br i1 %43, label %49, label %44
44: ; preds = %40, %44
%45 = phi i8* [ %47, %44 ], [ %42, %40 ]
%46 = call i32 @search_postfix_add(i8* %45)
%47 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %44
49: ; preds = %44, %40
%50 = call i32 (...) @search_reverse()
br label %66
51: ; preds = %36
%52 = call i32 @strcmp(i8* %6, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %66
54: ; preds = %51
%55 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%56 = icmp eq i8* %55, null
br i1 %56, label %66, label %57
57: ; preds = %54, %57
%58 = phi i8* [ %64, %57 ], [ %55, %54 ]
%59 = call i8* @strchr(i8* %58, i8 signext 58)
%60 = icmp eq i8* %59, null
%61 = getelementptr inbounds i8, i8* %59, i64 1
%62 = select i1 %60, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* %61
%63 = call i32 @evdns_set_option(i8* %58, i8* %62, i32 %1)
%64 = call i8* @evdns_strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3)
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %57
66: ; preds = %57, %54, %23, %49, %51, %33, %30, %2
ret void
}