void printBoard(int *sol, int size) {
  int x, y, i;
  int dim = size > 9 ? 2 : 1;
  printf("%*s", dim + 1, " ");
  for (i = 0; i < size * (dim + 1) + 1; i++) {
    printf("-");
  }
  printf("\n");
  printf("%*s|", dim + 1, " ");
  for (x = 1; x <= size; x++) {
    printf("%*d|", dim, x);
  }
  printf("\n");
  for (i = 0; i < (size + 1) * (dim + 1) + 1; i++) {
    printf("-");
  }
  printf("\n");
  for (y = 0; y < size; y++) {
    printf("|%*d|", dim, y + 1);
    for (x = 0; x < size; x++) {
      printf("%*s|", dim, sol[y] == x ? "*" : "-");
    }
    printf("\n");
    for (i = 0; i < (size + 1) * (dim + 1) + 1; i++) {
      printf("-");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    $0x1,%eax
mov    $0x2,%ecx
cmp    $0x9,%edx
cmovg  %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xebe(%rip),%rdi
lea    0xebb(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    118d <printBoard+0x7d>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <printBoard+0x47>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe62(%rip),%rdi
lea    0xe55(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11eb <printBoard+0xdb>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bd <printBoard+0xad>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1239 <printBoard+0x129>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1200 <printBoard+0xf0>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    132f <printBoard+0x21f>
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c5 <printBoard+0x1b5>
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x10(%rbp),%edi
lea    0xd6a(%rip),%rdx
lea    0xd72(%rip),%rax
cmp    %edi,%ecx
cmove  %rax,%rdx
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1278 <printBoard+0x168>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1313 <printBoard+0x203>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12da <printBoard+0x1ca>
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    124e <printBoard+0x13e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBoard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebx
mov    %rdi,0x30(%rsp)
xor    %r15d,%r15d
cmp    $0xa,%esi
setge  %r15b
lea    0x2(%r15),%ebp
lea    0xeb6(%rip),%rdi
lea    0xeb3(%rip),%rdx
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%r14
imul   %ebx,%ebp
test   %ebp,%ebp
js     117f <printBoard+0x5f>
add    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1170 <printBoard+0x50>
add    $0x1,%r15d
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe74(%rip),%rdi
lea    0xe69(%rip),%rdx
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11e2 <printBoard+0xc2>
mov    %ebx,%r12d
neg    %r12d
mov    $0x1,%ebp
lea    0xe53(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r12,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11c0 <printBoard+0xa0>
mov    %rbx,0x18(%rsp)
add    $0x1,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
imul   %ebx,%r14d
mov    %r14,0x8(%rsp)
test   %r14d,%r14d
js     121f <printBoard+0xff>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1210 <printBoard+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x18(%rsp),%rbx
test   %ebx,%ebx
jle    1304 <printBoard+0x1e4>
mov    %ebx,%eax
mov    %rax,0x20(%rsp)
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %eax,0x14(%rsp)
lea    0xdc3(%rip),%r12
lea    0xdb1(%rip),%rbp
xor    %r13d,%r13d
jmp    127f <printBoard+0x15f>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x28(%rsp),%r13
cmp    0x20(%rsp),%r13
mov    0x18(%rsp),%rbx
je     1304 <printBoard+0x1e4>
lea    0x1(%r13),%rdx
lea    0xd83(%rip),%rdi
mov    %r15d,%esi
mov    %rdx,0x28(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r14d,%r14d
jmp    12b6 <printBoard+0x196>
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
cmp    %r14d,%ebx
je     12d0 <printBoard+0x1b0>
mov    %r12,%rdx
mov    0x30(%rsp),%rax
cmp    (%rax,%r13,4),%r14d
je     12a0 <printBoard+0x180>
lea    0xd3b(%rip),%rdx
jmp    12a0 <printBoard+0x180>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x8(%rsp)
js     1260 <printBoard+0x140>
mov    0x14(%rsp),%ebx
nopl   0x0(%rax)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    12f0 <printBoard+0x1d0>
jmp    1260 <printBoard+0x140>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%*s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [5 x i8] c"%*s|\00"
@.str.5 = [5 x i8] c"%*d|\00"
@.str.6 = [6 x i8] c"|%*d|\00"
@.str.7 = [2 x i8] c"*\00"
define void @printBoard(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 9
%11 = zext i1 %10 to i64
%12 = select i1 %10, i32 2, i32 1
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = add nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %16
16: ; preds = %26, %2
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
%21 = mul nsw i32 %18, %20
%22 = add nsw i32 %21, 1
%23 = icmp slt i32 %17, %22
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %16
29: ; preds = %16
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %34
34: ; preds = %42, %29
%35 = load i32, i32* %5
%36 = load i32, i32* %4
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %45
38: ; preds = %34
%39 = load i32, i32* %8
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 %40)
br label %42
42: ; preds = %38
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %34
45: ; preds = %34
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %47
47: ; preds = %58, %45
%48 = load i32, i32* %7
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
%53 = mul nsw i32 %50, %52
%54 = add nsw i32 %53, 1
%55 = icmp slt i32 %48, %54
br i1 %55, label %56, label %61
56: ; preds = %47
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %47
61: ; preds = %47
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %63
63: ; preds = %109, %61
%64 = load i32, i32* %6
%65 = load i32, i32* %4
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %112
67: ; preds = %63
%68 = load i32, i32* %8
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %68, i32 %70)
store i32 0, i32* %5
br label %72
72: ; preds = %88, %67
%73 = load i32, i32* %5
%74 = load i32, i32* %4
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %91
76: ; preds = %72
%77 = load i32, i32* %8
%78 = load i32*, i32** %3
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i32, i32* %78, i64 %80
%82 = load i32, i32* %81
%83 = load i32, i32* %5
%84 = icmp eq i32 %82, %83
%85 = zext i1 %84 to i64
%86 = select i1 %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %77, i8* %86)
br label %88
88: ; preds = %76
%89 = load i32, i32* %5
%90 = add nsw i32 %89, 1
store i32 %90, i32* %5
br label %72
91: ; preds = %72
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %93
93: ; preds = %104, %91
%94 = load i32, i32* %7
%95 = load i32, i32* %4
%96 = add nsw i32 %95, 1
%97 = load i32, i32* %8
%98 = add nsw i32 %97, 1
%99 = mul nsw i32 %96, %98
%100 = add nsw i32 %99, 1
%101 = icmp slt i32 %94, %100
br i1 %101, label %102, label %107
102: ; preds = %93
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %104
104: ; preds = %102
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
store i32 %106, i32* %7
br label %93
107: ; preds = %93
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %109
109: ; preds = %107
%110 = load i32, i32* %6
%111 = add nsw i32 %110, 1
store i32 %111, i32* %6
br label %63
112: ; preds = %63
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%*s\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"-\00"
@.str.4 = [5 x i8] c"%*s|\00"
@.str.5 = [5 x i8] c"%*d|\00"
@.str.6 = [6 x i8] c"|%*d|\00"
@.str.7 = [2 x i8] c"*\00"
define void @printBoard(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 9
%4 = select i1 %3, i32 2, i32 1
%5 = add nuw nsw i32 %4, 1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = mul i32 %5, %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %2, %9
%10 = phi i32 [ %12, %9 ], [ 0, %2 ]
%11 = tail call i32 @putchar(i32 45)
%12 = add nuw i32 %10, 1
%13 = icmp eq i32 %10, %7
br i1 %13, label %14, label %9
14: ; preds = %9, %2
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp slt i32 %1, 1
br i1 %17, label %23, label %18
18: ; preds = %14, %18
%19 = phi i32 [ %21, %18 ], [ 1, %14 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %4, i32 %19)
%21 = add nuw i32 %19, 1
%22 = icmp eq i32 %19, %1
br i1 %22, label %23, label %18
23: ; preds = %18, %14
%24 = add i32 %1, 1
%25 = tail call i32 @putchar(i32 10)
%26 = mul i32 %5, %24
%27 = icmp slt i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %23, %28
%29 = phi i32 [ %31, %28 ], [ 0, %23 ]
%30 = tail call i32 @putchar(i32 45)
%31 = add nuw i32 %29, 1
%32 = icmp eq i32 %29, %26
br i1 %32, label %33, label %28
33: ; preds = %28, %23
%34 = tail call i32 @putchar(i32 10)
%35 = icmp sgt i32 %1, 0
br i1 %35, label %36, label %62
36: ; preds = %33
%37 = zext i32 %1 to i64
br label %38
38: ; preds = %59, %36
%39 = phi i64 [ 0, %36 ], [ %40, %59 ]
%40 = add nuw nsw i64 %39, 1
%41 = trunc i64 %40 to i32
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %4, i32 %41)
%43 = getelementptr inbounds i32, i32* %0, i64 %39
br label %44
44: ; preds = %38, %44
%45 = phi i32 [ 0, %38 ], [ %50, %44 ]
%46 = load i32, i32* %43
%47 = icmp eq i32 %46, %45
%48 = select i1 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %4, i8* %48)
%50 = add nuw nsw i32 %45, 1
%51 = icmp eq i32 %50, %1
br i1 %51, label %52, label %44
52: ; preds = %44
%53 = tail call i32 @putchar(i32 10)
br i1 %27, label %59, label %54
54: ; preds = %52, %54
%55 = phi i32 [ %57, %54 ], [ 0, %52 ]
%56 = tail call i32 @putchar(i32 45)
%57 = add nuw i32 %55, 1
%58 = icmp eq i32 %55, %26
br i1 %58, label %59, label %54
59: ; preds = %54, %52
%60 = tail call i32 @putchar(i32 10)
%61 = icmp eq i64 %40, %37
br i1 %61, label %62, label %38
62: ; preds = %59, %33
ret void
}