#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 */
typedef int /*<<< orphan*/ invalid;

/* Variables and functions */
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int /*<<< orphan*/);
int valid_layout_or_variant(char *sym) {
  size_t i;
  static const char *invalid[] = {"evdev", "inet", "pc", "base"};
  for (i = 0; i < (sizeof(invalid) / sizeof *(invalid)); i++) {
    if (!strncmp(sym, invalid[i], strlen(invalid[i]))) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_layout_or_variant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x4,-0x18(%rbp)
jae    11a8 <valid_layout_or_variant+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rcx
lea    0x2eee(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
lea    0x2edb(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1192 <valid_layout_or_variant+0x72>
movl   $0x0,-0x4(%rbp)
jmp    11af <valid_layout_or_variant+0x8f>
jmp    1197 <valid_layout_or_variant+0x77>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1134 <valid_layout_or_variant+0x14>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_layout_or_variant>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xed2(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11ad <valid_layout_or_variant+0x8d>
lea    0xeb6(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ad <valid_layout_or_variant+0x8d>
lea    0xe9b(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ad <valid_layout_or_variant+0x8d>
lea    0xe7e(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@valid_layout_or_variant.invalid = internal global [4 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@.str = [6 x i8] c"evdev\00"
@.str.1 = [5 x i8] c"inet\00"
@.str.2 = [3 x i8] c"pc\00"
@.str.3 = [5 x i8] c"base\00"
define i32 @valid_layout_or_variant(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %4
br label %5
5: ; preds = %21, %1
%6 = load i64, i64* %4
%7 = icmp ult i64 %6, 4
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i64, i64* %4
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* @valid_layout_or_variant.invalid, i64 0, i64 %10
%12 = load i8*, i8** %11
%13 = load i64, i64* %4
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* @valid_layout_or_variant.invalid, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @strncmp(i8* %9, i8* %12, i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %8
store i32 0, i32* %2
br label %25
20: ; preds = %8
br label %21
21: ; preds = %20
%22 = load i64, i64* %4
%23 = add i64 %22, 1
store i64 %23, i64* %4
br label %5
24: ; preds = %5
store i32 1, i32* %2
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [6 x i8] c"evdev\00"
@.str.1 = [5 x i8] c"inet\00"
@.str.2 = [3 x i8] c"pc\00"
@.str.3 = [5 x i8] c"base\00"
define i32 @valid_layout_or_variant(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %1
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %5
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %9
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %13, %9, %5, %1
%19 = phi i32 [ 0, %1 ], [ 0, %5 ], [ 0, %9 ], [ %17, %13 ]
ret i32 %19
}