#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(char *);
int select_interface(int, char const **, char *, char *, unsigned int *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
char *strdup(char const *);
char *strtok(char *, char *);
int parse_interface_prefs(const char *line, char *ifname, char *ip,
                          unsigned int *ifindex) {
  const char *argv[100];
  int argc = 0;
  char *s, *iniline = strdup(line);
  if ((s = strchr(iniline, '#')) != NULL) {
    *s = '\0';
  }
  s = strtok((char *)iniline, " \t");
  while (s != NULL && argc < 100 - 1) {
    argv[argc++] = s;
    s = strtok(NULL, " \t");
  }
  if (argc == 100) {
    fprintf(stderr, "parse_interface_prefs: too many arguments (max %d)", 100);
    free(iniline);
    return -1;
  }
  argv[argc] = NULL;
  return select_interface(argc, argv, ifname, ip, ifindex);
}


x86 assembly (clang, -O0):
<parse_interface_prefs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x354(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x368(%rbp)
mov    -0x368(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
mov    %rax,-0x360(%rbp)
cmp    $0x0,%rax
je     11c1 <parse_interface_prefs+0x61>
mov    -0x360(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x368(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x360(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x360(%rbp)
mov    %al,-0x369(%rbp)
je     1201 <parse_interface_prefs+0xa1>
cmpl   $0x63,-0x354(%rbp)
setl   %al
mov    %al,-0x369(%rbp)
mov    -0x369(%rbp),%al
test   $0x1,%al
jne    1214 <parse_interface_prefs+0xb4>
jmp    1252 <parse_interface_prefs+0xf2>
mov    -0x360(%rbp),%rcx
mov    -0x354(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x354(%rbp)
cltq
mov    %rcx,-0x350(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xdbf(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x360(%rbp)
jmp    11db <parse_interface_prefs+0x7b>
cmpl   $0x64,-0x354(%rbp)
jne    1291 <parse_interface_prefs+0x131>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
mov    $0x64,%edx
call   1060 <fprintf@plt>
mov    -0x368(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c5 <parse_interface_prefs+0x165>
movslq -0x354(%rbp),%rax
movq   $0x0,-0x350(%rbp,%rax,8)
mov    -0x354(%rbp),%edi
lea    -0x350(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1050 <select_interface@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_interface_prefs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x328,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1177 <parse_interface_prefs+0x37>
movb   $0x0,(%rax)
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11c2 <parse_interface_prefs+0x82>
xor    %ebp,%ebp
lea    0xe6c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rbp),%rbx
mov    %rax,(%rsp,%rbp,8)
xor    %edi,%edi
mov    %r13,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11c4 <parse_interface_prefs+0x84>
cmp    $0x62,%rbp
mov    %rbx,%rbp
jb     11a0 <parse_interface_prefs+0x60>
jmp    11c4 <parse_interface_prefs+0x84>
xor    %ebx,%ebx
mov    %ebx,%eax
movq   $0x0,(%rsp,%rax,8)
mov    %rsp,%rsi
mov    %ebx,%edi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <select_interface@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"parse_interface_prefs: too many arguments (max %d)\00"
define i32 @parse_interface_prefs(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca [100 x i8*]
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i32 0, i32* %11
%14 = load i8*, i8** %6
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %13
%16 = load i8*, i8** %13
%17 = call i8* @strchr(i8* %16, i8 signext 35)
store i8* %17, i8** %12
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i8*, i8** %12
store i8 0, i8* %20
br label %21
21: ; preds = %19, %4
%22 = load i8*, i8** %13
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %12
br label %24
24: ; preds = %32, %21
%25 = load i8*, i8** %12
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %11
%29 = icmp slt i32 %28, 99
br label %30
30: ; preds = %27, %24
%31 = phi i1 [ false, %24 ], [ %29, %27 ]
br i1 %31, label %32, label %39
32: ; preds = %30
%33 = load i8*, i8** %12
%34 = load i32, i32* %11
%35 = add nsw i32 %34, 1
store i32 %35, i32* %11
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [100 x i8*], [100 x i8*]* %10, i64 0, i64 %36
store i8* %33, i8** %37
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %38, i8** %12
br label %24
39: ; preds = %30
%40 = load i32, i32* %11
%41 = icmp eq i32 %40, 100
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 100)
%45 = load i8*, i8** %13
%46 = call i32 @free(i8* %45)
store i32 -1, i32* %5
br label %57
47: ; preds = %39
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [100 x i8*], [100 x i8*]* %10, i64 0, i64 %49
store i8* null, i8** %50
%51 = load i32, i32* %11
%52 = getelementptr inbounds [100 x i8*], [100 x i8*]* %10, i64 0, i64 0
%53 = load i8*, i8** %7
%54 = load i8*, i8** %8
%55 = load i32*, i32** %9
%56 = call i32 @select_interface(i32 %51, i8** %52, i8* %53, i8* %54, i32* %55)
store i32 %56, i32* %5
br label %57
57: ; preds = %47, %42
%58 = load i32, i32* %5
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
@stderr = global i32 0
define i32 @parse_interface_prefs(i8* nocapture %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca [100 x i8*]
%6 = bitcast [100 x i8*]* %5 to i8*
%7 = tail call i8* @strdup(i8* %0)
%8 = tail call i8* @strchr(i8* dereferenceable(1) %7, i8 signext 35)
%9 = icmp eq i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %4
store i8 0, i8* %8
br label %11
11: ; preds = %10, %4
%12 = tail call i8* @strtok(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %25, label %14
14: ; preds = %11, %14
%15 = phi i64 [ %17, %14 ], [ 0, %11 ]
%16 = phi i8* [ %19, %14 ], [ %12, %11 ]
%17 = add nuw nsw i64 %15, 1
%18 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 %15
store i8* %16, i8** %18
%19 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i8* %19, null
%21 = icmp ult i64 %15, 98
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %14, label %23
23: ; preds = %14
%24 = trunc i64 %17 to i32
br label %25
25: ; preds = %23, %11
%26 = phi i32 [ 0, %11 ], [ %24, %23 ]
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 %27
store i8* null, i8** %28
%29 = getelementptr inbounds [100 x i8*], [100 x i8*]* %5, i64 0, i64 0
%30 = call i32 @select_interface(i32 %26, i8** %29, i8* %1, i8* %2, i32* %3)
ret i32 %30
}