#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*/ scanf(char *, int *, char *, double *);
int /*<<< orphan*/ stdin;
int main(void) {
  int account;
  char name[30];
  double balance;
  FILE *cfPtr;
  if ((cfPtr = fopen("clients.dat", "w")) == NULL) {
    printf("File could not be opened\n");
  } else {
    printf("Enter the account, name, and balance.\n");
    printf("Enter EOF to end input.\n");
    printf("? ");
    scanf("%d%s%lf", &account, name, &balance);
    while (!feof(stdin)) {
      fprintf(cfPtr, "%d %s %.2f\n", account, name, balance);
      printf("? ");
      scanf("%d%s%lf", &account, name, &balance);
    }
    fclose(cfPtr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    11a1 <main+0x41>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
jmp    124e <main+0xee>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe9b(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1070 <scanf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1200 <main+0xa0>
jmp    1245 <main+0xe5>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    -0x30(%rbp),%rcx
movsd  -0x38(%rbp),%xmm0
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe38(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1070 <scanf@plt>
jmp    11dd <main+0x7d>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
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>
test   %rax,%rax
je     1261 <main+0xf1>
mov    %rax,%r15
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
lea    0xe49(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1080 <scanf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    1257 <main+0xe7>
lea    0x10(%rsp),%rbx
lea    0xe14(%rip),%r12
lea    0xe10(%rip),%r13
lea    0x4(%rsp),%rbp
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
lea    0xdf5(%rip),%rsi
mov    %rbx,%rcx
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1080 <scanf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     1210 <main+0xa0>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    126d <main+0xfd>
lea    0xdfb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"clients.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [26 x i8] c"File could not be opened\0A\00"
@.str.3 = [39 x i8] c"Enter the account, name, and balance.\0A\00"
@.str.4 = [25 x i8] c"Enter EOF to end input.\0A\00"
@.str.5 = [3 x i8] c"? \00"
@.str.6 = [8 x i8] c"%d%s%lf\00"
@stdin = global i32 0
@.str.7 = [12 x i8] c"%d %s %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [30 x i8]
%4 = alloca double
%5 = alloca i32*
store i32 0, i32* %1
%6 = 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* %6, i32** %5
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %33
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32* %2, i8* %14, double* %4)
br label %16
16: ; preds = %21, %10
%17 = load i32, i32* @stdin
%18 = call i32 @feof(i32 %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %30
21: ; preds = %16
%22 = load i32*, i32** %5
%23 = load i32, i32* %2
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%25 = load double, double* %4
%26 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %23, i8* %24, double %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%29 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32* %2, i8* %28, double* %4)
br label %16
30: ; preds = %16
%31 = load i32*, i32** %5
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %30, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"clients.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.5 = [3 x i8] c"? \00"
@.str.6 = [8 x i8] c"%d%s%lf\00"
@stdin = global i32 0
@.str.7 = [12 x i8] c"%d %s %.2f\0A\00"
@str = [38 x i8] c"Enter the account, name, and balance.\00"
@str.8 = [24 x i8] c"Enter EOF to end input.\00"
@str.9 = [25 x i8] c"File could not be opened\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [30 x i8], [30 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 ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %30
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0))
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32* %1, i8* %5, double* %3)
%16 = load i32, i32* @stdin
%17 = call i32 @feof(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %11, %19
%20 = load i32, i32* %1
%21 = load double, double* %3
%22 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %20, i8* %5, double %21)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32* %1, i8* %5, double* %3)
%25 = load i32, i32* @stdin
%26 = call i32 @feof(i32 %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %19, label %28
28: ; preds = %19, %11
%29 = call i32 @fclose(i32* %7)
br label %30
30: ; preds = %28, %9
ret i32 0
}