#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 */
char get_cell(int, int);
int nb_of_cases(char player) {
  int cpt = 0;
  int i, j;
  for (i = 0; i < 25; i++) {
    for (j = 0; j < 25; j++) {
      if (get_cell(i, j) == player) {
        cpt++;
      }
    }
  }
  return cpt;
}


x86 assembly (clang, -O0):
<nb_of_cases>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    1190 <nb_of_cases+0x80>
movl   $0x0,-0x10(%rbp)
cmpl   $0x19,-0x10(%rbp)
jge    117d <nb_of_cases+0x6d>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <get_cell@plt>
movsbl %al,%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jne    116a <nb_of_cases+0x5a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <nb_of_cases+0x5f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <nb_of_cases+0x2d>
jmp    1182 <nb_of_cases+0x72>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112c <nb_of_cases+0x1c>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nb_of_cases>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xor    %r15d,%r15d
xor    %ebx,%ebx
nop
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %ebp,%esi
call   1030 <get_cell@plt>
xor    %ecx,%ecx
cmp    %r14b,%al
sete   %cl
add    %ecx,%ebx
add    $0x1,%ebp
cmp    $0x19,%ebp
jne    1130 <nb_of_cases+0x20>
add    $0x1,%r15d
cmp    $0x19,%r15d
jne    1120 <nb_of_cases+0x10>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @nb_of_cases(i8 signext %0) {
br label %2
2: ; preds = %1, %14
%3 = phi i32 [ 0, %1 ], [ %15, %14 ]
%4 = phi i32 [ 0, %1 ], [ %11, %14 ]
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 0, %2 ], [ %12, %5 ]
%7 = phi i32 [ %4, %2 ], [ %11, %5 ]
%8 = tail call signext i8 @get_cell(i32 %3, i32 %6)
%9 = icmp eq i8 %8, %0
%10 = zext i1 %9 to i32
%11 = add nsw i32 %7, %10
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %12, 25
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = add nuw nsw i32 %3, 1
%16 = icmp eq i32 %15, 25
br i1 %16, label %17, label %2
17: ; preds = %14
ret i32 %11
}