#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int *malloc(int);
int /*<<< orphan*/ stdout;
int *init_lattice(int n_side) {
  int *x;
  int i;
  if (!(x = malloc(sizeof(int) * n_side * n_side))) {
    fprintf(stdout, "allocation problem\n");
    exit(1);
  }
  for (i = 0; i < n_side * n_side; i++) {
    x[i] = -1;
  }
  return x;
}


x86 assembly (clang, -O0):
<init_lattice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
movslq -0x4(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117f <init_lattice+0x4f>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    11b5 <init_lattice+0x85>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1186 <init_lattice+0x56>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_lattice>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
imul   %ebx,%ebx
lea    0x0(,%rbx,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     117f <init_lattice+0x3f>
mov    %rax,%r14
test   %ebx,%ebx
je     1174 <init_lattice+0x34>
mov    %ebx,%edx
shl    $0x2,%rdx
mov    %r14,%rdi
mov    $0xff,%esi
call   1030 <memset@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [20 x i8] c"allocation problem\0A\00"
define i32* @init_lattice(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = mul i64 4, %6
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 %7, %9
%11 = trunc i64 %10 to i32
%12 = call i32* @malloc(i32 %11)
store i32* %12, i32** %3
%13 = icmp ne i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %1
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %1
store i32 0, i32* %4
br label %19
19: ; preds = %30, %18
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = load i32, i32* %2
%23 = mul nsw i32 %21, %22
%24 = icmp slt i32 %20, %23
br i1 %24, label %25, label %33
25: ; preds = %19
%26 = load i32*, i32** %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 -1, i32* %29
br label %30
30: ; preds = %25
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %19
33: ; preds = %19
%34 = load i32*, i32** %3
ret i32* %34
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [20 x i8] c"allocation problem\0A\00"
define noalias i32* @init_lattice(i32 %0) {
%2 = shl i32 %0, 2
%3 = mul i32 %2, %0
%4 = tail call i32* @malloc(i32 %3)
%5 = bitcast i32* %4 to i8*
%6 = icmp eq i32* %4, null
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = mul i32 %0, %0
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = zext i32 %8 to i64
%12 = shl nuw nsw i64 %11, 2
br label %17
13: ; preds = %1
%14 = load i32, i32* @stdout
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10, %7
ret i32* %4
}