#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 ft_argvlen(int, char **);
int ft_strlen(char *);
int /*<<< orphan*/ ft_strncat(char *, char *, int);
scalar_t__ malloc(int);
char *ft_concat_params(int argc, char **argv) {
  int i;
  char *dest;
  char *bn;
  i = 1;
  bn = "\n";
  dest = (char *)malloc(sizeof(char) * ft_argvlen(argc, argv));
  if (argc > 1)
    while (++i < argc + 1) {
      ft_strncat(dest, argv[i - 1], ft_strlen(argv[i - 1]));
      if (i < argc)
        ft_strncat(dest, bn, 1);
    }
  return (dest);
}


x86 assembly (clang, -O0):
<ft_concat_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <ft_argvlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    120e <ft_concat_params+0xce>
jmp    118d <ft_concat_params+0x4d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1209 <ft_concat_params+0xc9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <ft_strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1040 <ft_strncat@plt>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1204 <ft_concat_params+0xc4>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1040 <ft_strncat@plt>
jmp    118d <ft_concat_params+0x4d>
jmp    120e <ft_concat_params+0xce>
mov    -0x20(%rbp),%rax
add    $0x40,%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,%ebp
call   1060 <ft_argvlen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
jl     11c7 <ft_concat_params+0x87>
mov    %ebp,%r12d
mov    $0x1,%r13d
sub    %r12,%r13
mov    $0x2,%r15d
jmp    1192 <ft_concat_params+0x52>
nopl   0x0(%rax,%rax,1)
lea    (%r15,%r13,1),%rax
add    $0x1,%rax
add    $0x1,%r15
cmp    $0x2,%rax
je     11c7 <ft_concat_params+0x87>
mov    -0x8(%r14,%r15,8),%rbp
mov    %rbp,%rdi
call   1030 <ft_strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <ft_strncat@plt>
cmp    %r12,%r15
jae    1180 <ft_concat_params+0x40>
mov    %rbx,%rdi
lea    0xe45(%rip),%rsi
mov    $0x1,%edx
call   1040 <ft_strncat@plt>
jmp    1180 <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 i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 1, i32* %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = load i32, i32* %3
%9 = load i8**, i8*** %4
%10 = call i32 @ft_argvlen(i32 %8, i8** %9)
%11 = sext i32 %10 to i64
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %6
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %50
18: ; preds = %2
br label %19
19: ; preds = %48, %18
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %49
25: ; preds = %19
%26 = load i8*, i8** %6
%27 = load i8**, i8*** %4
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %4
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @ft_strlen(i8* %38)
%40 = call i32 @ft_strncat(i8* %26, i8* %32, i32 %39)
%41 = load i32, i32* %5
%42 = load i32, i32* %3
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %25
%45 = load i8*, i8** %6
%46 = load i8*, i8** %7
%47 = call i32 @ft_strncat(i8* %45, i8* %46, i32 1)
br label %48
48: ; preds = %44, %25
br label %19
49: ; preds = %19
br label %50
50: ; preds = %49, %2
%51 = load i8*, i8** %6
ret i8* %51
}

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