#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 */
struct sudoku {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int sudoku_get(struct sudoku *, int, int);
void print_puzzle(int id, const char *label, struct sudoku *S) {
  int i, j, value;
  if (label)
    printf("Grid %d: %s\n", id, label);
  else
    printf("Grid %d\n", id);
  for (i = 0; i < 9; ++i) {
    for (j = 0; j < 9; ++j) {
      value = sudoku_get(S, i, j);
      if (value > 0)
        printf(" %d", value);
      else
        printf(" .");
      if ((j % 3) == (3 - 1))
        printf(" ");
    }
    printf("\n");
    if ((i % 3) == (3 - 1))
      printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_puzzle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1158 <print_puzzle+0x38>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1169 <print_puzzle+0x49>
mov    -0x4(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jge    1243 <print_puzzle+0x123>
movl   $0x0,-0x20(%rbp)
cmpl   $0x9,-0x20(%rbp)
jge    1200 <print_puzzle+0xe0>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <sudoku_get@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11bd <print_puzzle+0x9d>
mov    -0x24(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cb <print_puzzle+0xab>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    11ed <print_puzzle+0xcd>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <print_puzzle+0xd2>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1181 <print_puzzle+0x61>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    1230 <print_puzzle+0x110>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1235 <print_puzzle+0x115>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <print_puzzle+0x50>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_puzzle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%rdx
mov    %edi,%esi
test   %rdx,%rdx
je     1158 <print_puzzle+0x28>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1166 <print_puzzle+0x36>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea9(%rip),%r14
lea    0xea6(%rip),%r15
xor    %r13d,%r13d
jmp    118e <print_puzzle+0x5e>
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    $0x9,%r13d
je     1230 <print_puzzle+0x100>
xor    %ebx,%ebx
jmp    11a8 <print_puzzle+0x78>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x9,%ebx
je     1200 <print_puzzle+0xd0>
movzbl %bl,%eax
imul   $0xab,%eax,%eax
shr    $0x9,%eax
lea    (%rax,%rax,2),%ebp
add    $0x2,%bpl
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1050 <sudoku_get@plt>
test   %eax,%eax
jle    11e0 <print_puzzle+0xb0>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %bl,%bpl
jne    11a0 <print_puzzle+0x70>
jmp    11ef <print_puzzle+0xbf>
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %bl,%bpl
jne    11a0 <print_puzzle+0x70>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11a0 <print_puzzle+0x70>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
imul   $0xaaaaaaab,%r13d,%eax
add    $0xaaaaaaaa,%eax
cmp    $0x55555554,%eax
ja     1180 <print_puzzle+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1180 <print_puzzle+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sudoku = type { i32 }
@.str = [13 x i8] c"Grid %d: %s\0A\00"
@.str.1 = [9 x i8] c"Grid %d\0A\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [3 x i8] c" .\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"\0A\00"
define void @print_puzzle(i32 %0, i8* %1, %struct.sudoku* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.sudoku*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store %struct.sudoku* %2, %struct.sudoku** %6
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %14)
br label %19
16: ; preds = %3
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %12
store i32 0, i32* %7
br label %20
20: ; preds = %57, %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 9
br i1 %22, label %23, label %60
23: ; preds = %20
store i32 0, i32* %8
br label %24
24: ; preds = %46, %23
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 9
br i1 %26, label %27, label %49
27: ; preds = %24
%28 = load %struct.sudoku*, %struct.sudoku** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 @sudoku_get(%struct.sudoku* %28, i32 %29, i32 %30)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = load i32, i32* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %39
37: ; preds = %27
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = load i32, i32* %8
%41 = srem i32 %40, 3
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
br label %46
46: ; preds = %45
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %24
49: ; preds = %24
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32, i32* %7
%52 = srem i32 %51, 3
%53 = icmp eq i32 %52, 2
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
br label %57
57: ; preds = %56
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %20
60: ; preds = %20
ret void
}

LLVM IR (-O2):
%struct.sudoku = type { i32 }
@.str = [13 x i8] c"Grid %d: %s\0A\00"
@.str.1 = [9 x i8] c"Grid %d\0A\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [3 x i8] c" .\00"
define void @print_puzzle(i32 %0, i8* %1, %struct.sudoku* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %1)
br label %9
7: ; preds = %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %7, %5
br label %10
10: ; preds = %9, %35
%11 = phi i32 [ %36, %35 ], [ 0, %9 ]
br label %12
12: ; preds = %10, %26
%13 = phi i32 [ 0, %10 ], [ %27, %26 ]
%14 = tail call i32 @sudoku_get(%struct.sudoku* %2, i32 %11, i32 %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %20
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = trunc i32 %13 to i8
%22 = urem i8 %21, 3
%23 = icmp eq i8 %22, 2
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @putchar(i32 32)
br label %26
26: ; preds = %20, %24
%27 = add nuw nsw i32 %13, 1
%28 = icmp eq i32 %27, 9
br i1 %28, label %29, label %12
29: ; preds = %26
%30 = tail call i32 @putchar(i32 10)
%31 = urem i32 %11, 3
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = tail call i32 @putchar(i32 10)
br label %35
35: ; preds = %29, %33
%36 = add nuw nsw i32 %11, 1
%37 = icmp eq i32 %36, 9
br i1 %37, label %38, label %10
38: ; preds = %35
ret void
}