#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 */
size_t to_sudoku_cell(int const);
scalar_t__ to_sudoku_num(int const);
int solve_dlx_sudoku_cb(int nsolution, int *solutions, void *solved_cb_param) {
  char *results = (char *)solved_cb_param;
  for (int solution_i = 0; solution_i < nsolution; ++solution_i) {
    const int dlx_row_index = solutions[solution_i];
    results[to_sudoku_cell(dlx_row_index)] =
        (char)(to_sudoku_num(dlx_row_index) + '1');
  }
  return 1;
}


x86 assembly (clang, -O0):
<solve_dlx_sudoku_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1196 <solve_dlx_sudoku_cb+0x76>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <to_sudoku_num@plt>
add    $0x31,%rax
mov    %al,-0x31(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%edi
call   1030 <to_sudoku_cell@plt>
mov    -0x31(%rbp),%dl
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1142 <solve_dlx_sudoku_cb+0x22>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_dlx_sudoku_cb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1167 <solve_dlx_sudoku_cb+0x47>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%r13d
mov    %r13d,%edi
call   1040 <to_sudoku_num@plt>
mov    %rax,%rbx
add    $0x31,%bl
mov    %r13d,%edi
call   1030 <to_sudoku_cell@plt>
mov    %bl,(%r14,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1140 <solve_dlx_sudoku_cb+0x20>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @solve_dlx_sudoku_cb(i32 %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
store i8* %10, i8** %7
store i32 0, i32* %8
br label %11
11: ; preds = %29, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %32
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = call i64 @to_sudoku_num(i32 %21)
%23 = add nsw i64 %22, 49
%24 = trunc i64 %23 to i8
%25 = load i8*, i8** %7
%26 = load i32, i32* %9
%27 = call i64 @to_sudoku_cell(i32 %26)
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 %24, i8* %28
br label %29
29: ; preds = %15
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %11
32: ; preds = %11
ret i32 1
}

LLVM IR (-O2):
define i32 @solve_dlx_sudoku_cb(i32 %0, i32* nocapture %1, i8* nocapture writeonly %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %0 to i64
br label %8
7: ; preds = %8, %3
ret i32 1
8: ; preds = %5, %8
%9 = phi i64 [ 0, %5 ], [ %17, %8 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = tail call i64 @to_sudoku_num(i32 %11)
%13 = trunc i64 %12 to i8
%14 = add i8 %13, 49
%15 = tail call i64 @to_sudoku_cell(i32 %11)
%16 = getelementptr inbounds i8, i8* %2, i64 %15
store i8 %14, i8* %16
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, %6
br i1 %18, label %7, label %8
}