#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 song_get_song_list_scene(int);
int seq_engine_song_mode_find_next_scene(int current_entry) {
  int i;
  for (i = (current_entry + 1); i < 64; i++) {
    if (song_get_song_list_scene(i) != -1) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<seq_engine_song_mode_find_next_scene>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x40,-0xc(%rbp)
jge    115d <seq_engine_song_mode_find_next_scene+0x4d>
mov    -0xc(%rbp),%edi
call   1030 <song_get_song_list_scene@plt>
cmp    $0xffffffff,%eax
je     114a <seq_engine_song_mode_find_next_scene+0x3a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <seq_engine_song_mode_find_next_scene+0x54>
jmp    114f <seq_engine_song_mode_find_next_scene+0x3f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1124 <seq_engine_song_mode_find_next_scene+0x14>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_engine_song_mode_find_next_scene>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x40,%edi
mov    $0x3f,%ebp
cmovge %edi,%ebp
cmp    %ebx,%ebp
je     1135 <seq_engine_song_mode_find_next_scene+0x25>
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <song_get_song_list_scene@plt>
cmp    $0xffffffff,%eax
je     1120 <seq_engine_song_mode_find_next_scene+0x10>
jmp    113a <seq_engine_song_mode_find_next_scene+0x2a>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @seq_engine_song_mode_find_next_scene(i32 %0) {
%2 = call i32 @llvm.smax.i32(i32 %0, i32 63)
br label %3
3: ; preds = %7, %1
%4 = phi i32 [ %0, %1 ], [ %5, %7 ]
%5 = add i32 %4, 1
%6 = icmp eq i32 %4, %2
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @song_get_song_list_scene(i32 %5)
%9 = icmp eq i32 %8, -1
br i1 %9, label %3, label %10
10: ; preds = %3, %7
%11 = phi i32 [ %5, %7 ], [ -1, %3 ]
ret i32 %11
}