#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 */
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, size_t);
int lookfor_iface(char **ifaces, int n_ifaces, char *iface) {
  int i;
  for (i = 0; i < n_ifaces; i++) {
    if (strncmp(iface, ifaces[i], strlen(iface)) == 0) {
      if (ifaces[i][strlen(iface)] == '=') {
        return i;
      }
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<lookfor_iface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d1 <lookfor_iface+0xb1>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11be <lookfor_iface+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    11b9 <lookfor_iface+0x99>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d8 <lookfor_iface+0xb8>
jmp    11be <lookfor_iface+0x9e>
jmp    11c3 <lookfor_iface+0xa3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <lookfor_iface+0x1a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookfor_iface>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %esi,%esi
jle    118e <lookfor_iface+0x6e>
mov    %rdx,%r12
mov    %rdi,%r15
mov    %esi,%r13d
xor    %ebx,%ebx
jmp    1159 <lookfor_iface+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     118e <lookfor_iface+0x6e>
mov    (%r15,%rbx,8),%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1150 <lookfor_iface+0x30>
mov    (%r15,%rbx,8),%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
cmpb   $0x3d,0x0(%rbp,%rax,1)
jne    1150 <lookfor_iface+0x30>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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