#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 fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *my_stream;
  char my_filename[] = "snazzyjazz.txt";
  int close_error;
  my_stream = fopen(my_filename, "w");
  fprintf(my_stream, "Just alittle gello from fprintf.\n");
  close_error = fclose(my_stream);
  if (close_error != 0)
    printf("File could not be closed.\n");
  else
    printf("File closed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x1f(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xea2(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xe9a(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x1f(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11c2 <main+0x82>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
jmp    11ce <main+0x8e>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x7478742e7a7a61,%rax
mov    %rax,0x7(%rsp)
movabs $0x616a797a7a616e73,%rax
79 6a 61
mov    %rax,(%rsp)
lea    0xea6(%rip),%rsi
mov    %rsp,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xe96(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %eax,%eax
lea    0xe95(%rip),%rax
lea    0xe9b(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.my_filename = [15 x i8] c"snazzyjazz.txt\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [34 x i8] c"Just alittle gello from fprintf.\0A\00"
@.str.2 = [27 x i8] c"File could not be closed.\0A\00"
@.str.3 = [14 x i8] c"File closed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [15 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [15 x i8]* %3 to i8*
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32*, i32** %2
%11 = call i32 @fclose(i32* %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
ret i32 0
}

LLVM IR (-O2):
@__const.main.my_filename = [15 x i8] c"snazzyjazz.txt\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [34 x i8] c"Just alittle gello from fprintf.\0A\00"
@str = [13 x i8] c"File closed.\00"
@str.4 = [26 x i8] c"File could not be closed.\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 33, i64 1, i32* %3)
%5 = tail call i32 @fclose(i32* %3)
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
ret i32 0
}