#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);
int /*<<< orphan*/ ft_memset(void *, int, int);
char *ft_strnew(int);
char **ft_malloc2d(int x, int y) {
  char **array;
  int i;
  i = -1;
  while (!(array = (char **)ft_memalloc(sizeof(char *) * (y + 1))))
    continue;
  while (++i < y) {
    while (!(array[i] = ft_strnew(x)))
      continue;
    ft_memset((void *)array[i], (int)'.', x);
  }
  return (array);
}


x86 assembly (clang, -O0):
<ft_malloc2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x8(%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    1172 <ft_malloc2d+0x42>
jmp    1177 <ft_malloc2d+0x47>
jmp    1145 <ft_malloc2d+0x15>
jmp    117c <ft_malloc2d+0x4c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jge    11e0 <ft_malloc2d+0xb0>
jmp    1193 <ft_malloc2d+0x63>
mov    -0x4(%rbp),%edi
call   1040 <ft_strnew@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    11bd <ft_malloc2d+0x8d>
jmp    11c2 <ft_malloc2d+0x92>
jmp    1193 <ft_malloc2d+0x63>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x4(%rbp),%edx
mov    $0x2e,%esi
call   1030 <ft_memset@plt>
jmp    117c <ft_malloc2d+0x4c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_malloc2d>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%r12d
lea    0x8(,%r14,8),%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1050 <ft_memalloc@plt>
test   %rax,%rax
je     1150 <ft_malloc2d+0x20>
mov    %rax,%rbx
test   %r14d,%r14d
jle    119a <ft_malloc2d+0x6a>
mov    %r14d,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   1040 <ft_strnew@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     1170 <ft_malloc2d+0x40>
mov    %rax,%rdi
mov    $0x2e,%esi
mov    %r12d,%edx
call   1030 <ft_memset@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
jne    1170 <ft_malloc2d+0x40>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8** @ft_malloc2d(i32 %0, i32 %1) {
%3 = shl i32 %1, 3
%4 = add i32 %3, 8
br label %5
5: ; preds = %5, %2
%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 %1, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %19
%14 = phi i64 [ 0, %11 ], [ %21, %19 ]
%15 = getelementptr inbounds i8*, i8** %9, i64 %14
br label %16
16: ; preds = %13, %16
%17 = tail call i8* @ft_strnew(i32 %0)
store i8* %17, i8** %15
%18 = icmp eq i8* %17, null
br i1 %18, label %16, label %19
19: ; preds = %16
%20 = tail call i32 @ft_memset(i8* %17, i32 46, i32 %0)
%21 = add nuw nsw i64 %14, 1
%22 = icmp eq i64 %21, %12
br i1 %22, label %23, label %13
23: ; preds = %19, %8
ret i8** %9
}