#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 match_notes(int, int, int);
int find_first_matching_template_bar(int barnumber, int mnbars, int transpose) {
  int i, dif;
  for (i = 1; i < mnbars; i++) {
    dif = match_notes(i, barnumber, transpose);
    if (dif == 0)
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_first_matching_template_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <find_first_matching_template_bar+0x5d>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <match_notes@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    115a <find_first_matching_template_bar+0x4a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1174 <find_first_matching_template_bar+0x64>
jmp    115f <find_first_matching_template_bar+0x4f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1128 <find_first_matching_template_bar+0x18>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_first_matching_template_bar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xffffffff,%r14d
cmp    $0x2,%esi
jl     114d <find_first_matching_template_bar+0x3d>
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%r12d
mov    $0x1,%ebp
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <match_notes@plt>
test   %eax,%eax
je     114a <find_first_matching_template_bar+0x3a>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1130 <find_first_matching_template_bar+0x20>
jmp    114d <find_first_matching_template_bar+0x3d>
mov    %ebp,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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