#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 *);
char *subst_expand(char *, char *, char *, char *, int /*<<< orphan*/,
                   int /*<<< orphan*/, int /*<<< orphan*/);
char *func_subst(char *o, char **argv,
                 const char *funcname __attribute__((unused))) {
  o = subst_expand(o, argv[2], argv[0], argv[1], strlen(argv[0]),
                   strlen(argv[1]), 0);
  return o;
}


x86 assembly (clang, -O0):
<func_subst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    %eax,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <subst_expand@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func_subst>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x10(%rsi),%r15
mov    (%rsi),%r12
mov    0x8(%rsi),%r13
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   1030 <strlen@plt>
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1040 <subst_expand@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @func_subst(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** %4
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strlen(i8* %23)
%25 = call i8* @subst_expand(i8* %7, i8* %10, i8* %13, i8* %16, i32 %20, i32 %24, i32 0)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
define i8* @func_subst(i8* %0, i8** nocapture %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 2
%5 = load i8*, i8** %4
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %6)
%10 = load i8*, i8** %7
%11 = tail call i32 @strlen(i8* %10)
%12 = tail call i8* @subst_expand(i8* %0, i8* %5, i8* %6, i8* %8, i32 %9, i32 %11, i32 0)
ret i8* %12
}