#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 strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int dbd_copy_argv(char *to, char **from) {
  char **a;
  int ret;
  for (a = from; *a != NULL; a++) {
    ret = strcpy(to, *a);
    to += strlen(*a);
    to[0] = ' ';
    to++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<dbd_copy_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1199 <dbd_copy_argv+0x79>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <dbd_copy_argv+0x18>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbd_copy_argv>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rsi),%rsi
test   %rsi,%rsi
je     116a <dbd_copy_argv+0x4a>
mov    %rdi,%rbx
add    $0x8,%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    -0x8(%r14),%rdi
call   1040 <strlen@plt>
cltq
movb   $0x20,(%rbx,%rax,1)
add    %rax,%rbx
add    $0x1,%rbx
mov    (%r14),%rsi
add    $0x8,%r14
test   %rsi,%rsi
jne    1140 <dbd_copy_argv+0x20>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @dbd_copy_argv(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2, %5
%6 = phi i8* [ %16, %5 ], [ %3, %2 ]
%7 = phi i8* [ %14, %5 ], [ %0, %2 ]
%8 = phi i8** [ %15, %5 ], [ %1, %2 ]
%9 = tail call i32 @strcpy(i8* %7, i8* %6)
%10 = load i8*, i8** %8
%11 = tail call i32 @strlen(i8* %10)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 32, i8* %13
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = getelementptr inbounds i8*, i8** %8, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %5
18: ; preds = %5, %2
ret i32 1
}