#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("?");
    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    1242 <main+0xe2>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe8b(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1070 <scanf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f4 <main+0x94>
jmp    1239 <main+0xd9>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    -0x30(%rbp),%rcx
movsd  -0x38(%rbp),%xmm0
lea    0xe4c(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe28(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1070 <scanf@plt>
jmp    11d1 <main+0x71>
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     124f <main+0xdf>
mov    %rax,%r15
lea    0xe7e(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3f,%edi
call   1030 <putchar@plt>
lea    0xe54(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1080 <scanf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    1245 <main+0xd5>
lea    0xe2f(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe1b(%rip),%r12
lea    0x4(%rsp),%r13
lea    0x8(%rsp),%rbp
nopl   (%rax)
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
call   1060 <fprintf@plt>
mov    $0x3f,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1080 <scanf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     1200 <main+0x90>
mov    %r15,%rdi
call   1050 <fclose@plt>
jmp    125b <main+0xeb>
lea    0xdf0(%rip),%rdi
call   1040 <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 = [37 x i8] c"Enter the account,name,and balance.\0A\00"
@.str.4 = [2 x i8] c"?\00"
@.str.5 = [8 x i8] c"%d%s%lf\00"
@stdin = global i32 0
@.str.6 = [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 %32
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* %2, i8* %13, double* %4)
br label %15
15: ; preds = %20, %10
%16 = load i32, i32* @stdin
%17 = call i32 @feof(i32 %16)
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = load i32*, i32** %5
%22 = load i32, i32* %2
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%24 = load double, double* %4
%25 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %22, i8* %23, double %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%28 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* %2, i8* %27, double* %4)
br label %15
29: ; preds = %15
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
br label %32
32: ; preds = %29, %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 = [8 x i8] c"%d%s%lf\00"
@stdin = global i32 0
@.str.6 = [12 x i8] c"%d %s %.2f\0A\00"
@str = [36 x i8] c"Enter the account,name,and balance.\00"
@str.7 = [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.7, i64 0, i64 0))
br label %29
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @putchar(i32 63)
%14 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, 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 %27
18: ; preds = %11, %18
%19 = load i32, i32* %1
%20 = load double, double* %3
%21 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %19, i8* %5, double %20)
%22 = call i32 @putchar(i32 63)
%23 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* %1, i8* %5, double* %3)
%24 = load i32, i32* @stdin
%25 = call i32 @feof(i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %18, label %27
27: ; preds = %18, %11
%28 = call i32 @fclose(i32* %7)
br label %29
29: ; preds = %27, %9
ret i32 0
}