#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__ isdigit(char);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int devname_matches(char *name, char *match) {
  if (strncmp(name, "/dev/md/", 8) == 0)
    name += 8;
  else if (strncmp(name, "/dev/", 5) == 0)
    name += 5;
  if (strncmp(match, "/dev/md/", 8) == 0)
    match += 8;
  else if (strncmp(match, "/dev/", 5) == 0)
    match += 5;
  if (strncmp(name, "md", 2) == 0 && isdigit(name[2]))
    name += 2;
  if (strncmp(match, "md", 2) == 0 && isdigit(match[2]))
    match += 2;
  return (strcmp(name, match) == 0);
}


x86 assembly (clang, -O0):
<devname_matches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1170 <devname_matches+0x40>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <devname_matches+0x70>
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119b <devname_matches+0x6b>
mov    -0x8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <devname_matches+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d0 <devname_matches+0xa0>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1200 <devname_matches+0xd0>
mov    -0x10(%rbp),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11fb <devname_matches+0xcb>
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x10(%rbp)
jmp    1200 <devname_matches+0xd0>
mov    -0x8(%rbp),%rdi
lea    0xe04(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1242 <devname_matches+0x112>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1242 <devname_matches+0x112>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdc2(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1284 <devname_matches+0x154>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1284 <devname_matches+0x154>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<devname_matches>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebe(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
mov    $0x8,%r15d
mov    $0x8,%ecx
test   %rax,%rax
je     117c <devname_matches+0x4c>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,4),%rcx
add    %rcx,%rbx
lea    0xe7a(%rip),%rsi
mov    %r14,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b8 <devname_matches+0x88>
lea    0xe6a(%rip),%rsi
mov    %r14,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,4),%r15
add    %r15,%r14
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11e8 <devname_matches+0xb8>
lea    0x2(%rbx),%r15
movsbl 0x2(%rbx),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
cmovne %r15,%rbx
lea    0xe20(%rip),%rsi
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1216 <devname_matches+0xe6>
lea    0x2(%r14),%r15
movsbl 0x2(%r14),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
cmovne %r15,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/md/\00"
@.str.1 = [6 x i8] c"/dev/\00"
@.str.2 = [3 x i8] c"md\00"
define i32 @devname_matches(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 8
store i8* %10, i8** %3
br label %19
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 5
store i8* %17, i8** %3
br label %18
18: ; preds = %15, %11
br label %19
19: ; preds = %18, %8
%20 = load i8*, i8** %4
%21 = call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 8
store i8* %25, i8** %4
br label %34
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 5
store i8* %32, i8** %4
br label %33
33: ; preds = %30, %26
br label %34
34: ; preds = %33, %23
%35 = load i8*, i8** %3
%36 = call i64 @strncmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = call i64 @isdigit(i8 signext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %38
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 2
store i8* %46, i8** %3
br label %47
47: ; preds = %44, %38, %34
%48 = load i8*, i8** %4
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %47
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 2
%54 = load i8, i8* %53
%55 = call i64 @isdigit(i8 signext %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 2
store i8* %59, i8** %4
br label %60
60: ; preds = %57, %51, %47
%61 = load i8*, i8** %3
%62 = load i8*, i8** %4
%63 = call i64 @strcmp(i8* %61, i8* %62)
%64 = icmp eq i64 %63, 0
%65 = zext i1 %64 to i32
ret i32 %65
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/md/\00"
@.str.1 = [6 x i8] c"/dev/\00"
@.str.2 = [3 x i8] c"md\00"
define i32 @devname_matches(i8* %0, i8* %1) {
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i64 5, i64 0
br label %9
9: ; preds = %2, %5
%10 = phi i64 [ %8, %5 ], [ 8, %2 ]
%11 = getelementptr i8, i8* %0, i64 %10
%12 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i64 5, i64 0
br label %18
18: ; preds = %9, %14
%19 = phi i64 [ %17, %14 ], [ 8, %9 ]
%20 = getelementptr i8, i8* %1, i64 %19
%21 = tail call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = getelementptr inbounds i8, i8* %11, i64 2
%25 = load i8, i8* %24
%26 = tail call i64 @isdigit(i8 signext %25)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* %11, i8* %24
br label %29
29: ; preds = %23, %18
%30 = phi i8* [ %11, %18 ], [ %28, %23 ]
%31 = tail call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = getelementptr inbounds i8, i8* %20, i64 2
%35 = load i8, i8* %34
%36 = tail call i64 @isdigit(i8 signext %35)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, i8* %20, i8* %34
br label %39
39: ; preds = %33, %29
%40 = phi i8* [ %20, %29 ], [ %38, %33 ]
%41 = tail call i64 @strcmp(i8* %30, i8* %40)
%42 = icmp eq i64 %41, 0
%43 = zext i1 %42 to i32
ret i32 %43
}