#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 udev {
  int dummy;
};

/* Variables and functions */
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ udev_log_null(struct udev *, char *, char const *, char *);
int matches_device_list(struct udev *udev, char **devices, const char *name) {
  int i;
  for (i = 0; devices[i] != NULL; i++) {
    udev_log_null(udev, "compare '%s' == '%s'\n", name, devices[i]);
    if (strcmp(devices[i], name) == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<matches_device_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ac <matches_device_list+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe97(%rip),%rsi
call   1030 <udev_log_null@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1199 <matches_device_list+0x79>
movl   $0x1,-0x4(%rbp)
jmp    11b3 <matches_device_list+0x93>
jmp    119e <matches_device_list+0x7e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113b <matches_device_list+0x1b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matches_device_list>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%rcx
xor    %r14d,%r14d
test   %rcx,%rcx
je     1184 <matches_device_list+0x64>
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r15
add    $0x8,%rbp
lea    0xeb9(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <udev_log_null@plt>
mov    -0x8(%rbp),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117e <matches_device_list+0x5e>
mov    0x0(%rbp),%rcx
add    $0x8,%rbp
test   %rcx,%rcx
jne    1150 <matches_device_list+0x30>
jmp    1184 <matches_device_list+0x64>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.udev = type { i32 }
@.str = [22 x i8] c"compare '%s' == '%s'\0A\00"
define i32 @matches_device_list(%struct.udev* %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.udev*
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
store %struct.udev* %0, %struct.udev** %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i32 0, i32* %8
br label %9
9: ; preds = %35, %3
%10 = load i8**, i8*** %6
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %10, i64 %12
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %38
16: ; preds = %9
%17 = load %struct.udev*, %struct.udev** %5
%18 = load i8*, i8** %7
%19 = load i8**, i8*** %6
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @udev_log_null(%struct.udev* %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %23)
%25 = load i8**, i8*** %6
%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 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %16
store i32 1, i32* %4
br label %39
34: ; preds = %16
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %9
38: ; preds = %9
store i32 0, i32* %4
br label %39
39: ; preds = %38, %33
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
%struct.udev = type { i32 }
@.str = [22 x i8] c"compare '%s' == '%s'\0A\00"
define i32 @matches_device_list(%struct.udev* %0, i8** nocapture %1, i8* %2) {
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %10
6: ; preds = %10
%7 = getelementptr inbounds i8*, i8** %1, i64 %18
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %19, label %10
10: ; preds = %3, %6
%11 = phi i64 [ %18, %6 ], [ 0, %3 ]
%12 = phi i8* [ %8, %6 ], [ %4, %3 ]
%13 = phi i8** [ %7, %6 ], [ %1, %3 ]
%14 = tail call i32 @udev_log_null(%struct.udev* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %12)
%15 = load i8*, i8** %13
%16 = tail call i64 @strcmp(i8* %15, i8* %2)
%17 = icmp eq i64 %16, 0
%18 = add nuw i64 %11, 1
br i1 %17, label %19, label %6
19: ; preds = %10, %6, %3
%20 = phi i32 [ 0, %3 ], [ 0, %6 ], [ 1, %10 ]
ret i32 %20
}