#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*/ *fopen(char *, char *);
int fputs(char *, int /*<<< orphan*/ *);
int curs_put_default_abandoned_filename(char *name) {
  FILE *fp;
  int sts;
  fp = fopen(".mp3edit_abandonded_name", "wb");
  if (!fp) {
    return 1;
  }
  sts = fputs(name, fp);
  fclose(fp);
  return sts;
}


x86 assembly (clang, -O0):
<curs_put_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    116a <curs_put_default_abandoned_filename+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    1189 <curs_put_default_abandoned_filename+0x59>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fputs@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curs_put_default_abandoned_filename>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     116b <curs_put_default_abandoned_filename+0x3b>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
jmp    1170 <curs_put_default_abandoned_filename+0x40>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c".mp3edit_abandonded_name\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @curs_put_default_abandoned_filename(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
%6 = 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* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 1, i32* %2
br label %17
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i32*, i32** %4
%13 = call i32 @fputs(i8* %11, i32* %12)
store i32 %13, i32* %5
%14 = load i32*, i32** %4
%15 = call i32 @fclose(i32* %14)
%16 = load i32, i32* %5
store i32 %16, i32* %2
br label %17
17: ; preds = %10, %9
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [25 x i8] c".mp3edit_abandonded_name\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @curs_put_default_abandoned_filename(i8* nocapture %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 @fputs(i8* %0, i32* %2)
%6 = tail call i32 @fclose(i32* %2)
br label %7
7: ; preds = %1, %4
%8 = phi i32 [ %5, %4 ], [ 1, %1 ]
ret i32 %8
}