#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, int *, float *);
int /*<<< orphan*/ printf(char *, char *, int, float);
int /*<<< orphan*/ puts(char *);
int main(void) {
  FILE *fp;
  struct emp {
    char name[40];
    int age;
    float bs;
  };
  struct emp e;
  fp = fopen("Employee.txt", "r");
  if (fp == NULL) {
    puts("Cannot open file");
    exit(1);
  }
  while (fscanf(fp, "%s %d %f", e.name, &e.age, &e.bs) != EOF) {
    printf("%s\t%d\t%.2f\n", e.name, e.age, e.bs);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a7 <main+0x47>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11ac <main+0x4c>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x40(%rbp),%rcx
add    $0x28,%rcx
lea    -0x40(%rbp),%r8
add    $0x2c,%r8
lea    0xe55(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2e11(%rip),%rcx
cmp    (%rcx),%rax
je     11fd <main+0x9d>
lea    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%edx
movss  -0x14(%rbp),%xmm0
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
jmp    11ac <main+0x4c>
mov    -0x10(%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    0xe8b(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1219 <main+0xb9>
mov    %rax,%r13
lea    0x30(%rsp),%rcx
lea    0x34(%rsp),%r8
lea    0xe82(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
mov    %r8,%r15
call   1060 <fscanf@plt>
mov    0x2e33(%rip),%r14
cmp    (%r14),%rax
je     1200 <main+0xa0>
lea    0xe68(%rip),%r12
lea    0x8(%rsp),%rbx
lea    0xe53(%rip),%rbp
nopl   (%rax)
mov    0x30(%rsp),%edx
movss  0x34(%rsp),%xmm0
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
lea    0x30(%rsp),%rcx
mov    %r15,%r8
call   1060 <fscanf@plt>
cmp    (%r14),%rax
jne    11d0 <main+0x70>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdef(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.emp = type { [40 x i8], i32, float }
@.str = [13 x i8] c"Employee.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"Cannot open file\00"
@.str.3 = [9 x i8] c"%s %d %f\00"
@EOF = global i64 0
@.str.4 = [12 x i8] c"%s\09%d\09%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca %struct.emp
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
br label %11
11: ; preds = %20, %10
%12 = load i32*, i32** %2
%13 = getelementptr inbounds %struct.emp, %struct.emp* %3, i32 0, i32 0
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%15 = getelementptr inbounds %struct.emp, %struct.emp* %3, i32 0, i32 1
%16 = getelementptr inbounds %struct.emp, %struct.emp* %3, i32 0, i32 2
%17 = call i64 @fscanf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %14, i32* %15, float* %16)
%18 = load i64, i64* @EOF
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %11
%21 = getelementptr inbounds %struct.emp, %struct.emp* %3, i32 0, i32 0
%22 = getelementptr inbounds [40 x i8], [40 x i8]* %21, i64 0, i64 0
%23 = getelementptr inbounds %struct.emp, %struct.emp* %3, i32 0, i32 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.emp, %struct.emp* %3, i32 0, i32 2
%26 = load float, float* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %22, i32 %24, float %26)
br label %11
28: ; preds = %11
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
ret i32 0
}

LLVM IR (-O2):
%struct.emp = type { [40 x i8], i32, float }
@.str = [13 x i8] c"Employee.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"Cannot open file\00"
@.str.3 = [9 x i8] c"%s %d %f\00"
@EOF = global i64 0
@.str.4 = [12 x i8] c"%s\09%d\09%.2f\0A\00"
define i32 @main() {
%1 = alloca %struct.emp
%2 = getelementptr inbounds %struct.emp, %struct.emp* %1, i64 0, i32 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %11, label %5
5: ; preds = %0
%6 = getelementptr inbounds %struct.emp, %struct.emp* %1, i64 0, i32 1
%7 = getelementptr inbounds %struct.emp, %struct.emp* %1, i64 0, i32 2
%8 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32* %6, float* %7)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %21, label %14
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %5, %14
%15 = load i32, i32* %6
%16 = load float, float* %7
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %15, float %16)
%18 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32* %6, float* %7)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %14
21: ; preds = %14, %5
%22 = call i32 @fclose(i32* %3)
ret i32 0
}