#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *fp;
  int rating = 9;
  if (fp = fopen("d:/website.txt", "w")) {
    fprintf(fp, "WWW\n");
    fprintf(fp, "Topic: computer programming\n");
    fprintf(fp, "Rating out of 10 : %d \n", rating);
    fclose(fp);
  } else
    printf("Error opening d:/website.txt\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x9,-0x14(%rbp)
lea    0xea3(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11be <main+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11ca <main+0x8a>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xef2(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11be <main+0x6e>
mov    %rax,%rbx
lea    0xe8f(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
lea    0xe7b(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11ca <main+0x7a>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"d:/website.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"WWW\0A\00"
@.str.3 = [29 x i8] c"Topic: computer programming\0A\00"
@.str.4 = [24 x i8] c"Rating out of 10 : %d \0A\00"
@.str.5 = [30 x i8] c"Error opening d:/website.txt\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
store i32 9, i32* %3
%4 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = load i32*, i32** %2
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %2
%15 = call i32 @fclose(i32* %14)
br label %18
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %16, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"d:/website.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"WWW\0A\00"
@.str.3 = [29 x i8] c"Topic: computer programming\0A\00"
@.str.4 = [24 x i8] c"Rating out of 10 : %d \0A\00"
@str = [29 x i8] c"Error opening d:/website.txt\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 4, i64 1, i32* %1)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 28, i64 1, i32* %1)
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 9)
%7 = tail call i32 @fclose(i32* %1)
br label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
ret i32 0
}