#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, int *, ...);
int main(int argc, char const *argv[]) {
  int account;
  char name[30];
  double balance;
  double amount;
  FILE *ofPtr;
  FILE *tfPtr;
  ofPtr = fopen("oldmast.dat", "w");
  tfPtr = fopen("trans.dat", "w");
  printf("Sample data for file oldmast.dat:\n");
  printf("Enter account,name,and balance (EOF to end):");
  while (scanf("%d%[^0-9-]%lf", &account, name, &balance) != EOF) {
    fprintf(ofPtr, "%d %s %.2f\n", account, name, balance);
    printf("Enter account,name,and balance (EOF to end):");
  }
  fclose(ofPtr);
  printf("\nSample data for file trans.dat:\n");
  printf("Enter account,name,and balance (EOF to end):");
  while (scanf("%d%lf", &account, &amount) != EOF) {
    fprintf(tfPtr, "%d %.2f\n", account, amount);
    printf("Enter account,name,and balance (EOF to end):");
  }
  fclose(tfPtr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x60(%rbp)
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdx
lea    0xeb1(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x48(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2e1b(%rip),%rcx
cmp    (%rcx),%rax
je     1205 <main+0xb5>
mov    -0x58(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    -0x40(%rbp),%rcx
movsd  -0x48(%rbp),%xmm0
lea    0xe89(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
jmp    11ac <main+0x5c>
mov    -0x58(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2da5(%rip),%rcx
cmp    (%rcx),%rax
je     1277 <main+0x127>
mov    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%edx
movsd  -0x50(%rbp),%xmm0
lea    0xe4b(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
jmp    1226 <main+0xd6>
mov    -0x60(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe8b(%rip),%rdi
lea    0xe90(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,0x18(%rsp)
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x2e11(%rip),%rcx
cmp    (%rcx),%rax
je     1245 <main+0xe5>
lea    0x20(%rsp),%rbx
lea    0xe30(%rip),%r13
lea    0xe56(%rip),%rbp
lea    0x4(%rsp),%r14
lea    0x10(%rsp),%r15
nopl   0x0(%rax)
mov    0x4(%rsp),%edx
movsd  0x10(%rsp),%xmm0
mov    %r12,%rdi
lea    0xe3f(%rip),%rsi
mov    %rbx,%rcx
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%rax
jne    1200 <main+0xa0>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
lea    0xdf3(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x2d64(%rip),%r14
cmp    (%r14),%rax
mov    0x18(%rsp),%rbp
je     12e8 <main+0x188>
lea    0xd83(%rip),%r15
lea    0xdc3(%rip),%r12
lea    0x4(%rsp),%r13
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
mov    %rbp,%rdi
lea    0xda1(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    (%r14),%rax
jne    12b0 <main+0x150>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"oldmast.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"trans.dat\00"
@.str.3 = [35 x i8] c"Sample data for file oldmast.dat:\0A\00"
@.str.4 = [45 x i8] c"Enter account,name,and balance (EOF to end):\00"
@.str.5 = [14 x i8] c"%d%[^0-9-]%lf\00"
@EOF = global i64 0
@.str.6 = [12 x i8] c"%d %s %.2f\0A\00"
@.str.7 = [34 x i8] c"\0ASample data for file trans.dat:\0A\00"
@.str.8 = [6 x i8] c"%d%lf\00"
@.str.9 = [9 x i8] c"%d %.2f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [30 x i8]
%8 = alloca double
%9 = alloca double
%10 = alloca i32*
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = 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* %12, i32** %10
%13 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %11
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %21, %2
%17 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%18 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32* %6, i8* %17, double* %8)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load i32*, i32** %10
%23 = load i32, i32* %6
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%25 = load double, double* %8
%26 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %23, i8* %24, double %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %16
28: ; preds = %16
%29 = load i32*, i32** %10
%30 = call i32 @fclose(i32* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %37, %28
%34 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %6, double* %9)
%35 = load i64, i64* @EOF
%36 = icmp ne i64 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i32*, i32** %11
%39 = load i32, i32* %6
%40 = load double, double* %9
%41 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %39, double %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %33
43: ; preds = %33
%44 = load i32*, i32** %11
%45 = call i32 @fclose(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"oldmast.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"trans.dat\00"
@.str.4 = [45 x i8] c"Enter account,name,and balance (EOF to end):\00"
@.str.5 = [14 x i8] c"%d%[^0-9-]%lf\00"
@EOF = global i64 0
@.str.6 = [12 x i8] c"%d %s %.2f\0A\00"
@.str.8 = [6 x i8] c"%d%lf\00"
@.str.9 = [9 x i8] c"%d %.2f\0A\00"
@str = [34 x i8] c"Sample data for file oldmast.dat:\00"
@str.10 = [33 x i8] c"\0ASample data for file trans.dat:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [30 x i8]
%5 = alloca double
%6 = alloca double
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = 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))
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%15 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32* %3, i8* %8, double* %5)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %26, label %18
18: ; preds = %2, %18
%19 = load i32, i32* %3
%20 = load double, double* %5
%21 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %19, i8* %8, double %20)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%23 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32* %3, i8* %8, double* %5)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %18
26: ; preds = %18, %2
%27 = call i32 @fclose(i32* %11)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.10, i64 0, i64 0))
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%30 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %3, double* %6)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %41, label %33
33: ; preds = %26, %33
%34 = load i32, i32* %3
%35 = load double, double* %6
%36 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %34, double %35)
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%38 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %3, double* %6)
%39 = load i64, i64* @EOF
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %33
41: ; preds = %33, %26
%42 = call i32 @fclose(i32* %12)
ret i32 0
}