#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 *, unsigned int, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
unsigned int scanf(char *, ...);
int /*<<< orphan*/ stdin;
void tipo2(void) {
  FILE *file2Ptr;
  unsigned int numeroConto;
  double saldo;
  unsigned int esitoScanf;
  if ((file2Ptr = fopen("FileDelleTransazioni.dat", "w")) == NULL) {
    puts("Non e' stato possibile creare il file2.dat");
  } else {
    printf("File Delle Transazioni:\n");
    printf("%-20s%-20s\n", "Numerdo di conto", "Ammontare in dollari");
    do {
      if ((esitoScanf = scanf("%d %lf", &numeroConto, &saldo)) == 0) {
        scanf("%*[^\n]");
        puts("input non valido");
      }
    } while (esitoScanf == 0);
    while (!feof(stdin)) {
      fprintf(file2Ptr, "%d %.2lf\n", numeroConto, saldo);
      do {
        if ((esitoScanf = scanf("%d %lf", &numeroConto, &saldo)) == 0) {
          scanf("%*[^\n]");
          puts("input non valido");
        }
      } while (esitoScanf == 0);
    }
  }
  fclose(file2Ptr);
  return;
}


x86 assembly (clang, -O0):
<tipo2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11aa <tipo2+0x3a>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
jmp    12b4 <tipo2+0x144>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    0xeaf(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1080 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    1210 <tipo2+0xa0>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
jmp    1215 <tipo2+0xa5>
cmpl   $0x0,-0x1c(%rbp)
je     11d4 <tipo2+0x64>
jmp    1224 <tipo2+0xb4>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1247 <tipo2+0xd7>
jmp    12af <tipo2+0x13f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
lea    0xe56(%rip),%rsi
call   1060 <fprintf@plt>
lea    0xe2b(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1080 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    129b <tipo2+0x12b>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
jmp    12a0 <tipo2+0x130>
cmpl   $0x0,-0x1c(%rbp)
je     125f <tipo2+0xef>
jmp    1224 <tipo2+0xb4>
jmp    12b4 <tipo2+0x144>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tipo2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe7b(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     12b8 <tipo2+0x148>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%rdi
lea    0xe9b(%rip),%rsi
lea    0xea5(%rip),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
test   %eax,%eax
jne    1226 <tipo2+0xb6>
lea    0xe97(%rip),%r14
lea    0xe97(%rip),%r12
lea    0xe82(%rip),%r13
lea    0xc(%rsp),%rbp
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
test   %eax,%eax
je     1200 <tipo2+0x90>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    12c4 <tipo2+0x154>
lea    0xe35(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xe2b(%rip),%rbp
lea    0xe2b(%rip),%r14
jmp    1272 <tipo2+0x102>
nopl   (%rax)
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    12c4 <tipo2+0x154>
mov    0xc(%rsp),%edx
movsd  0x10(%rsp),%xmm0
mov    %r15,%rdi
lea    0xe11(%rip),%rsi
call   1060 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
test   %eax,%eax
jne    1260 <tipo2+0xf0>
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    1290 <tipo2+0x120>
lea    0xd5c(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"FileDelleTransazioni.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [43 x i8] c"Non e' stato possibile creare il file2.dat\00"
@.str.3 = [25 x i8] c"File Delle Transazioni:\0A\00"
@.str.4 = [12 x i8] c"%-20s%-20s\0A\00"
@.str.5 = [17 x i8] c"Numerdo di conto\00"
@.str.6 = [21 x i8] c"Ammontare in dollari\00"
@.str.7 = [7 x i8] c"%d %lf\00"
@.str.8 = [7 x i8] c"%*[^\0A]\00"
@.str.9 = [17 x i8] c"input non valido\00"
@stdin = global i32 0
@.str.10 = [10 x i8] c"%d %.2lf\0A\00"
define void @tipo2() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
%5 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 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 ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %45
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %12
12: ; preds = %19, %9
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %2, double* %3)
store i32 %13, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %12, label %22
22: ; preds = %19
br label %23
23: ; preds = %43, %22
%24 = load i32, i32* @stdin
%25 = call i32 @feof(i32 %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br i1 %27, label %28, label %44
28: ; preds = %23
%29 = load i32*, i32** %1
%30 = load i32, i32* %2
%31 = load double, double* %3
%32 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %30, double %31)
br label %33
33: ; preds = %40, %28
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %2, double* %3)
store i32 %34, i32* %4
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = icmp eq i32 %41, 0
br i1 %42, label %33, label %43
43: ; preds = %40
br label %23
44: ; preds = %23
br label %45
45: ; preds = %44, %7
%46 = load i32*, i32** %1
%47 = call i32 @fclose(i32* %46)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"FileDelleTransazioni.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [43 x i8] c"Non e' stato possibile creare il file2.dat\00"
@.str.4 = [12 x i8] c"%-20s%-20s\0A\00"
@.str.5 = [17 x i8] c"Numerdo di conto\00"
@.str.6 = [21 x i8] c"Ammontare in dollari\00"
@.str.7 = [7 x i8] c"%d %lf\00"
@.str.8 = [7 x i8] c"%*[^\0A]\00"
@.str.9 = [17 x i8] c"input non valido\00"
@stdin = global i32 0
@.str.10 = [10 x i8] c"%d %.2lf\0A\00"
@str = [24 x i8] c"File Delle Transazioni:\00"
define void @tipo2() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %38
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %1, double* %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %18, %9
%15 = load i32, i32* @stdin
%16 = call i32 @feof(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %27, label %38
18: ; preds = %9, %18
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %1, double* %2)
%22 = icmp eq i32 %21, 0
br i1 %22, label %18, label %14
23: ; preds = %33, %27
%24 = load i32, i32* @stdin
%25 = call i32 @feof(i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %14, %23
%28 = load i32, i32* %1
%29 = load double, double* %2
%30 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %28, double %29)
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %1, double* %2)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %23
33: ; preds = %27, %33
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32* %1, double* %2)
%37 = icmp eq i32 %36, 0
br i1 %37, label %33, label %23
38: ; preds = %23, %14, %7
%39 = call i32 @fclose(i32* %5)
ret void
}