#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
scalar_t__ is_irrelevant(int /*<<< orphan*/, int, int);
int num_relevant_variables(uint32_t rn, int rank) {
  register int rel_vars;
  register int i;
  rel_vars = rank;
  for (i = 0; i < rank; i++)
    if (is_irrelevant(rn, rank, i))
      rel_vars--;
  return rel_vars;
}


x86 assembly (clang, -O0):
<num_relevant_variables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    116b <num_relevant_variables+0x5b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <is_irrelevant@plt>
cmp    $0x0,%rax
je     1158 <num_relevant_variables+0x48>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <num_relevant_variables+0x4d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112b <num_relevant_variables+0x1b>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_relevant_variables>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
test   %esi,%esi
jle    114e <num_relevant_variables+0x3e>
mov    %edi,%r14d
xor    %ebp,%ebp
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <is_irrelevant@plt>
cmp    $0x1,%rax
adc    $0xffffffff,%ebx
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1130 <num_relevant_variables+0x20>
jmp    1151 <num_relevant_variables+0x41>
mov    %r15d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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