#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 */
struct dtree_dev_t {
  int dummy;
};

/* Variables and functions */
char **dtree_dev_compat(struct dtree_dev_t const *);
int /*<<< orphan*/ strcmp(char const *, char const *);
int is_compatible(const struct dtree_dev_t *dev, const char *compat) {
  const char **dev_compat = dtree_dev_compat(dev);
  for (int i = 0; dev_compat[i] != NULL; ++i) {
    if (!strcmp(dev_compat[i], compat))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_compatible>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <dtree_dev_compat@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1194 <is_compatible+0x74>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1181 <is_compatible+0x61>
movl   $0x1,-0x4(%rbp)
jmp    119b <is_compatible+0x7b>
jmp    1186 <is_compatible+0x66>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <is_compatible+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_compatible>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1030 <dtree_dev_compat@plt>
mov    (%rax),%rdi
test   %rdi,%rdi
je     1161 <is_compatible+0x41>
mov    %rax,%rbx
add    $0x8,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1158 <is_compatible+0x38>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <is_compatible+0x20>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
jmp    1163 <is_compatible+0x43>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dtree_dev_t = type { i32 }
define i32 @is_compatible(%struct.dtree_dev_t* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.dtree_dev_t*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
store %struct.dtree_dev_t* %0, %struct.dtree_dev_t** %4
store i8* %1, i8** %5
%8 = load %struct.dtree_dev_t*, %struct.dtree_dev_t** %4
%9 = call i8** @dtree_dev_compat(%struct.dtree_dev_t* %8)
store i8** %9, i8*** %6
store i32 0, i32* %7
br label %10
10: ; preds = %28, %2
%11 = load i8**, i8*** %6
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %31
17: ; preds = %10
%18 = load i8**, i8*** %6
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = load i8*, i8** %5
%24 = call i32 @strcmp(i8* %22, i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %17
store i32 1, i32* %3
br label %32
27: ; preds = %17
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %10
31: ; preds = %10
store i32 0, i32* %3
br label %32
32: ; preds = %31, %26
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
%struct.dtree_dev_t = type { i32 }
define i32 @is_compatible(%struct.dtree_dev_t* %0, i8* nocapture %1) {
%3 = tail call i8** @dtree_dev_compat(%struct.dtree_dev_t* %0)
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %10
6: ; preds = %10
%7 = getelementptr inbounds i8*, i8** %3, i64 %15
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %16, label %10
10: ; preds = %2, %6
%11 = phi i64 [ %15, %6 ], [ 0, %2 ]
%12 = phi i8* [ %8, %6 ], [ %4, %2 ]
%13 = tail call i32 @strcmp(i8* %12, i8* dereferenceable(1) %1)
%14 = icmp eq i32 %13, 0
%15 = add nuw i64 %11, 1
br i1 %14, label %16, label %6
16: ; preds = %10, %6
%17 = zext i1 %14 to i32
br label %18
18: ; preds = %16, %2
%19 = phi i32 [ 0, %2 ], [ %17, %16 ]
ret i32 %19
}