#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__ strcmpl(char *, char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmpl(char *, char *, int /*<<< orphan*/);
int strdictl(char *str, char *dict[]) {
  int i, match;
  match = -1;
  for (i = 0; dict[i]; i++) {
    if (strncmpl(str, dict[i], strlen(str)) == 0) {
      if (strcmpl(str, dict[i]) == 0) {
        match = i;
        break;
      } else if (match == -1) {
        match = i;
      } else {
        match = -2;
        break;
      }
    }
  }
  return (match);
}


x86 assembly (clang, -O0):
<strdictl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1203 <strdictl+0xd3>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmpl@plt>
cmp    $0x0,%rax
jne    11f0 <strdictl+0xc0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcmpl@plt>
cmp    $0x0,%rax
jne    11c5 <strdictl+0x95>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1203 <strdictl+0xd3>
cmpl   $0xffffffff,-0x18(%rbp)
jne    11da <strdictl+0xaa>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <strdictl+0xb6>
movl   $0xfffffffe,-0x18(%rbp)
jmp    1203 <strdictl+0xd3>
jmp    11eb <strdictl+0xbb>
jmp    11f0 <strdictl+0xc0>
jmp    11f5 <strdictl+0xc5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <strdictl+0x1e>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strdictl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%rbp
test   %rbp,%rbp
je     1194 <strdictl+0x64>
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0xffffffff,%r15d
xor    %ebx,%ebx
jmp    115e <strdictl+0x2e>
mov    0x8(%r14,%rbx,8),%rbp
add    $0x1,%rbx
test   %rbp,%rbp
je     11a7 <strdictl+0x77>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncmpl@plt>
test   %rax,%rax
jne    1150 <strdictl+0x20>
mov    (%r14,%rbx,8),%rsi
mov    %r12,%rdi
call   1050 <strcmpl@plt>
test   %rax,%rax
je     119c <strdictl+0x6c>
cmp    $0xffffffff,%r15d
jne    11a1 <strdictl+0x71>
mov    %ebx,%r15d
jmp    1150 <strdictl+0x20>
mov    $0xffffffff,%r15d
jmp    11a7 <strdictl+0x77>
mov    %ebx,%r15d
jmp    11a7 <strdictl+0x77>
mov    $0xfffffffe,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strdictl(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 -1, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %45, %2
%8 = load i8**, i8*** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %48
14: ; preds = %7
%15 = load i8*, i8** %3
%16 = load i8**, i8*** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %3
%22 = call i32 @strlen(i8* %21)
%23 = call i64 @strncmpl(i8* %15, i8* %20, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %44
25: ; preds = %14
%26 = load i8*, i8** %3
%27 = load i8**, i8*** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i64 @strcmpl(i8* %26, i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %25
%35 = load i32, i32* %5
store i32 %35, i32* %6
br label %48
36: ; preds = %25
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = load i32, i32* %5
store i32 %40, i32* %6
br label %42
41: ; preds = %36
store i32 -2, i32* %6
br label %48
42: ; preds = %39
br label %43
43: ; preds = %42
br label %44
44: ; preds = %43, %14
br label %45
45: ; preds = %44
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %7
48: ; preds = %41, %34, %7
%49 = load i32, i32* %6
ret i32 %49
}

LLVM IR (-O2):
define i32 @strdictl(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %28, label %5
5: ; preds = %2, %20
%6 = phi i64 [ %22, %20 ], [ 0, %2 ]
%7 = phi i8* [ %24, %20 ], [ %3, %2 ]
%8 = phi i8** [ %23, %20 ], [ %1, %2 ]
%9 = phi i32 [ %21, %20 ], [ -1, %2 ]
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i64 @strncmpl(i8* %0, i8* %7, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %5
%14 = load i8*, i8** %8
%15 = tail call i64 @strcmpl(i8* %0, i8* %14)
%16 = icmp eq i64 %15, 0
%17 = trunc i64 %6 to i32
br i1 %16, label %26, label %18
18: ; preds = %13
%19 = icmp eq i32 %9, -1
br i1 %19, label %20, label %28
20: ; preds = %18, %5
%21 = phi i32 [ %9, %5 ], [ %17, %18 ]
%22 = add nuw i64 %6, 1
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %5
26: ; preds = %13
%27 = trunc i64 %6 to i32
br label %28
28: ; preds = %26, %20, %18, %2
%29 = phi i32 [ -1, %2 ], [ %27, %26 ], [ %21, %20 ], [ -2, %18 ]
ret i32 %29
}