#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 */
struct cmd_info {
  int dummy;
};

/* Variables and functions */
int _run_command(int, char const **, struct cmd_info const *);
int iotools_fallback(int, char const **);
struct cmd_info *locate_command(char const *);
char *strrchr(char const *, char);
int run_command(int argc, const char *argv[]) {
  const struct cmd_info *cmd_info;
  const char *cmd_name;
  if (argc > 1) {
    cmd_info = locate_command(argv[1]);
    if (cmd_info != NULL) {
      return _run_command(--argc, ++argv, cmd_info);
    }
  }
  cmd_name = strrchr(argv[0], '/');
  cmd_name = (cmd_name == NULL) ? argv[0] : cmd_name + 1;
  cmd_info = locate_command(cmd_name);
  if (cmd_info != NULL) {
    return _run_command(argc, argv, cmd_info);
  }
  return iotools_fallback(argc, argv);
}


x86 assembly (clang, -O0):
<run_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a0 <run_command+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <locate_command@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119b <run_command+0x5b>
mov    -0x8(%rbp),%edi
add    $0xffffffff,%edi
mov    %edi,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    %rsi,-0x10(%rbp)
mov    -0x18(%rbp),%rdx
call   1050 <_run_command@plt>
mov    %eax,-0x4(%rbp)
jmp    1223 <run_command+0xe3>
jmp    11a0 <run_command+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d0 <run_command+0x90>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11dc <run_command+0x9c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <locate_command@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1214 <run_command+0xd4>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <_run_command@plt>
mov    %eax,-0x4(%rbp)
jmp    1223 <run_command+0xe3>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <iotools_fallback@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_command>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x2,%edi
jl     1165 <run_command+0x25>
mov    0x8(%r14),%rdi
call   1060 <locate_command@plt>
test   %rax,%rax
je     1165 <run_command+0x25>
add    $0x8,%r14
add    $0xffffffff,%ebp
jmp    118a <run_command+0x4a>
mov    (%r14),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %rbx,%rdi
call   1060 <locate_command@plt>
test   %rax,%rax
je     119b <run_command+0x5b>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rax,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <_run_command@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <iotools_fallback@plt>

LLVM IR (-O0):
%struct.cmd_info = type { i32 }
define i32 @run_command(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.cmd_info*
%7 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call %struct.cmd_info* @locate_command(i8* %13)
store %struct.cmd_info* %14, %struct.cmd_info** %6
%15 = load %struct.cmd_info*, %struct.cmd_info** %6
%16 = icmp ne %struct.cmd_info* %15, null
br i1 %16, label %17, label %24
17: ; preds = %10
%18 = load i32, i32* %4
%19 = add nsw i32 %18, -1
store i32 %19, i32* %4
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %5
%22 = load %struct.cmd_info*, %struct.cmd_info** %6
%23 = call i32 @_run_command(i32 %19, i8** %21, %struct.cmd_info* %22)
store i32 %23, i32* %3
br label %54
24: ; preds = %10
br label %25
25: ; preds = %24, %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i8* @strrchr(i8* %28, i8 signext 47)
store i8* %29, i8** %7
%30 = load i8*, i8** %7
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %36
32: ; preds = %25
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
br label %39
36: ; preds = %25
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 1
br label %39
39: ; preds = %36, %32
%40 = phi i8* [ %35, %32 ], [ %38, %36 ]
store i8* %40, i8** %7
%41 = load i8*, i8** %7
%42 = call %struct.cmd_info* @locate_command(i8* %41)
store %struct.cmd_info* %42, %struct.cmd_info** %6
%43 = load %struct.cmd_info*, %struct.cmd_info** %6
%44 = icmp ne %struct.cmd_info* %43, null
br i1 %44, label %45, label %50
45: ; preds = %39
%46 = load i32, i32* %4
%47 = load i8**, i8*** %5
%48 = load %struct.cmd_info*, %struct.cmd_info** %6
%49 = call i32 @_run_command(i32 %46, i8** %47, %struct.cmd_info* %48)
store i32 %49, i32* %3
br label %54
50: ; preds = %39
%51 = load i32, i32* %4
%52 = load i8**, i8*** %5
%53 = call i32 @iotools_fallback(i32 %51, i8** %52)
store i32 %53, i32* %3
br label %54
54: ; preds = %50, %45, %17
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
%struct.cmd_info = type { i32 }
define i32 @run_command(i32 %0, i8** %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call %struct.cmd_info* @locate_command(i8* %6)
%8 = icmp eq %struct.cmd_info* %7, null
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = add nsw i32 %0, -1
%11 = tail call i32 @_run_command(i32 %10, i8** %5, %struct.cmd_info* %7)
br label %24
12: ; preds = %4, %2
%13 = load i8*, i8** %1
%14 = tail call i8* @strrchr(i8* dereferenceable(1) %13, i8 signext 47)
%15 = icmp eq i8* %14, null
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = select i1 %15, i8* %13, i8* %16
%18 = tail call %struct.cmd_info* @locate_command(i8* %17)
%19 = icmp eq %struct.cmd_info* %18, null
br i1 %19, label %22, label %20
20: ; preds = %12
%21 = tail call i32 @_run_command(i32 %0, i8** %1, %struct.cmd_info* %18)
br label %24
22: ; preds = %12
%23 = tail call i32 @iotools_fallback(i32 %0, i8** %1)
br label %24
24: ; preds = %22, %20, %9
%25 = phi i32 [ %11, %9 ], [ %21, %20 ], [ %23, %22 ]
ret i32 %25
}