#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 */
struct MusicList {
  int dummy;
};
struct Music {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ add_music_to_musicList(struct MusicList *, struct Music *);
struct Music *create_music(char *, char *);
struct MusicList *create_musicList();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
struct MusicList *load_fmList(const char *path) {
  FILE *fp;
  char fmPath[256];
  char fmName[256];
  struct MusicList *musicList = create_musicList();
  if ((fp = fopen(path, "r")) == NULL)
    return musicList;
  while (!feof(fp)) {
    fscanf(fp, "%[^,],%s\n", fmName, fmPath);
    struct Music *music = create_music(fmPath, fmName);
    add_music_to_musicList(musicList, music);
  }
  fclose(fp);
  return musicList;
}


x86 assembly (clang, -O0):
<load_fmList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <create_musicList@plt>
mov    %rax,-0x228(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bb <load_fmList+0x4b>
mov    -0x228(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1242 <load_fmList+0xd2>
jmp    11c0 <load_fmList+0x50>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11de <load_fmList+0x6e>
jmp    122e <load_fmList+0xbe>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe0b(%rip),%rsi
call   1050 <fscanf@plt>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1070 <create_music@plt>
mov    %rax,-0x230(%rbp)
mov    -0x228(%rbp),%rdi
mov    -0x230(%rbp),%rsi
call   1080 <add_music_to_musicList@plt>
jmp    11c0 <load_fmList+0x50>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x228(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_fmList>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <create_musicList@plt>
mov    %rax,%r14
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     120b <load_fmList+0x9b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1203 <load_fmList+0x93>
lea    0xe4b(%rip),%r15
mov    %rsp,%r12
lea    0x100(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1050 <fscanf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <create_music@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1080 <add_music_to_musicList@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11d0 <load_fmList+0x60>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.MusicList = type { i32 }
%struct.Music = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"%[^,],%s\0A\00"
define %struct.MusicList* @load_fmList(i8* %0) {
%2 = alloca %struct.MusicList*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca %struct.MusicList*
%8 = alloca %struct.Music*
store i8* %0, i8** %3
%9 = call %struct.MusicList* (...) @create_musicList()
store %struct.MusicList* %9, %struct.MusicList** %7
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %4
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load %struct.MusicList*, %struct.MusicList** %7
store %struct.MusicList* %14, %struct.MusicList** %2
br label %36
15: ; preds = %1
br label %16
16: ; preds = %21, %15
%17 = load i32*, i32** %4
%18 = call i32 @feof(i32* %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %32
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%25 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%28 = call %struct.Music* @create_music(i8* %26, i8* %27)
store %struct.Music* %28, %struct.Music** %8
%29 = load %struct.MusicList*, %struct.MusicList** %7
%30 = load %struct.Music*, %struct.Music** %8
%31 = call i32 @add_music_to_musicList(%struct.MusicList* %29, %struct.Music* %30)
br label %16
32: ; preds = %16
%33 = load i32*, i32** %4
%34 = call i32 @fclose(i32* %33)
%35 = load %struct.MusicList*, %struct.MusicList** %7
store %struct.MusicList* %35, %struct.MusicList** %2
br label %36
36: ; preds = %32, %13
%37 = load %struct.MusicList*, %struct.MusicList** %2
ret %struct.MusicList* %37
}

LLVM IR (-O2):
%struct.MusicList = type { i32 }
%struct.Music = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"%[^,],%s\0A\00"
define %struct.MusicList* @load_fmList(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = tail call %struct.MusicList* (...) @create_musicList()
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %20, label %9
9: ; preds = %1
%10 = call i32 @feof(i32* %7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9, %12
%13 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %4)
%14 = call %struct.Music* @create_music(i8* %4, i8* %5)
%15 = call i32 @add_music_to_musicList(%struct.MusicList* %6, %struct.Music* %14)
%16 = call i32 @feof(i32* %7)
%17 = icmp eq i32 %16, 0
br i1 %17, label %12, label %18
18: ; preds = %12, %9
%19 = call i32 @fclose(i32* %7)
br label %20
20: ; preds = %1, %18
ret %struct.MusicList* %6
}