#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, char *,
                           double);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, unsigned int *, char *, double *);
int /*<<< orphan*/ stdin;
int main(void) {
  unsigned int account;
  char name[30];
  double balance;
  FILE *cfPtr;
  if ((cfPtr = fopen("clients.dat", "w")) == NULL) {
    puts("File could not be opened");
  } else {
    puts("Enter the account, name, and balance.");
    puts("Enter EOF to end input.");
    printf("%s", "? ");
    scanf("%d%29s%lf", &account, name, &balance);
    while (!feof(stdin)) {
      fprintf(cfPtr, "%d %s %.2f\n", account, name, balance);
      printf("%s", "? ");
      scanf("%d%29s%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    0xe7a(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    11b1 <main+0x41>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
jmp    126c <main+0xfc>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe84(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1080 <scanf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1217 <main+0xa7>
jmp    1263 <main+0xf3>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    -0x30(%rbp),%rcx
movsd  -0x38(%rbp),%xmm0
lea    0xe47(%rip),%rsi
call   1060 <fprintf@plt>
lea    0xe2b(%rip),%rdi
lea    0xe27(%rip),%rsi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe1a(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1080 <scanf@plt>
jmp    11f4 <main+0x84>
mov    -0x40(%rbp),%rdi
call   1040 <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     1278 <main+0x108>
mov    %rax,%r15
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1080 <scanf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    126e <main+0xfe>
lea    0x10(%rsp),%rbx
lea    0xe67(%rip),%r13
lea    0xe63(%rip),%rbp
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
lea    0xe41(%rip),%rsi
mov    %rbx,%rcx
call   1060 <fprintf@plt>
lea    0xe22(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1080 <scanf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     1220 <main+0xb0>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1284 <main+0x114>
lea    0xd8f(%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 = [25 x i8] c"File could not be opened\00"
@.str.3 = [38 x i8] c"Enter the account, name, and balance.\00"
@.str.4 = [24 x i8] c"Enter EOF to end input.\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [3 x i8] c"? \00"
@.str.7 = [10 x i8] c"%d%29s%lf\00"
@stdin = global i32 0
@.str.8 = [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 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %33
10: ; preds = %0
%11 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 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), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, 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 ([10 x i8], [10 x i8]* @.str.7, 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.8, 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), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, 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 ([10 x i8], [10 x i8]* @.str.7, 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.2 = [25 x i8] c"File could not be opened\00"
@.str.3 = [38 x i8] c"Enter the account, name, and balance.\00"
@.str.4 = [24 x i8] c"Enter EOF to end input.\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [3 x i8] c"? \00"
@.str.7 = [10 x i8] c"%d%29s%lf\00"
@stdin = global i32 0
@.str.8 = [12 x i8] c"%d %s %.2f\0A\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.2, 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.3, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, 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.8, i64 0, i64 0), i32 %20, i8* %5, double %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, 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
}