#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 /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
int main() {
  FILE *fp;
  fp = fopen("file.txt", "w+");
  fputs("Linkerist\n", fp);
  fputs("Heracles\n", fp);
  fclose(fp);
  fputs("Linkerist", stdout);
  fputs("Heracles\n", stdout);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeab(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x10(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%rsi
lea    0xe91(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%rsi
lea    0xe71(%rip),%rdi
call   1040 <fputs@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
lea    0xebb(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1050 <fwrite@plt>
lea    0xead(%rip),%r14
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2e52(%rip),%rbx
mov    (%rbx),%rcx
lea    0xe89(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%rbx),%rcx
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rdi
call   1050 <fwrite@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [11 x i8] c"Linkerist\0A\00"
@.str.3 = [10 x i8] c"Heracles\0A\00"
@.str.4 = [10 x i8] c"Linkerist\00"
@stdout = global i32* null
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%6 = load i32*, i32** %2
%7 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%8 = load i32*, i32** %2
%9 = call i32 @fclose(i32* %8)
%10 = load i32*, i32** @stdout
%11 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %10)
%12 = load i32*, i32** @stdout
%13 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* %12)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [11 x i8] c"Linkerist\0A\00"
@.str.3 = [10 x i8] c"Heracles\0A\00"
@.str.4 = [10 x i8] c"Linkerist\00"
@stdout = global i32* null
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 10, i64 1, i32* %1)
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 9, i64 1, i32* %1)
%4 = tail call i32 @fclose(i32* %1)
%5 = load i32*, i32** @stdout
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 9, i64 1, i32* %5)
%7 = load i32*, i32** @stdout
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 9, i64 1, i32* %7)
ret i32 0
}