#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 */
void *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
__attribute__((malloc, returns_nonnull)) char **scr_map_new(int col, int row) {
  char **map = malloc(sizeof(char *) * row);
  for (int r = 0; r < row; r++) {
    map[r] = malloc(col + 1);
    memset(map[r], '-', col);
    map[r][col] = '\0';
  }
  return map;
}


x86 assembly (clang, -O0):
<scr_map_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a9 <scr_map_new+0x89>
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x4(%rbp),%edx
mov    $0x2d,%esi
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <scr_map_new+0x28>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scr_map_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    118d <scr_map_new+0x6d>
movslq %r14d,%r13
add    $0x1,%r14d
mov    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,(%r12,%rbp,8)
mov    %rax,%rdi
mov    $0x2d,%esi
mov    %r13d,%edx
call   1030 <memset@plt>
movb   $0x0,(%rbx,%r13,1)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <scr_map_new+0x40>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define noalias i8** @scr_map_new(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
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call i8* @malloc(i32 %10)
%12 = bitcast i8* %11 to i8**
store i8** %12, i8*** %5
store i32 0, i32* %6
br label %13
13: ; preds = %40, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %43
17: ; preds = %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = call i8* @malloc(i32 %19)
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
store i8* %20, i8** %24
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* %3
%31 = call i32 @memset(i8* %29, i8 signext 45, i32 %30)
%32 = load i8**, i8*** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %17
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %13
43: ; preds = %13
%44 = load i8**, i8*** %5
ret i8** %44
}

LLVM IR (-O2):
define noalias i8** @scr_map_new(i32 %0, i32 %1) {
%3 = shl i32 %1, 3
%4 = tail call i8* @malloc(i32 %3)
%5 = bitcast i8* %4 to i8**
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = add nsw i32 %0, 1
%9 = sext i32 %0 to i64
%10 = zext i32 %1 to i64
br label %12
11: ; preds = %12, %2
ret i8** %5
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %18, %12 ]
%14 = tail call i8* @malloc(i32 %8)
%15 = getelementptr inbounds i8*, i8** %5, i64 %13
store i8* %14, i8** %15
%16 = tail call i32 @memset(i8* %14, i8 signext 45, i32 %0)
%17 = getelementptr inbounds i8, i8* %14, i64 %9
store i8 0, i8* %17
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %11, label %12
}