#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*/ ft_putchar(char);
int test_value(char **, int, int, char);
int backtrack(char **tab, int position) {
  int i;
  int j;
  char n;
  i = (position / 9) + '0';
  j = (position % 9) + '0';
  n = '1';
  if (position == 81)
    return (1);
  if (tab[i][j] != '0')
    return backtrack(tab, position + 1);
  while (n <= '9') {
    if (test_value(tab, i, j, n) == 1) {
      tab[i][j] = n;
      ft_putchar('8');
      if (backtrack(tab, position + 1))
        return (1);
    }
  }
  tab[i][j] = '0';
  return (0);
}


x86 assembly (clang, -O0):
<backtrack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %edx,-0x1c(%rbp)
movb   $0x31,-0x1d(%rbp)
cmpl   $0x51,-0x14(%rbp)
jne    117b <backtrack+0x4b>
movl   $0x1,-0x4(%rbp)
jmp    1246 <backtrack+0x116>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
je     11af <backtrack+0x7f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <backtrack@plt>
mov    %eax,-0x4(%rbp)
jmp    1246 <backtrack+0x116>
jmp    11b4 <backtrack+0x84>
movsbl -0x1d(%rbp),%eax
cmp    $0x39,%eax
jg     122b <backtrack+0xfb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
movsbl -0x1d(%rbp),%ecx
call   1030 <test_value@plt>
cmp    $0x1,%eax
jne    1226 <backtrack+0xf6>
mov    -0x1d(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    $0x38,%edi
call   1050 <ft_putchar@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <backtrack@plt>
cmp    $0x0,%eax
je     1221 <backtrack+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1246 <backtrack+0x116>
jmp    1226 <backtrack+0xf6>
jmp    11b4 <backtrack+0x84>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backtrack>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x51,%esi
jne    113c <backtrack+0x1c>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%r14d
mov    %rdi,%r15
jmp    115a <backtrack+0x3a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14d
cmp    $0x51,%r14d
je     112c <backtrack+0xc>
movslq %r14d,%rax
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
movslq %ecx,%rbp
lea    0x0(%rbp,%rbp,8),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x30,%ebx
mov    0x180(%r15,%rbp,8),%rax
cmpb   $0x30,(%rax,%rbx,1)
jne    1150 <backtrack+0x30>
add    $0x30,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    $0x31,%ecx
call   1030 <test_value@plt>
cmp    $0x1,%eax
jne    11a0 <backtrack+0x80>
mov    (%r15,%rbp,8),%rax
movb   $0x31,(%rax,%rbx,1)
mov    $0x38,%edi
call   1040 <ft_putchar@plt>
jmp    1150 <backtrack+0x30>

LLVM IR (-O0):
define i32 @backtrack(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i8** %0, i8*** %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
%10 = sdiv i32 %9, 9
%11 = add nsw i32 %10, 48
store i32 %11, i32* %6
%12 = load i32, i32* %5
%13 = srem i32 %12, 9
%14 = add nsw i32 %13, 48
store i32 %14, i32* %7
store i8 49, i8* %8
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 81
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 1, i32* %3
br label %75
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 48
br i1 %29, label %30, label %35
30: ; preds = %18
%31 = load i8**, i8*** %4
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = call i32 @backtrack(i8** %31, i32 %33)
store i32 %34, i32* %3
br label %75
35: ; preds = %18
br label %36
36: ; preds = %65, %35
%37 = load i8, i8* %8
%38 = sext i8 %37 to i32
%39 = icmp sle i32 %38, 57
br i1 %39, label %40, label %66
40: ; preds = %36
%41 = load i8**, i8*** %4
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = load i8, i8* %8
%45 = call i32 @test_value(i8** %41, i32 %42, i32 %43, i8 signext %44)
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %65
47: ; preds = %40
%48 = load i8, i8* %8
%49 = load i8**, i8*** %4
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 %48, i8* %56
%57 = call i32 @ft_putchar(i8 signext 56)
%58 = load i8**, i8*** %4
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
%61 = call i32 @backtrack(i8** %58, i32 %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %47
store i32 1, i32* %3
br label %75
64: ; preds = %47
br label %65
65: ; preds = %64, %40
br label %36
66: ; preds = %36
%67 = load i8**, i8*** %4
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = load i32, i32* %7
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 48, i8* %74
store i32 0, i32* %3
br label %75
75: ; preds = %66, %63, %30, %17
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
define i32 @backtrack(i8** %0, i32 %1) {
%3 = icmp eq i32 %1, 81
br i1 %3, label %27, label %4
4: ; preds = %2, %17
%5 = phi i32 [ %18, %17 ], [ %1, %2 ]
%6 = sdiv i32 %5, 9
%7 = add nsw i32 %6, 48
%8 = srem i32 %5, 9
%9 = add nsw i32 %8, 48
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds i8*, i8** %0, i64 %10
%12 = load i8*, i8** %11
%13 = zext i32 %9 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 48
br i1 %16, label %20, label %17
17: ; preds = %4, %23
%18 = add nsw i32 %5, 1
%19 = icmp eq i32 %18, 81
br i1 %19, label %27, label %4
20: ; preds = %4, %20
%21 = tail call i32 @test_value(i8** %0, i32 %7, i32 %9, i8 signext 49)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %20
23: ; preds = %20
%24 = load i8*, i8** %11
%25 = getelementptr inbounds i8, i8* %24, i64 %13
store i8 49, i8* %25
%26 = tail call i32 @ft_putchar(i8 signext 56)
br label %17
27: ; preds = %17, %2
ret i32 1
}