#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*/ free(char *);
char *ft_echap_cmd(char *);
char *ft_strquote(char *);
char *ft_build_cmd(char *cmd) {
  int i;
  char *echap;
  cmd = ft_strquote(cmd);
  echap = ft_echap_cmd(cmd);
  i = -1;
  while (cmd[++i]) {
    if (echap[i] == 1)
      cmd[i] = -cmd[i];
  }
  free(echap);
  return (cmd);
}


x86 assembly (clang, -O0):
<ft_build_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ft_strquote@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ft_echap_cmd@plt>
mov    %rax,-0x18(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %ecx,%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11ae <ft_build_cmd+0x7e>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    11a9 <ft_build_cmd+0x79>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    115d <ft_build_cmd+0x2d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_build_cmd>:
push   %rbx
call   1050 <ft_strquote@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <ft_echap_cmd@plt>
mov    (%rbx),%cl
test   %cl,%cl
je     116a <ft_build_cmd+0x3a>
xor    %edx,%edx
jmp    115d <ft_build_cmd+0x2d>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
je     116a <ft_build_cmd+0x3a>
cmpb   $0x1,(%rax,%rdx,1)
jne    1150 <ft_build_cmd+0x20>
neg    %cl
mov    %cl,(%rbx,%rdx,1)
jmp    1150 <ft_build_cmd+0x20>
mov    %rax,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @ft_build_cmd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @ft_strquote(i8* %5)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @ft_echap_cmd(i8* %7)
store i8* %8, i8** %4
store i32 -1, i32* %3
br label %9
9: ; preds = %38, %1
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %9
%18 = load i8*, i8** %4
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %38
25: ; preds = %17
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = sub nsw i32 0, %31
%33 = trunc i32 %32 to i8
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 %33, i8* %37
br label %38
38: ; preds = %25, %17
br label %9
39: ; preds = %9
%40 = load i8*, i8** %4
%41 = call i32 @free(i8* %40)
%42 = load i8*, i8** %2
ret i8* %42
}

LLVM IR (-O2):
define i8* @ft_build_cmd(i8* %0) {
%2 = tail call i8* @ft_strquote(i8* %0)
%3 = tail call i8* @ft_echap_cmd(i8* %2)
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %1, %15
%7 = phi i64 [ %16, %15 ], [ 0, %1 ]
%8 = phi i8 [ %18, %15 ], [ %4, %1 ]
%9 = phi i8* [ %17, %15 ], [ %2, %1 ]
%10 = getelementptr inbounds i8, i8* %3, i64 %7
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = sub i8 0, %8
store i8 %14, i8* %9
br label %15
15: ; preds = %13, %6
%16 = add nuw i64 %7, 1
%17 = getelementptr inbounds i8, i8* %2, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %6
20: ; preds = %15, %1
%21 = tail call i32 @free(i8* %3)
ret i8* %2
}