#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 /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int strlen(char *);
char *trim(char *);
char *extract_nameserver(char *line) {
  char *cline = trim(line);
  char *address = NULL;
  if (cline[0] != '\n' && cline[0] != '#') {
    ;
    address = malloc(sizeof(char *) * (strlen(cline) + 2));
    sscanf(cline, "nameserver %[^#\n ]", address);
    if (strlen(address) == 0) {
      do {
        if (address)
          free(address);
        address = NULL;
      } while (0);
    }
  }
  free(cline);
  return address;
}


x86 assembly (clang, -O0):
<extract_nameserver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <trim@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     11ff <extract_nameserver+0xaf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     11ff <extract_nameserver+0xaf>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x2,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe43(%rip),%rsi
call   1070 <sscanf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    11fa <extract_nameserver+0xaa>
jmp    11d9 <extract_nameserver+0x89>
cmpq   $0x0,-0x18(%rbp)
je     11ed <extract_nameserver+0x9d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
jmp    11fa <extract_nameserver+0xaa>
jmp    11ff <extract_nameserver+0xaf>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_nameserver>:
push   %r14
push   %rbx
push   %rax
call   1050 <trim@plt>
mov    %rax,%r14
mov    (%rax),%al
xor    %ebx,%ebx
cmp    $0xa,%al
je     11ac <extract_nameserver+0x5c>
cmp    $0x23,%al
je     11ac <extract_nameserver+0x5c>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x10(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe7a(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
call   1070 <sscanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jne    11ac <extract_nameserver+0x5c>
test   %rbx,%rbx
je     11aa <extract_nameserver+0x5a>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"nameserver %[^#\0A ]\00"
define i8* @extract_nameserver(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @trim(i8* %5)
store i8* %6, i8** %3
store i8* null, i8** %4
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %42
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 35
br i1 %17, label %18, label %42
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %20, 2
%22 = sext i32 %21 to i64
%23 = mul i64 8, %22
%24 = trunc i64 %23 to i32
%25 = call i8* @malloc(i32 %24)
store i8* %25, i8** %4
%26 = load i8*, i8** %3
%27 = load i8*, i8** %4
%28 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %4
%30 = call i32 @strlen(i8* %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %18
br label %33
33: ; preds = %32
%34 = load i8*, i8** %4
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %4
%38 = call i32 @free(i8* %37)
br label %39
39: ; preds = %36, %33
store i8* null, i8** %4
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40, %18
br label %42
42: ; preds = %41, %12, %1
%43 = load i8*, i8** %3
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %4
ret i8* %45
}

LLVM IR (-O2):
@.str = [19 x i8] c"nameserver %[^#\0A ]\00"
define i8* @extract_nameserver(i8* %0) {
%2 = tail call i8* @trim(i8* %0)
%3 = load i8, i8* %2
switch i8 %3, label %4 [
i8 10, label %16
i8 35, label %16
]
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %2)
%6 = shl i32 %5, 3
%7 = add i32 %6, 16
%8 = tail call i8* @malloc(i32 %7)
%9 = tail call i32 @sscanf(i8* %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @strlen(i8* %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = icmp eq i8* %8, null
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 @free(i8* %8)
br label %16
16: ; preds = %12, %14, %1, %1, %4
%17 = phi i8* [ %8, %4 ], [ null, %1 ], [ null, %1 ], [ null, %14 ], [ null, %12 ]
%18 = tail call i32 @free(i8* %2)
ret i8* %17
}