#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 */
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
int /*<<< orphan*/ copy(char *, char *, unsigned int);
char *copy_input(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ insert_0(char *, unsigned int, unsigned int);
int /*<<< orphan*/ memset(char *, char, size_t);
int /*<<< orphan*/ munmap(char *, int /*<<< orphan*/);
char *null_check_malloc(size_t);
int /*<<< orphan*/ scan(char *, unsigned int *, unsigned int *);
void init_board(char **current, char **next, unsigned *width, unsigned *height,
                char *filename) {
  off_t in_size = 0;
  char *buff = copy_input(filename, &in_size);
  scan(buff, width, height);
  size_t size = *height * (*width + 1);
  *current = null_check_malloc(size);
  *next = null_check_malloc(size);
  memset(*current, ' ', size);
  copy(buff, *current, *width);
  munmap(buff, in_size);
  insert_0(*current, *width, *height);
  insert_0(*next, *width, *height);
}


x86 assembly (clang, -O0):
<init_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <copy_input@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <scan@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1070 <null_check_malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
call   1070 <null_check_malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rdx
mov    $0x20,%esi
call   1030 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1040 <copy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1080 <munmap@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1050 <insert_0@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1050 <insert_0@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_board>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %r8,%rdi
call   1060 <copy_input@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <scan@plt>
mov    (%rbx),%ebp
add    $0x1,%ebp
imul   (%r14),%ebp
mov    %rbp,%rdi
call   1070 <null_check_malloc@plt>
mov    %rax,(%r12)
mov    %rbp,%rdi
call   1070 <null_check_malloc@plt>
mov    %rax,(%r15)
mov    (%r12),%rdi
mov    $0x20,%esi
mov    %rbp,%rdx
call   1030 <memset@plt>
mov    (%r12),%rsi
mov    (%rbx),%edx
mov    %r13,%rdi
call   1040 <copy@plt>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
call   1080 <munmap@plt>
mov    (%r12),%rdi
mov    (%rbx),%esi
mov    (%r14),%edx
call   1050 <insert_0@plt>
mov    (%r15),%rdi
mov    (%rbx),%esi
mov    (%r14),%edx
call   1050 <insert_0@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @init_board(i8** %0, i8** %1, i32* %2, i32* %3, i8* %4) {
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i8* %4, i8** %10
store i32 0, i32* %11
%14 = load i8*, i8** %10
%15 = call i8* @copy_input(i8* %14, i32* %11)
store i8* %15, i8** %12
%16 = load i8*, i8** %12
%17 = load i32*, i32** %8
%18 = load i32*, i32** %9
%19 = call i32 @scan(i8* %16, i32* %17, i32* %18)
%20 = load i32*, i32** %9
%21 = load i32, i32* %20
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
%24 = add i32 %23, 1
%25 = mul i32 %21, %24
%26 = zext i32 %25 to i64
store i64 %26, i64* %13
%27 = load i64, i64* %13
%28 = call i8* @null_check_malloc(i64 %27)
%29 = load i8**, i8*** %6
store i8* %28, i8** %29
%30 = load i64, i64* %13
%31 = call i8* @null_check_malloc(i64 %30)
%32 = load i8**, i8*** %7
store i8* %31, i8** %32
%33 = load i8**, i8*** %6
%34 = load i8*, i8** %33
%35 = load i64, i64* %13
%36 = call i32 @memset(i8* %34, i8 signext 32, i64 %35)
%37 = load i8*, i8** %12
%38 = load i8**, i8*** %6
%39 = load i8*, i8** %38
%40 = load i32*, i32** %8
%41 = load i32, i32* %40
%42 = call i32 @copy(i8* %37, i8* %39, i32 %41)
%43 = load i8*, i8** %12
%44 = load i32, i32* %11
%45 = call i32 @munmap(i8* %43, i32 %44)
%46 = load i8**, i8*** %6
%47 = load i8*, i8** %46
%48 = load i32*, i32** %8
%49 = load i32, i32* %48
%50 = load i32*, i32** %9
%51 = load i32, i32* %50
%52 = call i32 @insert_0(i8* %47, i32 %49, i32 %51)
%53 = load i8**, i8*** %7
%54 = load i8*, i8** %53
%55 = load i32*, i32** %8
%56 = load i32, i32* %55
%57 = load i32*, i32** %9
%58 = load i32, i32* %57
%59 = call i32 @insert_0(i8* %54, i32 %56, i32 %58)
ret void
}

LLVM IR (-O2):
define void @init_board(i8** nocapture %0, i8** nocapture %1, i32* %2, i32* %3, i8* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%8 = call i8* @copy_input(i8* %4, i32* %6)
%9 = call i32 @scan(i8* %8, i32* %2, i32* %3)
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = add i32 %11, 1
%13 = mul i32 %12, %10
%14 = zext i32 %13 to i64
%15 = call i8* @null_check_malloc(i64 %14)
store i8* %15, i8** %0
%16 = call i8* @null_check_malloc(i64 %14)
store i8* %16, i8** %1
%17 = load i8*, i8** %0
%18 = call i32 @memset(i8* %17, i8 signext 32, i64 %14)
%19 = load i8*, i8** %0
%20 = load i32, i32* %2
%21 = call i32 @copy(i8* %8, i8* %19, i32 %20)
%22 = load i32, i32* %6
%23 = call i32 @munmap(i8* %8, i32 %22)
%24 = load i8*, i8** %0
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @insert_0(i8* %24, i32 %25, i32 %26)
%28 = load i8*, i8** %1
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = call i32 @insert_0(i8* %28, i32 %29, i32 %30)
ret void
}