#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 strcmp(char const *, char const *);
scalar_t__ strlen(char const *);
int checkCmd(const char *proc, const char *cmd) {
  int len = (int)strlen(cmd), ch;
  if (len > 1)
    for (ch = len - 2; ch >= 0; --ch)
      if ('/' == cmd[ch])
        return strcmp(proc, &cmd[ch + 1]);
  return strcmp(proc, cmd);
}


x86 assembly (clang, -O0):
<checkCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jle    11aa <checkCmd+0x8a>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     11a5 <checkCmd+0x85>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x2f,%eax
cmp    %ecx,%eax
jne    1192 <checkCmd+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x4(%rbp)
jmp    11ba <checkCmd+0x9a>
jmp    1197 <checkCmd+0x77>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    114f <checkCmd+0x2f>
jmp    11aa <checkCmd+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkCmd>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1158 <checkCmd+0x38>
lea    -0x2(%rax),%ecx
add    $0xffffffff,%eax
nopl   (%rax)
mov    %ecx,%edx
cmpb   $0x2f,(%rbx,%rdx,1)
je     1155 <checkCmd+0x35>
add    $0xffffffff,%ecx
add    $0xffffffffffffffff,%rax
test   %eax,%eax
jg     1140 <checkCmd+0x20>
jmp    1158 <checkCmd+0x38>
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcmp@plt>

LLVM IR (-O0):
define i32 @checkCmd(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %40
13: ; preds = %2
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 2
store i32 %15, i32* %7
br label %16
16: ; preds = %36, %13
%17 = load i32, i32* %7
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %39
19: ; preds = %16
%20 = load i8*, i8** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 47, %25
br i1 %26, label %27, label %35
27: ; preds = %19
%28 = load i8*, i8** %4
%29 = load i8*, i8** %5
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = call i32 @strcmp(i8* %28, i8* %33)
store i32 %34, i32* %3
br label %44
35: ; preds = %19
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, -1
store i32 %38, i32* %7
br label %16
39: ; preds = %16
br label %40
40: ; preds = %39, %2
%41 = load i8*, i8** %4
%42 = load i8*, i8** %5
%43 = call i32 @strcmp(i8* %41, i8* %42)
store i32 %43, i32* %3
br label %44
44: ; preds = %40, %27
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @checkCmd(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %21
6: ; preds = %2
%7 = add nsw i32 %4, -2
br label %8
8: ; preds = %6, %18
%9 = phi i32 [ %19, %18 ], [ %7, %6 ]
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = add nuw nsw i32 %9, 1
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
br label %21
18: ; preds = %8
%19 = add nsw i32 %9, -1
%20 = icmp sgt i32 %9, 0
br i1 %20, label %8, label %21
21: ; preds = %18, %2, %14
%22 = phi i8* [ %17, %14 ], [ %1, %2 ], [ %1, %18 ]
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %22)
ret i32 %23
}