#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*/ Bool;

/* Variables and functions */
int /*<<< orphan*/ False;
int /*<<< orphan*/ True;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
Bool optionmatch(char *opt, char *arg, int minlen) {
  int arglen;
  if (strcmp(opt, arg) == 0) {
    return (True);
  }
  if ((arglen = strlen(arg)) >= (int)strlen(opt) || arglen < minlen) {
    return (False);
  }
  if (strncmp(opt, arg, arglen) == 0) {
    return (True);
  }
  return (False);
}


x86 assembly (clang, -O0):
<optionmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    116b <optionmatch+0x3b>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e4 <optionmatch+0xb4>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    119c <optionmatch+0x6c>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ad <optionmatch+0x7d>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e4 <optionmatch+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d8 <optionmatch+0xa8>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e4 <optionmatch+0xb4>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optionmatch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strcmp@plt>
test   %rax,%rax
je     117e <optionmatch+0x4e>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2e85(%rip),%rcx
cmp    %r15d,%ebp
jl     118e <optionmatch+0x5e>
cmp    %eax,%ebp
jge    118e <optionmatch+0x5e>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1187 <optionmatch+0x57>
mov    0x2e5b(%rip),%rcx
jmp    118e <optionmatch+0x5e>
mov    0x2e5a(%rip),%rcx
mov    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@True = global i32 0
@False = global i32 0
define i32 @optionmatch(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i64 @strcmp(i8* %9, i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = load i32, i32* @True
store i32 %14, i32* %4
br label %37
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %8
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = icmp sge i32 %17, %19
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = load i32, i32* %8
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21, %15
%26 = load i32, i32* @False
store i32 %26, i32* %4
br label %37
27: ; preds = %21
%28 = load i8*, i8** %5
%29 = load i8*, i8** %6
%30 = load i32, i32* %8
%31 = call i64 @strncmp(i8* %28, i8* %29, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = load i32, i32* @True
store i32 %34, i32* %4
br label %37
35: ; preds = %27
%36 = load i32, i32* @False
store i32 %36, i32* %4
br label %37
37: ; preds = %35, %33, %25, %13
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@True = global i32 0
@False = global i32 0
define i32 @optionmatch(i8* %0, i8* %1, i32 %2) {
%4 = tail call i64 @strcmp(i8* %0, i8* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %1)
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sge i32 %7, %8
%10 = icmp slt i32 %7, %2
%11 = or i1 %10, %9
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %7)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i32* @True, i32* @False
br label %16
16: ; preds = %12, %6, %3
%17 = phi i32* [ @True, %3 ], [ @False, %6 ], [ %15, %12 ]
%18 = load i32, i32* %17
ret i32 %18
}