#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 *, float, float, float);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  FILE *textFile;
  textFile = fopen("number.txt", "w");
  if (textFile == NULL) {
    printf("[ERROR] Can't opening the file.\n");
    return 0;
  }
  float a, b, c;
  printf("Enter the first number: ");
  scanf("%f", &a);
  printf("Enter the second number: ");
  scanf("%f", &b);
  printf("Enter the third number: ");
  scanf("%f", &c);
  fprintf(textFile, "%f\n%f\n%f\n", a, b, c);
  fclose(textFile);
  printf("The content is writing in a file called numbers.txt\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1199 <main+0x49>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1228 <main+0xd8>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe92(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     120a <main+0xaa>
mov    %rax,%rbx
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8d(%rip),%r14
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1070 <scanf@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe5e(%rip),%rdi
jmp    1211 <main+0xb1>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"number.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"[ERROR] Can't opening the file.\0A\00"
@.str.3 = [25 x i8] c"Enter the first number: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [26 x i8] c"Enter the second number: \00"
@.str.6 = [25 x i8] c"Enter the third number: \00"
@.str.7 = [10 x i8] c"%f\0A%f\0A%f\0A\00"
@.str.8 = [53 x i8] c"The content is writing in a file called numbers.txt\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %26
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %4)
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%18 = load i32*, i32** %2
%19 = load float, float* %3
%20 = load float, float* %4
%21 = load float, float* %5
%22 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), float %19, float %20, float %21)
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
br label %26
26: ; preds = %11, %9
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [11 x i8] c"number.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [25 x i8] c"Enter the first number: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [26 x i8] c"Enter the second number: \00"
@.str.6 = [25 x i8] c"Enter the third number: \00"
@.str.7 = [10 x i8] c"%f\0A%f\0A%f\0A\00"
@str = [52 x i8] c"The content is writing in a file called numbers.txt\00"
@str.9 = [32 x i8] c"[ERROR] Can't opening the file.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %24
8: ; preds = %0
%9 = bitcast float* %1 to i8*
%10 = bitcast float* %2 to i8*
%11 = bitcast float* %3 to i8*
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%18 = load float, float* %1
%19 = load float, float* %2
%20 = load float, float* %3
%21 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), float %18, float %19, float %20)
%22 = call i32 @fclose(i32* %4)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %8, %6
ret i32 0
}