#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*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, char *, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *, char *, double *);
int /*<<< orphan*/ stdin;
void f(void) {
  FILE *filePtr;
  int accountNum;
  char name[25];
  double currentBalance;
  if ((filePtr = fopen("newmast.dat", "a")) == NULL) {
    puts("file newmast.dat non trovato");
  } else {
    printf("%-10s%-25s%s\n", "Account", "Nome", "Bilancio");
    printf("%s", "EOF per uscire\n? ");
    scanf("%d%24s%lf", &accountNum, name, &currentBalance);
    while (!feof(stdin)) {
      fprintf(filePtr, "%d %s %.2lf\n", accountNum, name, currentBalance);
      printf("%-10d%-25s%.2lf\n", accountNum, name, currentBalance);
      scanf("%d%24s%lf", &accountNum, name, &currentBalance);
    }
  }
  fclose(filePtr);
  return;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe81(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11aa <f+0x3a>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
jmp    1275 <f+0x105>
lea    0xe7a(%rip),%rdi
lea    0xe81(%rip),%rsi
lea    0xe82(%rip),%rdx
lea    0xe80(%rip),%rcx
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe77(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1080 <scanf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    121d <f+0xad>
jmp    1270 <f+0x100>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0x30(%rbp),%rcx
movsd  -0x38(%rbp),%xmm0
lea    0xe3a(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xc(%rbp),%esi
lea    -0x30(%rbp),%rdx
movsd  -0x38(%rbp),%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe06(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1080 <scanf@plt>
jmp    11fa <f+0x8a>
jmp    1275 <f+0x105>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe7b(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1288 <f+0x118>
lea    0xe87(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xe8f(%rip),%rdx
lea    0xe8d(%rip),%rcx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe88(%rip),%rdi
lea    0xe84(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1080 <scanf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    1294 <f+0x124>
lea    0x10(%rsp),%rbx
lea    0xe69(%rip),%r12
lea    0xe4b(%rip),%r13
lea    0x4(%rsp),%rbp
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
lea    0xe2a(%rip),%rsi
mov    %rbx,%rcx
call   1060 <fprintf@plt>
mov    0x4(%rsp),%esi
movsd  0x8(%rsp),%xmm0
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1080 <scanf@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     1230 <f+0xc0>
jmp    1294 <f+0x124>
lea    0xd7f(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"newmast.dat\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [29 x i8] c"file newmast.dat non trovato\00"
@.str.3 = [14 x i8] c"%-10s%-25s%s\0A\00"
@.str.4 = [8 x i8] c"Account\00"
@.str.5 = [5 x i8] c"Nome\00"
@.str.6 = [9 x i8] c"Bilancio\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [18 x i8] c"EOF per uscire\0A? \00"
@.str.9 = [10 x i8] c"%d%24s%lf\00"
@stdin = global i32 0
@.str.10 = [13 x i8] c"%d %s %.2lf\0A\00"
@.str.11 = [17 x i8] c"%-10d%-25s%.2lf\0A\00"
define void @f() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca [25 x i8]
%4 = alloca double
%5 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %32
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%12 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32* %2, i8* %12, double* %4)
br label %14
14: ; preds = %19, %9
%15 = load i32, i32* @stdin
%16 = call i32 @feof(i32 %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = load i32*, i32** %1
%21 = load i32, i32* %2
%22 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%23 = load double, double* %4
%24 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %21, i8* %22, double %23)
%25 = load i32, i32* %2
%26 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%27 = load double, double* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %25, i8* %26, double %27)
%29 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%30 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32* %2, i8* %29, double* %4)
br label %14
31: ; preds = %14
br label %32
32: ; preds = %31, %7
%33 = load i32*, i32** %1
%34 = call i32 @fclose(i32* %33)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"newmast.dat\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [29 x i8] c"file newmast.dat non trovato\00"
@.str.3 = [14 x i8] c"%-10s%-25s%s\0A\00"
@.str.4 = [8 x i8] c"Account\00"
@.str.5 = [5 x i8] c"Nome\00"
@.str.6 = [9 x i8] c"Bilancio\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [18 x i8] c"EOF per uscire\0A? \00"
@.str.9 = [10 x i8] c"%d%24s%lf\00"
@stdin = global i32 0
@.str.10 = [13 x i8] c"%d %s %.2lf\0A\00"
@.str.11 = [17 x i8] c"%-10d%-25s%.2lf\0A\00"
define void @f() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%6 = bitcast double* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %29
11: ; preds = %0
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32* %1, i8* %5, double* %3)
%15 = load i32, i32* @stdin
%16 = call i32 @feof(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %11, %18
%19 = load i32, i32* %1
%20 = load double, double* %3
%21 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %19, i8* %5, double %20)
%22 = load i32, i32* %1
%23 = load double, double* %3
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %22, i8* %5, double %23)
%25 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32* %1, i8* %5, double* %3)
%26 = load i32, i32* @stdin
%27 = call i32 @feof(i32 %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %18, label %29
29: ; preds = %18, %11, %9
%30 = call i32 @fclose(i32* %7)
ret void
}