#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 count_char(int, char **);
int /*<<< orphan*/ ft_strcat(char *, char *);
char *malloc(int);
char *ft_concat_params(int argc, char **argv) {
  char *str;
  int i;
  int j;
  j = 1;
  i = count_char(argc, argv);
  str = malloc(sizeof(char) * (i + argc));
  while (j < argc) {
    ft_strcat(str, argv[j]);
    if (j != argc - 1)
      ft_strcat(str, "\n");
    j++;
  }
  return (str);
}


x86 assembly (clang, -O0):
<ft_concat_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <count_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x4(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bc <ft_concat_params+0x8c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <ft_strcat@plt>
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11ae <ft_concat_params+0x7e>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1040 <ft_strcat@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116c <ft_concat_params+0x3c>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_concat_params>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
call   1030 <count_char@plt>
lea    (%rax,%r15,1),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%r15d
jl     1197 <ft_concat_params+0x67>
lea    -0x1(%r15),%r12d
mov    %r15d,%r13d
mov    $0x1,%ebp
lea    0xe95(%rip),%r15
jmp    1179 <ft_concat_params+0x49>
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,%r13
je     1197 <ft_concat_params+0x67>
mov    (%r14,%rbp,8),%rsi
mov    %rbx,%rdi
call   1040 <ft_strcat@plt>
cmp    %rbp,%r12
je     1170 <ft_concat_params+0x40>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <ft_strcat@plt>
jmp    1170 <ft_concat_params+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i8* @ft_concat_params(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 1, i32* %7
%8 = load i32, i32* %3
%9 = load i8**, i8*** %4
%10 = call i32 @count_char(i32 %8, i8** %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = load i32, i32* %3
%13 = add nsw i32 %11, %12
%14 = sext i32 %13 to i64
%15 = mul i64 1, %14
%16 = trunc i64 %15 to i32
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %5
br label %18
18: ; preds = %37, %2
%19 = load i32, i32* %7
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i8**, i8*** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @ft_strcat(i8* %23, i8* %28)
%30 = load i32, i32* %7
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
%33 = icmp ne i32 %30, %32
br i1 %33, label %34, label %37
34: ; preds = %22
%35 = load i8*, i8** %5
%36 = call i32 @ft_strcat(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %34, %22
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %18
40: ; preds = %18
%41 = load i8*, i8** %5
ret i8* %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i8* @ft_concat_params(i32 %0, i8** %1) {
%3 = tail call i32 @count_char(i32 %0, i8** %1)
%4 = add nsw i32 %3, %0
%5 = tail call i8* @malloc(i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = add nsw i32 %0, -1
%9 = zext i32 %8 to i64
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %7, %19
%12 = phi i64 [ 1, %7 ], [ %20, %19 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @ft_strcat(i8* %5, i8* %14)
%16 = icmp eq i64 %12, %9
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = tail call i32 @ft_strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %11
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %19, %2
ret i8* %5
}