#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 */
char *basename(char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int check_cmd(int argc, char **argv, char *cmd) {
  char *pcmd = cmd;
  if (((strncmp(basename(argv[0]), "file_utils", strlen("file_utils")) == 0) &&
       argc > 1 && (strncmp(argv[1], pcmd, strlen(pcmd)) == 0)) ||
      (strncmp(basename(argv[0]), pcmd, strlen(pcmd)) == 0)) {
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<check_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x28(%rbp)
lea    0xe9e(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe8c(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c3 <check_cmd+0x93>
cmpl   $0x1,-0x8(%rbp)
jle    11c3 <check_cmd+0x93>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11fd <check_cmd+0xcd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1209 <check_cmd+0xd9>
movl   $0x0,-0x4(%rbp)
jmp    1210 <check_cmd+0xe0>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_cmd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
mov    (%rsi),%rdi
call   1050 <basename@plt>
mov    %rax,%rbp
lea    0xead(%rip),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x2,%r15d
jl     1191 <check_cmd+0x61>
test   %rax,%rax
jne    1191 <check_cmd+0x61>
mov    0x8(%rbx),%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11bf <check_cmd+0x8f>
mov    (%rbx),%rdi
call   1050 <basename@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
neg    %rax
sbb    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    11b6 <check_cmd+0x86>

LLVM IR (-O0):
@.str = [11 x i8] c"file_utils\00"
define i32 @check_cmd(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %7
store i8* %9, i8** %8
%10 = load i8**, i8*** %6
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i8* @basename(i8* %12)
%14 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%15 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %3
%18 = load i32, i32* %5
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8*, i8** %8
%25 = load i8*, i8** %8
%26 = call i32 @strlen(i8* %25)
%27 = call i64 @strncmp(i8* %23, i8* %24, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %20, %17, %3
%30 = load i8**, i8*** %6
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i8* @basename(i8* %32)
%34 = load i8*, i8** %8
%35 = load i8*, i8** %8
%36 = call i32 @strlen(i8* %35)
%37 = call i64 @strncmp(i8* %33, i8* %34, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %29, %20
store i32 0, i32* %4
br label %41
40: ; preds = %29
store i32 -1, i32* %4
br label %41
41: ; preds = %40, %39
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@.str = [11 x i8] c"file_utils\00"
define i32 @check_cmd(i32 %0, i8** nocapture %1, i8* %2) {
%4 = load i8*, i8** %1
%5 = tail call i8* @basename(i8* %4)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i64 %7, 0
%9 = icmp sgt i32 %0, 1
%10 = and i1 %9, %8
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strlen(i8* %2)
%15 = tail call i64 @strncmp(i8* %13, i8* %2, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %11, %3
%18 = load i8*, i8** %1
%19 = tail call i8* @basename(i8* %18)
%20 = tail call i32 @strlen(i8* %2)
%21 = tail call i64 @strncmp(i8* %19, i8* %2, i32 %20)
%22 = icmp ne i64 %21, 0
%23 = sext i1 %22 to i32
br label %24
24: ; preds = %17, %11
%25 = phi i32 [ 0, %11 ], [ %23, %17 ]
ret i32 %25
}