#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*/ ConvertLcase(char *, int);
int DBFindCommand(char *, int);
int DBFindRemote(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int DBFindRemoteCommand(char remote[], char command[], int *cmd_num,
                        int *rem_num) {
  int ncmd, nrem;
  char remcmp[100];
  char cmdcmp[100];
  memset(remcmp, 0, 100);
  memset(cmdcmp, 0, 100);
  strcpy(remcmp, remote);
  strcpy(cmdcmp, command);
  ConvertLcase(remcmp, (int)strlen(remcmp));
  ConvertLcase(cmdcmp, (int)strlen(cmdcmp));
  nrem = DBFindRemote(remcmp);
  if (nrem == -1)
    return (12);
  if (rem_num)
    *rem_num = nrem;
  ncmd = DBFindCommand(cmdcmp, nrem);
  if (ncmd == -1)
    return (13);
  *cmd_num = ncmd;
  return (0);
}


x86 assembly (clang, -O0):
<DBFindRemoteCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x120(%rbp),%rdi
mov    %eax,%esi
call   1030 <ConvertLcase@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x118(%rbp),%rdi
mov    %eax,%esi
call   1030 <ConvertLcase@plt>
lea    -0xa0(%rbp),%rdi
call   1080 <DBFindRemote@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    1236 <DBFindRemoteCommand+0xd6>
movl   $0xc,-0x4(%rbp)
jmp    1282 <DBFindRemoteCommand+0x122>
cmpq   $0x0,-0x28(%rbp)
je     124a <DBFindRemoteCommand+0xea>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x110(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1070 <DBFindCommand@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1272 <DBFindRemoteCommand+0x112>
movl   $0xd,-0x4(%rbp)
jmp    1282 <DBFindRemoteCommand+0x122>
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DBFindRemoteCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0x70(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <ConvertLcase@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <ConvertLcase@plt>
mov    %r12,%rdi
call   1080 <DBFindRemote@plt>
cmp    $0xffffffff,%eax
je     1208 <DBFindRemoteCommand+0xa8>
test   %r15,%r15
je     11f2 <DBFindRemoteCommand+0x92>
mov    %eax,(%r15)
mov    %rsp,%rdi
mov    %eax,%esi
call   1070 <DBFindCommand@plt>
cmp    $0xffffffff,%eax
je     120f <DBFindRemoteCommand+0xaf>
mov    %eax,(%r14)
xor    %eax,%eax
jmp    1214 <DBFindRemoteCommand+0xb4>
mov    $0xc,%eax
jmp    1214 <DBFindRemoteCommand+0xb4>
mov    $0xd,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @DBFindRemoteCommand(i8* %0, i8* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca [100 x i8]
%13 = alloca [100 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 100)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 100)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%19 = load i8*, i8** %6
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%22 = load i8*, i8** %7
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%26 = call i64 @strlen(i8* %25)
%27 = trunc i64 %26 to i32
%28 = call i32 @ConvertLcase(i8* %24, i32 %27)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%31 = call i64 @strlen(i8* %30)
%32 = trunc i64 %31 to i32
%33 = call i32 @ConvertLcase(i8* %29, i32 %32)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%35 = call i32 @DBFindRemote(i8* %34)
store i32 %35, i32* %11
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %39
38: ; preds = %4
store i32 12, i32* %5
br label %55
39: ; preds = %4
%40 = load i32*, i32** %9
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %11
%44 = load i32*, i32** %9
store i32 %43, i32* %44
br label %45
45: ; preds = %42, %39
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%47 = load i32, i32* %11
%48 = call i32 @DBFindCommand(i8* %46, i32 %47)
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %52
51: ; preds = %45
store i32 13, i32* %5
br label %55
52: ; preds = %45
%53 = load i32, i32* %10
%54 = load i32*, i32** %8
store i32 %53, i32* %54
store i32 0, i32* %5
br label %55
55: ; preds = %52, %51, %38
%56 = load i32, i32* %5
ret i32 %56
}

LLVM IR (-O2):
define i32 @DBFindRemoteCommand(i8* %0, i8* %1, i32* nocapture writeonly %2, i32* writeonly %3) {
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %7, i32 0, i32 100)
%10 = call i32 @memset(i8* %8, i32 0, i32 100)
%11 = call i32 @strcpy(i8* %7, i8* %0)
%12 = call i32 @strcpy(i8* %8, i8* %1)
%13 = call i64 @strlen(i8* %7)
%14 = trunc i64 %13 to i32
%15 = call i32 @ConvertLcase(i8* %7, i32 %14)
%16 = call i64 @strlen(i8* %8)
%17 = trunc i64 %16 to i32
%18 = call i32 @ConvertLcase(i8* %8, i32 %17)
%19 = call i32 @DBFindRemote(i8* %7)
%20 = icmp eq i32 %19, -1
br i1 %20, label %28, label %21
21: ; preds = %4
%22 = icmp eq i32* %3, null
br i1 %22, label %24, label %23
23: ; preds = %21
store i32 %19, i32* %3
br label %24
24: ; preds = %23, %21
%25 = call i32 @DBFindCommand(i8* %8, i32 %19)
%26 = icmp eq i32 %25, -1
br i1 %26, label %28, label %27
27: ; preds = %24
store i32 %25, i32* %2
br label %28
28: ; preds = %24, %4, %27
%29 = phi i32 [ 0, %27 ], [ 12, %4 ], [ 13, %24 ]
ret i32 %29
}