#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*/ atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ model_stack_push(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf_s(char *, char *, int);
void view_makeAStackFromFile(void) {
  char fileName[255] = {0};
  char buf[255] = {0};
  FILE *fp = NULL;
  printf("Input the file name for Stack : ");
  scanf_s("%s", fileName, 255);
  fp = fopen(fileName, "rt");
  if (fp != NULL) {
    while (fgets(buf, 255, fp) != NULL) {
      printf("%s", buf);
      model_stack_push(atoi(buf));
    }
    fclose(fp);
  }
  puts("");
}


x86 assembly (clang, -O0):
<view_makeAStackFromFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1060 <memset@plt>
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1060 <memset@plt>
movq   $0x0,-0x208(%rbp)
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x100(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0xff,%edx
call   1090 <scanf_s@plt>
lea    -0x100(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x208(%rbp)
cmpq   $0x0,-0x208(%rbp)
je     127a <view_makeAStackFromFile+0xea>
jmp    121f <view_makeAStackFromFile+0x8f>
lea    -0x200(%rbp),%rdi
mov    -0x208(%rbp),%rdx
mov    $0xff,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     126e <view_makeAStackFromFile+0xde>
lea    -0x200(%rbp),%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x200(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   1080 <model_stack_push@plt>
jmp    121f <view_makeAStackFromFile+0x8f>
mov    -0x208(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd9f(%rip),%rdi
call   1030 <puts@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_makeAStackFromFile>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x1ef(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movups %xmm0,0xef(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xd83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd96(%rip),%rdi
lea    0x100(%rsp),%rbx
mov    %rbx,%rsi
mov    $0xff,%edx
call   1080 <scanf_s@plt>
lea    0xd7d(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1319 <view_makeAStackFromFile+0x199>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0xff,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1311 <view_makeAStackFromFile+0x191>
lea    0xd4e(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   1070 <model_stack_push@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    12e0 <view_makeAStackFromFile+0x160>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Input the file name for Stack : \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [1 x i8] zeroinitializer
define void @view_makeAStackFromFile() {
%1 = alloca [255 x i8]
%2 = alloca [255 x i8]
%3 = alloca i32*
%4 = bitcast [255 x i8]* %1 to i8*
%5 = bitcast [255 x i8]* %2 to i8*
store i32* null, i32** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%8 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 255)
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %28
13: ; preds = %0
br label %14
14: ; preds = %19, %13
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%16 = load i32*, i32** %3
%17 = call i32* @fgets(i8* %15, i32 255, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%23 = call i32 @atoi(i8* %22)
%24 = call i32 @model_stack_push(i32 %23)
br label %14
25: ; preds = %14
%26 = load i32*, i32** %3
%27 = call i32 @fclose(i32* %26)
br label %28
28: ; preds = %25, %0
%29 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Input the file name for Stack : \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"rt\00"
define void @view_makeAStackFromFile() {
%1 = alloca [255 x i8]
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 255)
%7 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %20, label %9
9: ; preds = %0
%10 = call i32* @fgets(i8* %4, i32 255, i32* %7)
%11 = icmp eq i32* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9, %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%14 = call i32 @atoi(i8* %4)
%15 = call i32 @model_stack_push(i32 %14)
%16 = call i32* @fgets(i8* %4, i32 255, i32* %7)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %12
18: ; preds = %12, %9
%19 = call i32 @fclose(i32* %7)
br label %20
20: ; preds = %18, %0
%21 = call i32 @putchar(i32 10)
ret void
}