#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 */
char *allocmem(size_t);
int /*<<< orphan*/ freem(char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ system(char *);
void invoke_prog(char *prog, char *args) {
  size_t l = strlen(prog);
  char *buf = allocmem(l + strlen(args) + 2);
  strcpy(buf, prog);
  buf[l] = ' ';
  strcpy(&buf[l + 1], args);
  system(buf);
  freem(buf);
}


x86 assembly (clang, -O0):
<invoke_prog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1070 <allocmem@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   1060 <system@plt>
mov    -0x20(%rbp),%rdi
call   1030 <freem@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invoke_prog>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%r12,%rax,1),%rdi
add    $0x2,%rdi
call   1070 <allocmem@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
movb   $0x20,(%rbx,%r12,1)
lea    (%rbx,%r12,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <freem@plt>

LLVM IR (-O0):
define void @invoke_prog(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = load i8*, i8** %4
%11 = call i64 @strlen(i8* %10)
%12 = add i64 %9, %11
%13 = add i64 %12, 2
%14 = call i8* @allocmem(i64 %13)
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = load i8*, i8** %3
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %6
%19 = load i64, i64* %5
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8 32, i8* %20
%21 = load i8*, i8** %6
%22 = load i64, i64* %5
%23 = add i64 %22, 1
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @system(i8* %27)
%29 = load i8*, i8** %6
%30 = call i32 @freem(i8* %29)
ret void
}

LLVM IR (-O2):
define void @invoke_prog(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add i64 %3, 2
%6 = add i64 %5, %4
%7 = tail call i8* @allocmem(i64 %6)
%8 = tail call i32 @strcpy(i8* %7, i8* %0)
%9 = getelementptr inbounds i8, i8* %7, i64 %3
store i8 32, i8* %9
%10 = add i64 %3, 1
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = tail call i32 @strcpy(i8* %11, i8* %1)
%13 = tail call i32 @system(i8* %7)
%14 = tail call i32 @freem(i8* %7)
ret void
}