#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 */
scalar_t__ ft_memalloc(int);
char *ft_strdup(char *);
int get_v(char **);
char **new_2d_cpy(char *actual[]) {
  char **array;
  int i;
  int y;
  y = get_v(actual);
  i = -1;
  while (!(array = (char **)ft_memalloc(sizeof(char *) * (y + 1))))
    continue;
  while (++i < y) {
    while (!(array[i] = ft_strdup(actual[i])))
      continue;
  }
  return (array);
}


x86 assembly (clang, -O0):
<new_2d_cpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_v@plt>
mov    %eax,-0x18(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <ft_memalloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117c <new_2d_cpy+0x4c>
jmp    1181 <new_2d_cpy+0x51>
jmp    114f <new_2d_cpy+0x1f>
jmp    1186 <new_2d_cpy+0x56>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x18(%rbp),%eax
jge    11da <new_2d_cpy+0xaa>
jmp    119d <new_2d_cpy+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <ft_strdup@plt>
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d0 <new_2d_cpy+0xa0>
jmp    11d5 <new_2d_cpy+0xa5>
jmp    119d <new_2d_cpy+0x6d>
jmp    1186 <new_2d_cpy+0x56>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_2d_cpy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <get_v@plt>
mov    %eax,%r15d
lea    0x8(,%r15,8),%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <ft_memalloc@plt>
test   %rax,%rax
je     1150 <new_2d_cpy+0x20>
mov    %rax,%rbx
test   %r15d,%r15d
jle    118b <new_2d_cpy+0x5b>
mov    %r15d,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r14,%rbp,8),%rdi
call   1040 <ft_strdup@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     1170 <new_2d_cpy+0x40>
add    $0x1,%rbp
cmp    %r15,%rbp
jne    1170 <new_2d_cpy+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8** @new_2d_cpy(i8** %0) {
%2 = tail call i32 @get_v(i8** %0)
%3 = shl i32 %2, 3
%4 = add i32 %3, 8
br label %5
5: ; preds = %5, %1
%6 = tail call i64 @ft_memalloc(i32 %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %5, label %8
8: ; preds = %5
%9 = inttoptr i64 %6 to i8**
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = zext i32 %2 to i64
br label %16
13: ; preds = %20
%14 = add nuw nsw i64 %17, 1
%15 = icmp eq i64 %14, %12
br i1 %15, label %24, label %16
16: ; preds = %11, %13
%17 = phi i64 [ 0, %11 ], [ %14, %13 ]
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = getelementptr inbounds i8*, i8** %9, i64 %17
br label %20
20: ; preds = %16, %20
%21 = load i8*, i8** %18
%22 = tail call i8* @ft_strdup(i8* %21)
store i8* %22, i8** %19
%23 = icmp eq i8* %22, null
br i1 %23, label %20, label %13
24: ; preds = %13, %8
ret i8** %9
}