#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*/ strlen(char *);
scalar_t__ strstr(char *, char *);
char *variable_buffer_output(char *, char *, int /*<<< orphan*/);
char *func_findstring(char *o, char **argv,
                      const char *funcname __attribute__((unused))) {
  if (strstr(argv[1], argv[0]) != 0)
    o = variable_buffer_output(o, argv[0], strlen(argv[0]));
  return o;
}


x86 assembly (clang, -O0):
<func_findstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     1194 <func_findstring+0x64>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <variable_buffer_output@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func_findstring>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rsi
mov    0x8(%rbx),%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     116a <func_findstring+0x3a>
mov    (%rbx),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <variable_buffer_output@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @func_findstring(i8* %0, i8** %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i64 @strstr(i8* %9, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %3
%16 = load i8*, i8** %4
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @strlen(i8* %22)
%24 = call i8* @variable_buffer_output(i8* %16, i8* %19, i32 %23)
store i8* %24, i8** %4
br label %25
25: ; preds = %15, %3
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
define i8* @func_findstring(i8* %0, i8** nocapture %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = load i8*, i8** %1
%7 = tail call i64 @strstr(i8* %5, i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i8*, i8** %1
%11 = tail call i32 @strlen(i8* %10)
%12 = tail call i8* @variable_buffer_output(i8* %0, i8* %10, i32 %11)
br label %13
13: ; preds = %9, %3
%14 = phi i8* [ %12, %9 ], [ %0, %3 ]
ret i8* %14
}