int **grid_init(char **lines) {
  int i;
  int j;
  int **grid;
  grid = malloc(sizeof(int *) * 9);
  i = -1;
  while (++i < 9) {
    j = -1;
    grid[i] = malloc(sizeof(int) * 9);
    while (++j < 9)
      put_in_grid(grid, i, j, lines[i][j]);
  }
  i = -1;
  while (++i < 9)
    free(lines[i]);
  free(lines);
  return (grid);
}


x86 assembly (clang, -O0):
<grid_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x48,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x9,%eax
jge    11c4 <grid_init+0x94>
movl   $0xffffffff,-0x10(%rbp)
mov    $0x24,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x9,%eax
jge    11bf <grid_init+0x8f>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x0,%al
call   1050 <put_in_grid@plt>
jmp    1183 <grid_init+0x53>
jmp    1151 <grid_init+0x21>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x9,%eax
jge    11f3 <grid_init+0xc3>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    11cb <grid_init+0x9b>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_init>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x48,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x24,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
mov    (%r14,%rbx,8),%rax
movsbl (%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x1(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x2(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x3(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x4(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x5(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x6(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x7(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
mov    (%r14,%rbx,8),%rax
movsbl 0x8(%rax),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1050 <put_in_grid@plt>
add    $0x1,%rbx
cmp    $0x9,%rbx
jne    1150 <grid_init+0x20>
mov    (%r14),%rdi
call   1030 <free@plt>
mov    0x8(%r14),%rdi
call   1030 <free@plt>
mov    0x10(%r14),%rdi
call   1030 <free@plt>
mov    0x18(%r14),%rdi
call   1030 <free@plt>
mov    0x20(%r14),%rdi
call   1030 <free@plt>
mov    0x28(%r14),%rdi
call   1030 <free@plt>
mov    0x30(%r14),%rdi
call   1030 <free@plt>
mov    0x38(%r14),%rdi
call   1030 <free@plt>
mov    0x40(%r14),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32** @grid_init(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
store i8** %0, i8*** %2
%6 = call i8* @malloc(i64 72)
%7 = bitcast i8* %6 to i32**
store i32** %7, i32*** %5
store i32 -1, i32* %3
br label %8
8: ; preds = %38, %1
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
%11 = icmp slt i32 %10, 9
br i1 %11, label %12, label %39
12: ; preds = %8
store i32 -1, i32* %4
%13 = call i8* @malloc(i64 36)
%14 = bitcast i8* %13 to i32*
%15 = load i32**, i32*** %5
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32*, i32** %15, i64 %17
store i32* %14, i32** %18
br label %19
19: ; preds = %23, %12
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
%22 = icmp slt i32 %21, 9
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load i32**, i32*** %5
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = load i8**, i8*** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %24, i32 %25, i32 %26, i32 %36)
br label %19
38: ; preds = %19
br label %8
39: ; preds = %8
store i32 -1, i32* %3
br label %40
40: ; preds = %44, %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
%43 = icmp slt i32 %42, 9
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i8**, i8*** %2
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
br label %40
50: ; preds = %40
%51 = load i8**, i8*** %2
%52 = bitcast i8** %51 to i8*
%53 = load i32**, i32*** %5
ret i32** %53
}

LLVM IR (-O2):
define i32** @grid_init(i8** nocapture %0) {
%2 = tail call dereferenceable_or_null(72) i8* @malloc(i64 72)
%3 = bitcast i8* %2 to i32**
br label %23
4: ; preds = %23
%5 = load i8*, i8** %0
tail call void @free(i8* %5)
%6 = getelementptr inbounds i8*, i8** %0, i64 1
%7 = load i8*, i8** %6
tail call void @free(i8* %7)
%8 = getelementptr inbounds i8*, i8** %0, i64 2
%9 = load i8*, i8** %8
tail call void @free(i8* %9)
%10 = getelementptr inbounds i8*, i8** %0, i64 3
%11 = load i8*, i8** %10
tail call void @free(i8* %11)
%12 = getelementptr inbounds i8*, i8** %0, i64 4
%13 = load i8*, i8** %12
tail call void @free(i8* %13)
%14 = getelementptr inbounds i8*, i8** %0, i64 5
%15 = load i8*, i8** %14
tail call void @free(i8* %15)
%16 = getelementptr inbounds i8*, i8** %0, i64 6
%17 = load i8*, i8** %16
tail call void @free(i8* %17)
%18 = getelementptr inbounds i8*, i8** %0, i64 7
%19 = load i8*, i8** %18
tail call void @free(i8* %19)
%20 = getelementptr inbounds i8*, i8** %0, i64 8
%21 = load i8*, i8** %20
tail call void @free(i8* %21)
%22 = bitcast i8** %0 to i8*
tail call void @free(i8* %22)
ret i32** %3
23: ; preds = %1, %23
%24 = phi i64 [ 0, %1 ], [ %74, %23 ]
%25 = tail call dereferenceable_or_null(36) i8* @malloc(i64 36)
%26 = getelementptr inbounds i32*, i32** %3, i64 %24
%27 = bitcast i32** %26 to i8**
store i8* %25, i8** %27
%28 = getelementptr inbounds i8*, i8** %0, i64 %24
%29 = load i8*, i8** %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = trunc i64 %24 to i32
%33 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 0, i32 %31)
%34 = load i8*, i8** %28
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 1, i32 %37)
%39 = load i8*, i8** %28
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 2, i32 %42)
%44 = load i8*, i8** %28
%45 = getelementptr inbounds i8, i8* %44, i64 3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 3, i32 %47)
%49 = load i8*, i8** %28
%50 = getelementptr inbounds i8, i8* %49, i64 4
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 4, i32 %52)
%54 = load i8*, i8** %28
%55 = getelementptr inbounds i8, i8* %54, i64 5
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 5, i32 %57)
%59 = load i8*, i8** %28
%60 = getelementptr inbounds i8, i8* %59, i64 6
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 6, i32 %62)
%64 = load i8*, i8** %28
%65 = getelementptr inbounds i8, i8* %64, i64 7
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 7, i32 %67)
%69 = load i8*, i8** %28
%70 = getelementptr inbounds i8, i8* %69, i64 8
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = tail call i32 (i32**, i32, i32, i32, ...) bitcast (i32 (...)* @put_in_grid to i32 (i32**, i32, i32, i32, ...)*)(i32** %3, i32 %32, i32 8, i32 %72)
%74 = add nuw nsw i64 %24, 1
%75 = icmp eq i64 %74, 9
br i1 %75, label %4, label %23
}