#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *curs_get_default_abandoned_filename(char *name) {
  FILE *fp;
  fp = fopen(".mp3edit_abandonded_name", "rb");
  if (!fp) {
    return NULL;
  }
  fgets(name, 1024, fp);
  fclose(fp);
  return name;
}


x86 assembly (clang, -O0):
<curs_get_default_abandoned_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116b <curs_get_default_abandoned_filename+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    118e <curs_get_default_abandoned_filename+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curs_get_default_abandoned_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     116c <curs_get_default_abandoned_filename+0x3c>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    116f <curs_get_default_abandoned_filename+0x3f>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c".mp3edit_abandonded_name\00"
@.str.1 = [3 x i8] c"rb\00"
define i8* @curs_get_default_abandoned_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
%6 = load i32*, i32** %4
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i8* null, i8** %2
br label %16
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i32*, i32** %4
%12 = call i32 @fgets(i8* %10, i32 1024, i32* %11)
%13 = load i32*, i32** %4
%14 = call i32 @fclose(i32* %13)
%15 = load i8*, i8** %3
store i8* %15, i8** %2
br label %16
16: ; preds = %9, %8
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@.str = [25 x i8] c".mp3edit_abandonded_name\00"
@.str.1 = [3 x i8] c"rb\00"
define i8* @curs_get_default_abandoned_filename(i8* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @fgets(i8* %0, i32 1024, i32* %2)
%6 = tail call i32 @fclose(i32* %2)
br label %7
7: ; preds = %1, %4
%8 = phi i8* [ %0, %4 ], [ null, %1 ]
ret i8* %8
}