#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 */
scalar_t__ isspace(char);
int /*<<< orphan*/ read_token(char **, char *);
char *strstr(char *, char *);
int auto_login_next_token(char **hay, char *store) {
  char *keys[] = {"machine", "default", "login", "password"};
  int keys_len[] = {7, 7, 5, 8};
  char *ptr, *minptr;
  int i, min;
  min = -1;
  minptr = 0;
  for (i = 0; i < 4; i++)
    if ((ptr = strstr(*hay, keys[i])))
      if (!minptr || ptr < minptr) {
        minptr = ptr;
        min = i;
      }
  if (min != -1) {
    *hay = minptr + keys_len[min];
    if (min != 1) {
      if (!isspace(**hay)) {
        *store = 0;
      } else {
        while (isspace(**hay))
          (*hay)++;
        read_token(hay, store);
      }
    }
  }
  return min;
}


x86 assembly (clang, -O0):
<auto_login_next_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2cb9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0xffffffff,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x4,-0x54(%rbp)
jge    1204 <auto_login_next_token+0xd4>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     11f1 <auto_login_next_token+0xc1>
cmpq   $0x0,-0x50(%rbp)
je     11de <auto_login_next_token+0xae>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    11ec <auto_login_next_token+0xbc>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    11f1 <auto_login_next_token+0xc1>
jmp    11f6 <auto_login_next_token+0xc6>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1198 <auto_login_next_token+0x68>
cmpl   $0xffffffff,-0x58(%rbp)
je     129c <auto_login_next_token+0x16c>
mov    -0x50(%rbp),%rcx
movslq -0x58(%rbp),%rax
movslq -0x40(%rbp,%rax,4),%rax
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x1,-0x58(%rbp)
je     1297 <auto_login_next_token+0x167>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    1254 <auto_login_next_token+0x124>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    1292 <auto_login_next_token+0x162>
jmp    1259 <auto_login_next_token+0x129>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1285 <auto_login_next_token+0x155>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1259 <auto_login_next_token+0x129>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <read_token@plt>
jmp    1297 <auto_login_next_token+0x167>
jmp    129c <auto_login_next_token+0x16c>
mov    -0x58(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auto_login_next_token>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%r12
lea    0xeb8(%rip),%rsi
mov    %r12,%rdi
call   1050 <strstr@plt>
mov    %rax,%r15
cmp    $0x1,%rax
sbb    %ebp,%ebp
lea    0xea8(%rip),%rsi
mov    %r12,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1187 <auto_login_next_token+0x57>
test   %r15,%r15
sete   %cl
cmp    %r15,%rax
setb   %dl
or     %cl,%dl
cmovne %rax,%r15
mov    $0x1,%eax
cmovne %eax,%ebp
lea    0xe82(%rip),%rsi
mov    %r12,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     11b5 <auto_login_next_token+0x85>
test   %r15,%r15
sete   %cl
cmp    %r15,%rax
setb   %dl
or     %cl,%dl
cmovne %rax,%r15
mov    $0x2,%eax
cmovne %eax,%ebp
lea    0xe5a(%rip),%rsi
mov    %r12,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     11d3 <auto_login_next_token+0xa3>
test   %r15,%r15
je     11fa <auto_login_next_token+0xca>
cmp    %r15,%rax
jb     11fa <auto_login_next_token+0xca>
cmp    $0xffffffff,%ebp
je     1247 <auto_login_next_token+0x117>
mov    %ebp,%eax
lea    0xe3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rax,%r15
mov    %r15,(%rbx)
mov    $0x1,%ecx
mov    %r15,%rax
cmp    $0x1,%ebp
jne    1206 <auto_login_next_token+0xd6>
jmp    1254 <auto_login_next_token+0x124>
add    $0x8,%rax
mov    %rax,(%rbx)
mov    $0x3,%ebp
movsbl (%rax),%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     124e <auto_login_next_token+0x11e>
mov    (%rbx),%rax
movsbl (%rax),%edi
nopl   0x0(%rax)
call   1030 <isspace@plt>
test   %rax,%rax
je     123a <auto_login_next_token+0x10a>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movsbl 0x1(%rax),%edi
jmp    1220 <auto_login_next_token+0xf0>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <read_token@plt>
jmp    1252 <auto_login_next_token+0x122>
mov    $0xffffffff,%ecx
jmp    1254 <auto_login_next_token+0x124>
movb   $0x0,(%r14)
mov    %ebp,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"machine\00"
@.str.1 = [8 x i8] c"default\00"
@.str.2 = [6 x i8] c"login\00"
@.str.3 = [9 x i8] c"password\00"
@__const.auto_login_next_token.keys = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0)]
@__const.auto_login_next_token.keys_len = [4 x i32] [i32 7, i32 7, i32 5, i32 8]
define i32 @auto_login_next_token(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca [4 x i8*]
%6 = alloca [4 x i32]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
%11 = bitcast [4 x i8*]* %5 to i8*
%12 = bitcast [4 x i32]* %6 to i8*
store i32 -1, i32* %10
store i8* null, i8** %8
store i32 0, i32* %9
br label %13
13: ; preds = %37, %2
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %40
16: ; preds = %13
%17 = load i8**, i8*** %3
%18 = load i8*, i8** %17
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i8* @strstr(i8* %18, i8* %22)
store i8* %23, i8** %7
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %36
25: ; preds = %16
%26 = load i8*, i8** %8
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i8*, i8** %7
%30 = load i8*, i8** %8
%31 = icmp ult i8* %29, %30
br i1 %31, label %32, label %35
32: ; preds = %28, %25
%33 = load i8*, i8** %7
store i8* %33, i8** %8
%34 = load i32, i32* %9
store i32 %34, i32* %10
br label %35
35: ; preds = %32, %28
br label %36
36: ; preds = %35, %16
br label %37
37: ; preds = %36
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %13
40: ; preds = %13
%41 = load i32, i32* %10
%42 = icmp ne i32 %41, -1
br i1 %42, label %43, label %79
43: ; preds = %40
%44 = load i8*, i8** %8
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %44, i64 %49
%51 = load i8**, i8*** %3
store i8* %50, i8** %51
%52 = load i32, i32* %10
%53 = icmp ne i32 %52, 1
br i1 %53, label %54, label %78
54: ; preds = %43
%55 = load i8**, i8*** %3
%56 = load i8*, i8** %55
%57 = load i8, i8* %56
%58 = call i64 @isspace(i8 signext %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %54
%61 = load i8*, i8** %4
store i8 0, i8* %61
br label %77
62: ; preds = %54
br label %63
63: ; preds = %69, %62
%64 = load i8**, i8*** %3
%65 = load i8*, i8** %64
%66 = load i8, i8* %65
%67 = call i64 @isspace(i8 signext %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %63
%70 = load i8**, i8*** %3
%71 = load i8*, i8** %70
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %70
br label %63
73: ; preds = %63
%74 = load i8**, i8*** %3
%75 = load i8*, i8** %4
%76 = call i32 @read_token(i8** %74, i8* %75)
br label %77
77: ; preds = %73, %60
br label %78
78: ; preds = %77, %43
br label %79
79: ; preds = %78, %40
%80 = load i32, i32* %10
ret i32 %80
}

LLVM IR (-O2):
@.str = [8 x i8] c"machine\00"
@.str.1 = [8 x i8] c"default\00"
@.str.2 = [6 x i8] c"login\00"
@.str.3 = [9 x i8] c"password\00"
@__const.auto_login_next_token.keys_len = [4 x i32] [i32 7, i32 7, i32 5, i32 8]
define i32 @auto_login_next_token(i8** %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = tail call i8* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
%6 = sext i1 %5 to i32
%7 = tail call i8* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = icmp eq i8* %4, null
%11 = icmp ult i8* %7, %4
%12 = select i1 %10, i1 true, i1 %11
%13 = select i1 %12, i8* %7, i8* %4
%14 = select i1 %12, i32 1, i32 %6
br label %15
15: ; preds = %9, %2
%16 = phi i8* [ %4, %2 ], [ %13, %9 ]
%17 = phi i32 [ %6, %2 ], [ %14, %9 ]
%18 = tail call i8* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %26, label %20
20: ; preds = %15
%21 = icmp eq i8* %16, null
%22 = icmp ult i8* %18, %16
%23 = select i1 %21, i1 true, i1 %22
%24 = select i1 %23, i8* %18, i8* %16
%25 = select i1 %23, i32 2, i32 %17
br label %26
26: ; preds = %20, %15
%27 = phi i8* [ %16, %15 ], [ %24, %20 ]
%28 = phi i32 [ %17, %15 ], [ %25, %20 ]
%29 = tail call i8* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %37, label %31
31: ; preds = %26
%32 = icmp eq i8* %27, null
%33 = icmp ult i8* %29, %27
%34 = select i1 %32, i1 true, i1 %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = getelementptr inbounds i8, i8* %29, i64 8
store i8* %36, i8** %0
br label %46
37: ; preds = %31, %26
%38 = icmp eq i32 %28, -1
br i1 %38, label %66, label %39
39: ; preds = %37
%40 = zext i32 %28 to i64
%41 = getelementptr inbounds [4 x i32], [4 x i32]* @__const.auto_login_next_token.keys_len, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %27, i64 %43
store i8* %44, i8** %0
%45 = icmp eq i32 %28, 1
br i1 %45, label %66, label %46
46: ; preds = %35, %39
%47 = phi i8* [ %36, %35 ], [ %44, %39 ]
%48 = phi i32 [ 3, %35 ], [ %28, %39 ]
%49 = load i8, i8* %47
%50 = tail call i64 @isspace(i8 signext %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %46
%53 = load i8*, i8** %0
%54 = load i8, i8* %53
%55 = tail call i64 @isspace(i8 signext %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %64, label %58
57: ; preds = %46
store i8 0, i8* %1
br label %66
58: ; preds = %52, %58
%59 = load i8*, i8** %0
%60 = getelementptr inbounds i8, i8* %59, i64 1
store i8* %60, i8** %0
%61 = load i8, i8* %60
%62 = tail call i64 @isspace(i8 signext %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %58
64: ; preds = %58, %52
%65 = tail call i32 @read_token(i8** %0, i8* %1)
br label %66
66: ; preds = %39, %64, %57, %37
%67 = phi i32 [ 1, %39 ], [ %48, %64 ], [ %48, %57 ], [ -1, %37 ]
ret i32 %67
}