#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 /*<<< orphan*/ fsleep(double);
scalar_t__ lloyd_bgm_is_playing();
int /*<<< orphan*/ lloyd_bgm_set_fade_in_duration(int);
int /*<<< orphan*/ lloyd_bgm_set_fade_out_duration(int);
int /*<<< orphan*/ lloyd_bgm_start(char *);
int /*<<< orphan*/ lloyd_bgm_stop();
int /*<<< orphan*/ lloyd_close();
int /*<<< orphan*/ lloyd_init();
int /*<<< orphan*/ lloyd_update();
int main() {
  int i = 0;
  lloyd_init();
  lloyd_bgm_set_fade_in_duration(2);
  lloyd_bgm_set_fade_out_duration(2);
  lloyd_bgm_start("bgm0001.ogg");
  while (lloyd_bgm_is_playing()) {
    fsleep(0.01);
    if (++i == 100 * 4) {
      lloyd_bgm_stop();
    }
    lloyd_update();
  }
  lloyd_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1070 <lloyd_init@plt>
mov    $0x2,%edi
call   1050 <lloyd_bgm_set_fade_in_duration@plt>
mov    $0x2,%edi
call   10b0 <lloyd_bgm_set_fade_out_duration@plt>
lea    0xe40(%rip),%rdi
call   10a0 <lloyd_bgm_start@plt>
mov    $0x0,%al
call   1030 <lloyd_bgm_is_playing@plt>
cmp    $0x0,%rax
je     1212 <main+0x82>
movsd  0xe1a(%rip),%xmm0
call   1080 <fsleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x190,%eax
jne    1206 <main+0x76>
mov    $0x0,%al
call   1090 <lloyd_bgm_stop@plt>
mov    $0x0,%al
call   1040 <lloyd_update@plt>
jmp    11cd <main+0x3d>
mov    $0x0,%al
call   1060 <lloyd_close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <lloyd_init@plt>
mov    $0x2,%edi
call   1050 <lloyd_bgm_set_fade_in_duration@plt>
mov    $0x2,%edi
call   10b0 <lloyd_bgm_set_fade_out_duration@plt>
lea    0xe55(%rip),%rdi
call   10a0 <lloyd_bgm_start@plt>
xor    %eax,%eax
call   1030 <lloyd_bgm_is_playing@plt>
test   %rax,%rax
je     11fe <main+0x6e>
mov    $0x18f,%ebx
jmp    11e3 <main+0x53>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <lloyd_update@plt>
xor    %eax,%eax
call   1030 <lloyd_bgm_is_playing@plt>
test   %rax,%rax
je     11fe <main+0x6e>
movsd  0xe15(%rip),%xmm0
call   1080 <fsleep@plt>
sub    $0x1,%ebx
jae    11d0 <main+0x40>
xor    %eax,%eax
call   1090 <lloyd_bgm_stop@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1060 <lloyd_close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"bgm0001.ogg\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (...) @lloyd_init()
%4 = call i32 @lloyd_bgm_set_fade_in_duration(i32 2)
%5 = call i32 @lloyd_bgm_set_fade_out_duration(i32 2)
%6 = call i32 @lloyd_bgm_start(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %17, %0
%8 = call i64 (...) @lloyd_bgm_is_playing()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = call i32 @fsleep(double 1.000000e-02)
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
%14 = icmp eq i32 %13, 400
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 (...) @lloyd_bgm_stop()
br label %17
17: ; preds = %15, %10
%18 = call i32 (...) @lloyd_update()
br label %7
19: ; preds = %7
%20 = call i32 (...) @lloyd_close()
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"bgm0001.ogg\00"
define i32 @main() {
%1 = tail call i32 (...) @lloyd_init()
%2 = tail call i32 @lloyd_bgm_set_fade_in_duration(i32 2)
%3 = tail call i32 @lloyd_bgm_set_fade_out_duration(i32 2)
%4 = tail call i32 @lloyd_bgm_start(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 (...) @lloyd_bgm_is_playing()
%6 = icmp eq i64 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %0, %14
%8 = phi i32 [ %10, %14 ], [ 0, %0 ]
%9 = tail call i32 @fsleep(double 1.000000e-02)
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, 400
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (...) @lloyd_bgm_stop()
br label %14
14: ; preds = %12, %7
%15 = tail call i32 (...) @lloyd_update()
%16 = tail call i64 (...) @lloyd_bgm_is_playing()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %7
18: ; preds = %14, %0
%19 = tail call i32 (...) @lloyd_close()
ret i32 0
}