#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 algo(char **);
int check_params(int, char **, char *);
int /*<<< orphan*/ display(char **, char);
int /*<<< orphan*/ free_grid(char **);
char **get_grid();
int /*<<< orphan*/ my_putchar(char);
int /*<<< orphan*/ my_puterr(char *);
int /*<<< orphan*/ my_putnchar(char, int);
int main(int ac, char **av) {
  char **grid;
  char color;
  int i;
  if (check_params(ac, av, &color) == -1)
    return (0);
  i = 0;
  while ((grid = get_grid()) != NULL) {
    if (i != 0) {
      my_putnchar('#', 20);
      my_putchar('\n');
    }
    if (algo(grid) == -1)
      my_puterr("The grid is impossible to solve\n");
    display(grid, color);
    free_grid(grid);
    i++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x19(%rbp),%rdx
call   1080 <check_params@plt>
cmp    $0xffffffff,%eax
jne    11bb <main+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1243 <main+0xc3>
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1090 <get_grid@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     123c <main+0xbc>
cmpl   $0x0,-0x20(%rbp)
je     11fa <main+0x7a>
mov    $0x23,%edi
mov    $0x14,%esi
call   1050 <my_putnchar@plt>
mov    $0xa,%edi
call   1070 <my_putchar@plt>
mov    -0x18(%rbp),%rdi
call   1060 <algo@plt>
cmp    $0xffffffff,%eax
jne    1218 <main+0x98>
lea    0xded(%rip),%rdi
call   1030 <my_puterr@plt>
mov    -0x18(%rbp),%rdi
movsbl -0x19(%rbp),%esi
call   1040 <display@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <free_grid@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <main+0x42>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x7(%rsp),%rdx
call   1080 <check_params@plt>
cmp    $0xffffffff,%eax
je     1244 <main+0xc4>
xor    %eax,%eax
call   1090 <get_grid@plt>
test   %rax,%rax
je     1244 <main+0xc4>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <algo@plt>
cmp    $0xffffffff,%eax
jne    11c3 <main+0x43>
lea    0xe42(%rip),%rdi
call   1030 <my_puterr@plt>
movsbl 0x7(%rsp),%esi
mov    %rbx,%rdi
call   1040 <display@plt>
mov    %rbx,%rdi
call   10a0 <free_grid@plt>
xor    %eax,%eax
call   1090 <get_grid@plt>
test   %rax,%rax
je     1244 <main+0xc4>
mov    %rax,%rbx
lea    0xe12(%rip),%r14
jmp    1214 <main+0x94>
movsbl 0x7(%rsp),%esi
mov    %rbx,%rdi
call   1040 <display@plt>
mov    %rbx,%rdi
call   10a0 <free_grid@plt>
xor    %eax,%eax
call   1090 <get_grid@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1244 <main+0xc4>
mov    $0x23,%edi
mov    $0x14,%esi
call   1050 <my_putnchar@plt>
mov    $0xa,%edi
call   1070 <my_putchar@plt>
mov    %rbx,%rdi
call   1060 <algo@plt>
cmp    $0xffffffff,%eax
jne    11f0 <main+0x70>
mov    %r14,%rdi
call   1030 <my_puterr@plt>
jmp    11f0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"The grid is impossible to solve\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @check_params(i32 %9, i8** %10, i8* %7)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %39
14: ; preds = %2
store i32 0, i32* %8
br label %15
15: ; preds = %30, %14
%16 = call i8** (...) @get_grid()
store i8** %16, i8*** %6
%17 = icmp ne i8** %16, null
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %8
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @my_putnchar(i8 signext 35, i32 20)
%23 = call i32 @my_putchar(i8 signext 10)
br label %24
24: ; preds = %21, %18
%25 = load i8**, i8*** %6
%26 = call i32 @algo(i8** %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @my_puterr(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = load i8**, i8*** %6
%32 = load i8, i8* %7
%33 = call i32 @display(i8** %31, i8 signext %32)
%34 = load i8**, i8*** %6
%35 = call i32 @free_grid(i8** %34)
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %15
38: ; preds = %15
store i32 0, i32* %3
br label %39
39: ; preds = %38, %13
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [33 x i8] c"The grid is impossible to solve\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8
%4 = call i32 @check_params(i32 %0, i8** %1, i8* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %34, label %6
6: ; preds = %2
%7 = call i8** (...) @get_grid()
%8 = icmp eq i8** %7, null
br i1 %8, label %34, label %9
9: ; preds = %6
%10 = call i32 @algo(i8** %7)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @my_puterr(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load i8, i8* %3
%16 = call i32 @display(i8** %7, i8 signext %15)
%17 = call i32 @free_grid(i8** %7)
%18 = call i8** (...) @get_grid()
%19 = icmp eq i8** %18, null
br i1 %19, label %34, label %20
20: ; preds = %14, %28
%21 = phi i8** [ %32, %28 ], [ %18, %14 ]
%22 = call i32 @my_putnchar(i8 signext 35, i32 20)
%23 = call i32 @my_putchar(i8 signext 10)
%24 = call i32 @algo(i8** %21)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @my_puterr(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %20
%29 = load i8, i8* %3
%30 = call i32 @display(i8** %21, i8 signext %29)
%31 = call i32 @free_grid(i8** %21)
%32 = call i8** (...) @get_grid()
%33 = icmp eq i8** %32, null
br i1 %33, label %34, label %20
34: ; preds = %28, %14, %6, %2
ret i32 0
}