#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 */
scalar_t__ countries_eslimitrofe(int, int);
int countries_cantlimitrofes(int p) {
  int i;
  int cant = 0;
  if (p < 0 || p >= 50)
    return -1;
  for (i = 0; i < 50; i++) {
    if (countries_eslimitrofe(p, i))
      cant++;
  }
  return cant;
}


x86 assembly (clang, -O0):
<countries_cantlimitrofes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1136 <countries_cantlimitrofes+0x26>
cmpl   $0x32,-0x8(%rbp)
jl     1142 <countries_cantlimitrofes+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    118a <countries_cantlimitrofes+0x7a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x32,-0xc(%rbp)
jge    1184 <countries_cantlimitrofes+0x74>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <countries_eslimitrofe@plt>
cmp    $0x0,%rax
je     1171 <countries_cantlimitrofes+0x61>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1176 <countries_cantlimitrofes+0x66>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <countries_cantlimitrofes+0x39>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countries_cantlimitrofes>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%ebp
cmp    $0x31,%edi
ja     1149 <countries_cantlimitrofes+0x39>
mov    %edi,%r14d
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,%edi
mov    %ebx,%esi
call   1030 <countries_eslimitrofe@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x1,%ebx
cmp    $0x32,%ebx
jne    1130 <countries_cantlimitrofes+0x20>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @countries_cantlimitrofes(i32 %0) {
%2 = icmp ugt i32 %0, 49
br i1 %2, label %12, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %9, %3 ], [ 0, %1 ]
%5 = phi i32 [ %10, %3 ], [ 0, %1 ]
%6 = tail call i64 @countries_eslimitrofe(i32 %0, i32 %5)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i32
%9 = add nuw nsw i32 %4, %8
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, 50
br i1 %11, label %12, label %3
12: ; preds = %3, %1
%13 = phi i32 [ -1, %1 ], [ %9, %3 ]
ret i32 %13
}