#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 Processor {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ searchMemory(struct Processor *, char **);
int /*<<< orphan*/ searchRegisters(struct Processor *, char **);
scalar_t__ strcmp(char *, char *);
void search(struct Processor *proc, char **tokens) {
  if (strcmp(tokens[0], "-M") == 0) {
    printf("mem search\n");
    searchMemory(proc, tokens + 1);
  } else if (strcmp(tokens[0], "-R") == 0) {
    searchRegisters(proc, tokens + 1);
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    118f <search+0x4f>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1030 <searchMemory@plt>
jmp    11c2 <search+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe72(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <search+0x7d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <searchRegisters@plt>
jmp    11c2 <search+0x82>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rdi
lea    0xeac(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     117a <search+0x3a>
mov    (%rbx),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     119c <search+0x5c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <searchMemory@plt>
add    $0x8,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <searchRegisters@plt>

LLVM IR (-O0):
%struct.Processor = type { i32 }
@.str = [3 x i8] c"-M\00"
@.str.1 = [12 x i8] c"mem search\0A\00"
@.str.2 = [3 x i8] c"-R\00"
define void @search(%struct.Processor* %0, i8** %1) {
%3 = alloca %struct.Processor*
%4 = alloca i8**
store %struct.Processor* %0, %struct.Processor** %3
store i8** %1, i8*** %4
%5 = load i8**, i8*** %4
%6 = getelementptr inbounds i8*, i8** %5, i64 0
%7 = load i8*, i8** %6
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = load %struct.Processor*, %struct.Processor** %3
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = call i32 @searchMemory(%struct.Processor* %12, i8** %14)
br label %28
16: ; preds = %2
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load %struct.Processor*, %struct.Processor** %3
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = call i32 @searchRegisters(%struct.Processor* %23, i8** %25)
br label %27
27: ; preds = %22, %16
br label %28
28: ; preds = %27, %10
ret void
}

LLVM IR (-O2):
%struct.Processor = type { i32 }
@.str = [3 x i8] c"-M\00"
@.str.2 = [3 x i8] c"-R\00"
@str = [11 x i8] c"mem search\00"
define void @search(%struct.Processor* %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = tail call i32 @searchMemory(%struct.Processor* %0, i8** %8)
br label %17
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = tail call i32 @searchRegisters(%struct.Processor* %0, i8** %15)
br label %17
17: ; preds = %10, %14, %6
ret void
}