#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*/ EXIT_FAILURE;
int /*<<< orphan*/ LC_NUMERIC;
float atof(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getfield(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
char *strdup(char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int main(void) {
  int len;
  float fuelcost = 0, totalgal = 0, sodm = 0, fodm;
  setlocale(LC_NUMERIC, "");
  char file_name[25];
  FILE *fp;
  system("dir *.csv");
  printf("\nEnter the name of file you wish to open...\n");
  fgets(file_name, 255, stdin);
  len = strlen(file_name);
  if (file_name[len - 1] == '\n')
    file_name[len - 1] = 0;
  fp = fopen(file_name, "r");
  if (fp == NULL) {
    perror("\nError while opening the file.\n");
    printf("%s\n", file_name);
    exit(EXIT_FAILURE);
  }
  printf("\nThe contents of %s file are:\n", file_name);
  char line[1024], *tmp, sDay[15], fDay[15];
  len = 0;
  while (fgets(line, 1024, fp)) {
    len++;
    tmp = strdup(line);
    if (len == 2)
      strcpy(sDay, getfield(tmp, 1));
    free(tmp);
    tmp = strdup(line);
    strcpy(fDay, getfield(tmp, 1));
    free(tmp);
    tmp = strdup(line);
    if (sodm == 0)
      sodm = atof(getfield(tmp, 2));
    free(tmp);
    tmp = strdup(line);
    fodm = atof(getfield(tmp, 2));
    free(tmp);
    tmp = strdup(line);
    totalgal += atof(getfield(tmp, 3));
    free(tmp);
    tmp = strdup(line);
    fuelcost += atof(getfield(tmp, 4));
    free(tmp);
  }
  printf("\nsDay = %s \t fDay = %s\n\n", sDay, fDay);
  printf("Starting Odometer = %.0f; Final Odometer = %.0f miles\n", sodm, fodm);
  printf("Total Gallons Used       = %.2f\n", totalgal);
  printf("Total Fuel Cost          = $%.2f\n", fuelcost);
  printf("Average cost per gallon  = $%.2f\n", (fuelcost / totalgal));
  printf("Miles driven this period = %.0f\n", (fodm - sodm));
  printf("Miles per gallon         = %.2f\n", ((fodm - sodm) / totalgal));
  printf("Miles driven on each $1  = %.2f\n", ((fodm - sodm) / fuelcost));
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   10c0 <setlocale@plt>
lea    0xdda(%rip),%rdi
call   1090 <system@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2da4(%rip),%rax
mov    (%rax),%rdx
mov    $0xff,%esi
call   10b0 <fgets@plt>
lea    -0x40(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1280 <main+0xa0>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12cb <main+0xeb>
lea    0xd93(%rip),%rdi
call   10e0 <perror@plt>
lea    -0x40(%rbp),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    -0x40(%rbp),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
movl   $0x0,-0x8(%rbp)
lea    -0x450(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    $0x400,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     14c4 <main+0x2e4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0x450(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x458(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1356 <main+0x176>
lea    -0x467(%rbp),%rax
mov    %rax,-0x480(%rbp)
mov    -0x458(%rbp),%rdi
mov    $0x1,%esi
call   1050 <getfield@plt>
mov    -0x480(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    -0x458(%rbp),%rdi
call   1030 <free@plt>
lea    -0x450(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x458(%rbp)
lea    -0x476(%rbp),%rax
mov    %rax,-0x488(%rbp)
mov    -0x458(%rbp),%rdi
mov    $0x1,%esi
call   1050 <getfield@plt>
mov    -0x488(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    -0x458(%rbp),%rdi
call   1030 <free@plt>
lea    -0x450(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x458(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    13f5 <main+0x215>
jp     13f5 <main+0x215>
mov    -0x458(%rbp),%rdi
mov    $0x2,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1060 <atof@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x458(%rbp),%rdi
call   1030 <free@plt>
lea    -0x450(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x458(%rbp)
mov    -0x458(%rbp),%rdi
mov    $0x2,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1060 <atof@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x458(%rbp),%rdi
call   1030 <free@plt>
lea    -0x450(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x458(%rbp)
mov    -0x458(%rbp),%rdi
mov    $0x3,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1060 <atof@plt>
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x458(%rbp),%rdi
call   1030 <free@plt>
lea    -0x450(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x458(%rbp)
mov    -0x458(%rbp),%rdi
mov    $0x4,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1060 <atof@plt>
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x458(%rbp),%rdi
call   1030 <free@plt>
jmp    12e4 <main+0x104>
lea    -0x467(%rbp),%rsi
lea    -0x476(%rbp),%rdx
lea    0xba3(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xb9c(%rip),%rdi
mov    $0x2,%al
call   10a0 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbbc(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbc6(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbcc(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbd2(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbd2(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbd2(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x458,%rsp
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   10d0 <setlocale@plt>
lea    0xde7(%rip),%rdi
call   10a0 <system@plt>
lea    0xf3e(%rip),%rdi
call   1060 <puts@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   10c0 <fgets@plt>
mov    %rbx,%rdi
call   1090 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1260 <main+0x70>
movb   $0x0,0xf(%rsp,%rax,1)
lea    0xda7(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1551 <main+0x361>
mov    %rax,%r14
lea    0xdac(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0x50(%rsp),%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     1436 <main+0x246>
mov    $0x1,%ebp
lea    0x50(%rsp),%r13
lea    0x41(%rsp),%r15
lea    0x32(%rsp),%r12
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
jmp    13a0 <main+0x1b0>
xchg   %ax,%ax
movss  %xmm0,0xc(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1110 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1070 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1110 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x3,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1070 <atof@plt>
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1110 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x4,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1070 <atof@plt>
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     1450 <main+0x260>
mov    %r13,%rdi
call   1110 <strdup@plt>
mov    %rax,%rbx
sub    $0x1,%ebp
jae    13c7 <main+0x1d7>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <getfield@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1110 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1050 <getfield@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1110 <strdup@plt>
mov    %rax,%rbx
movss  0xc(%rsp),%xmm0
ucomiss 0xbef(%rip),%xmm0
jne    12e0 <main+0xf0>
jp     12e0 <main+0xf0>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <getfield@plt>
mov    %eax,%edi
call   1070 <atof@plt>
jmp    12e0 <main+0xf0>
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xbf8(%rip),%rdi
lea    0x41(%rsp),%rsi
lea    0x32(%rsp),%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xbe5(%rip),%rdi
mov    $0x2,%al
call   10b0 <printf@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc05(%rip),%rdi
mov    $0x1,%al
call   10b0 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc0e(%rip),%rdi
mov    $0x1,%al
call   10b0 <printf@plt>
movss  0x4(%rsp),%xmm0
divss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc13(%rip),%rdi
mov    $0x1,%al
call   10b0 <printf@plt>
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xc11(%rip),%rdi
mov    $0x1,%al
call   10b0 <printf@plt>
movss  0x8(%rsp),%xmm0
divss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc15(%rip),%rdi
mov    $0x1,%al
call   10b0 <printf@plt>
movss  0x8(%rsp),%xmm0
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc18(%rip),%rdi
mov    $0x1,%al
call   10b0 <printf@plt>
mov    %r14,%rdi
call   1080 <fclose@plt>
xor    %eax,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xab8(%rip),%rdi
call   10f0 <perror@plt>
lea    0x10(%rsp),%rdi
call   1060 <puts@plt>
mov    0x2a62(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@LC_NUMERIC = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"dir *.csv\00"
@.str.2 = [45 x i8] c"\0AEnter the name of file you wish to open...\0A\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [32 x i8] c"\0AError while opening the file.\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [31 x i8] c"\0AThe contents of %s file are:\0A\00"
@.str.7 = [25 x i8] c"\0AsDay = %s \09 fDay = %s\0A\0A\00"
@.str.8 = [55 x i8] c"Starting Odometer = %.0f; Final Odometer = %.0f miles\0A\00"
@.str.9 = [33 x i8] c"Total Gallons Used = %.2f\0A\00"
@.str.10 = [34 x i8] c"Total Fuel Cost = $%.2f\0A\00"
@.str.11 = [34 x i8] c"Average cost per gallon = $%.2f\0A\00"
@.str.12 = [33 x i8] c"Miles driven this period = %.0f\0A\00"
@.str.13 = [33 x i8] c"Miles per gallon = %.2f\0A\00"
@.str.14 = [33 x i8] c"Miles driven on each $1 = %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca [25 x i8]
%8 = alloca i32*
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca [15 x i8]
%12 = alloca [15 x i8]
store i32 0, i32* %1
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%13 = load i32, i32* @LC_NUMERIC
%14 = call i32 @setlocale(i32 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** @stdin
%19 = call i64 @fgets(i8* %17, i32 255, i32* %18)
%20 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %34
29: ; preds = %0
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %29, %0
%35 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %36, i32** %8
%37 = load i32*, i32** %8
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%41 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %34
%46 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %46)
store i32 0, i32* %2
br label %48
48: ; preds = %84, %45
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = load i32*, i32** %8
%51 = call i64 @fgets(i8* %49, i32 1024, i32* %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %112
53: ; preds = %48
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
store i32 %55, i32* %2
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%57 = call i8* @strdup(i8* %56)
store i8* %57, i8** %10
%58 = load i32, i32* %2
%59 = icmp eq i32 %58, 2
br i1 %59, label %60, label %65
60: ; preds = %53
%61 = getelementptr inbounds [15 x i8], [15 x i8]* %11, i64 0, i64 0
%62 = load i8*, i8** %10
%63 = call i32 @getfield(i8* %62, i32 1)
%64 = call i32 @strcpy(i8* %61, i32 %63)
br label %65
65: ; preds = %60, %53
%66 = load i8*, i8** %10
%67 = call i32 @free(i8* %66)
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%69 = call i8* @strdup(i8* %68)
store i8* %69, i8** %10
%70 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%71 = load i8*, i8** %10
%72 = call i32 @getfield(i8* %71, i32 1)
%73 = call i32 @strcpy(i8* %70, i32 %72)
%74 = load i8*, i8** %10
%75 = call i32 @free(i8* %74)
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%77 = call i8* @strdup(i8* %76)
store i8* %77, i8** %10
%78 = load float, float* %5
%79 = fcmp oeq float %78, 0.000000e+00
br i1 %79, label %80, label %84
80: ; preds = %65
%81 = load i8*, i8** %10
%82 = call i32 @getfield(i8* %81, i32 2)
%83 = call float @atof(i32 %82)
store float %83, float* %5
br label %84
84: ; preds = %80, %65
%85 = load i8*, i8** %10
%86 = call i32 @free(i8* %85)
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%88 = call i8* @strdup(i8* %87)
store i8* %88, i8** %10
%89 = load i8*, i8** %10
%90 = call i32 @getfield(i8* %89, i32 2)
%91 = call float @atof(i32 %90)
store float %91, float* %6
%92 = load i8*, i8** %10
%93 = call i32 @free(i8* %92)
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%95 = call i8* @strdup(i8* %94)
store i8* %95, i8** %10
%96 = load i8*, i8** %10
%97 = call i32 @getfield(i8* %96, i32 3)
%98 = call float @atof(i32 %97)
%99 = load float, float* %4
%100 = fadd float %99, %98
store float %100, float* %4
%101 = load i8*, i8** %10
%102 = call i32 @free(i8* %101)
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%104 = call i8* @strdup(i8* %103)
store i8* %104, i8** %10
%105 = load i8*, i8** %10
%106 = call i32 @getfield(i8* %105, i32 4)
%107 = call float @atof(i32 %106)
%108 = load float, float* %3
%109 = fadd float %108, %107
store float %109, float* %3
%110 = load i8*, i8** %10
%111 = call i32 @free(i8* %110)
br label %48
112: ; preds = %48
%113 = getelementptr inbounds [15 x i8], [15 x i8]* %11, i64 0, i64 0
%114 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %113, i8* %114)
%116 = load float, float* %5
%117 = fpext float %116 to double
%118 = load float, float* %6
%119 = fpext float %118 to double
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0), double %117, double %119)
%121 = load float, float* %4
%122 = fpext float %121 to double
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), double %122)
%124 = load float, float* %3
%125 = fpext float %124 to double
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), double %125)
%127 = load float, float* %3
%128 = load float, float* %4
%129 = fdiv float %127, %128
%130 = fpext float %129 to double
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), double %130)
%132 = load float, float* %6
%133 = load float, float* %5
%134 = fsub float %132, %133
%135 = fpext float %134 to double
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), double %135)
%137 = load float, float* %6
%138 = load float, float* %5
%139 = fsub float %137, %138
%140 = load float, float* %4
%141 = fdiv float %139, %140
%142 = fpext float %141 to double
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), double %142)
%144 = load float, float* %6
%145 = load float, float* %5
%146 = fsub float %144, %145
%147 = load float, float* %3
%148 = fdiv float %146, %147
%149 = fpext float %148 to double
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), double %149)
%151 = load i32*, i32** %8
%152 = call i32 @fclose(i32* %151)
ret i32 0
}

LLVM IR (-O2):
@LC_NUMERIC = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"dir *.csv\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [32 x i8] c"\0AError while opening the file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [31 x i8] c"\0AThe contents of %s file are:\0A\00"
@.str.7 = [25 x i8] c"\0AsDay = %s \09 fDay = %s\0A\0A\00"
@.str.8 = [55 x i8] c"Starting Odometer = %.0f; Final Odometer = %.0f miles\0A\00"
@.str.9 = [33 x i8] c"Total Gallons Used = %.2f\0A\00"
@.str.10 = [34 x i8] c"Total Fuel Cost = $%.2f\0A\00"
@.str.11 = [34 x i8] c"Average cost per gallon = $%.2f\0A\00"
@.str.12 = [33 x i8] c"Miles driven this period = %.0f\0A\00"
@.str.13 = [33 x i8] c"Miles per gallon = %.2f\0A\00"
@.str.14 = [33 x i8] c"Miles driven on each $1 = %.2f\0A\00"
@str = [44 x i8] c"\0AEnter the name of file you wish to open...\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [15 x i8]
%4 = alloca [15 x i8]
%5 = load i32, i32* @LC_NUMERIC
%6 = tail call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%8 = tail call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%10 = load i32*, i32** @stdin
%11 = call i64 @fgets(i8* %7, i32 255, i32* %10)
%12 = call i32 @strlen(i8* %7)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %19
18: ; preds = %0
store i8 0, i8* %15
br label %19
19: ; preds = %18, %0
%20 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @puts(i8* %7)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%30 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%31 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%32 = call i64 @fgets(i8* %29, i32 1024, i32* %20)
%33 = icmp eq i64 %32, 0
br i1 %33, label %75, label %34
34: ; preds = %27, %56
%35 = phi i32 [ %39, %56 ], [ 0, %27 ]
%36 = phi float [ %57, %56 ], [ 0.000000e+00, %27 ]
%37 = phi float [ %66, %56 ], [ 0.000000e+00, %27 ]
%38 = phi float [ %71, %56 ], [ 0.000000e+00, %27 ]
%39 = add nuw nsw i32 %35, 1
%40 = call i8* @strdup(i8* %29)
%41 = icmp eq i32 %39, 2
br i1 %41, label %42, label %45
42: ; preds = %34
%43 = call i32 @getfield(i8* %40, i32 1)
%44 = call i32 @strcpy(i8* %30, i32 %43)
br label %45
45: ; preds = %42, %34
%46 = call i32 @free(i8* %40)
%47 = call i8* @strdup(i8* %29)
%48 = call i32 @getfield(i8* %47, i32 1)
%49 = call i32 @strcpy(i8* %31, i32 %48)
%50 = call i32 @free(i8* %47)
%51 = call i8* @strdup(i8* %29)
%52 = fcmp oeq float %36, 0.000000e+00
br i1 %52, label %53, label %56
53: ; preds = %45
%54 = call i32 @getfield(i8* %51, i32 2)
%55 = call float @atof(i32 %54)
br label %56
56: ; preds = %53, %45
%57 = phi float [ %55, %53 ], [ %36, %45 ]
%58 = call i32 @free(i8* %51)
%59 = call i8* @strdup(i8* %29)
%60 = call i32 @getfield(i8* %59, i32 2)
%61 = call float @atof(i32 %60)
%62 = call i32 @free(i8* %59)
%63 = call i8* @strdup(i8* %29)
%64 = call i32 @getfield(i8* %63, i32 3)
%65 = call float @atof(i32 %64)
%66 = fadd float %37, %65
%67 = call i32 @free(i8* %63)
%68 = call i8* @strdup(i8* %29)
%69 = call i32 @getfield(i8* %68, i32 4)
%70 = call float @atof(i32 %69)
%71 = fadd float %38, %70
%72 = call i32 @free(i8* %68)
%73 = call i64 @fgets(i8* %29, i32 1024, i32* %20)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %34
75: ; preds = %56, %27
%76 = phi float [ 0.000000e+00, %27 ], [ %71, %56 ]
%77 = phi float [ 0.000000e+00, %27 ], [ %66, %56 ]
%78 = phi float [ 0.000000e+00, %27 ], [ %57, %56 ]
%79 = phi float [ undef, %27 ], [ %61, %56 ]
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %30, i8* %31)
%81 = fpext float %78 to double
%82 = fpext float %79 to double
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0), double %81, double %82)
%84 = fpext float %77 to double
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), double %84)
%86 = fpext float %76 to double
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), double %86)
%88 = fdiv float %76, %77
%89 = fpext float %88 to double
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), double %89)
%91 = fsub float %79, %78
%92 = fpext float %91 to double
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), double %92)
%94 = fdiv float %91, %77
%95 = fpext float %94 to double
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), double %95)
%97 = fdiv float %91, %76
%98 = fpext float %97 to double
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), double %98)
%100 = call i32 @fclose(i32* %20)
ret i32 0
}