#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, char const *);
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char const *, size_t);
bool command_match(const char *s, const char *name, size_t min) {
  size_t len = strlen(s);
  if (strncmp(s, name, len) == 0) {
    if (len < min) {
      errx(EXIT_FAILURE, "ambiguous command '%s'", s);
    }
    return (true);
  }
  return (false);
}


x86 assembly (clang, -O0):
<command_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119f <command_match+0x6f>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1193 <command_match+0x63>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe72(%rip),%rsi
call   1050 <errx@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a6 <command_match+0x76>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_match>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    1181 <command_match+0x51>
mov    $0x1,%r15d
cmp    %r14,%rbp
jae    1181 <command_match+0x51>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    %rbx,%rdx
call   1050 <errx@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [23 x i8] c"ambiguous command '%s'\00"
define i32 @command_match(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %8
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i64, i64* %8
%14 = call i64 @strncmp(i8* %11, i8* %12, i64 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %3
%17 = load i64, i64* %8
%18 = load i64, i64* %7
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @EXIT_FAILURE
%22 = load i8*, i8** %5
%23 = call i32 @errx(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %20, %16
store i32 1, i32* %4
br label %26
25: ; preds = %3
store i32 0, i32* %4
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [23 x i8] c"ambiguous command '%s'\00"
define i32 @command_match(i8* %0, i8* %1, i64 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = tail call i64 @strncmp(i8* %0, i8* %1, i64 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = icmp ult i64 %4, %2
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @errx(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %3, %7, %9
%13 = phi i32 [ 1, %9 ], [ 1, %7 ], [ 0, %3 ]
ret i32 %13
}