#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 */
struct Stack {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stack_dump(struct Stack *);
int /*<<< orphan*/ stack_ok(struct Stack *);
int /*<<< orphan*/ stack_push(struct Stack *, double);
int push_from_file(FILE *com_file, struct Stack *stk_p) {
  if (!stack_ok(stk_p)) {
    stack_dump(stk_p);
    printf("INVALID STACK IN THE BEGINNING OF push_from_file!!!\n");
    assert(NULL);
  }
  double number = -666;
  fscanf(com_file, "%lg", &number);
  stack_push(stk_p, number);
  if (!stack_ok(stk_p)) {
    stack_dump(stk_p);
    printf("INVALID STACK IN THE END OF push_from_file!!!\n");
    assert(NULL);
  }
  return 0;
}


x86 assembly (clang, -O0):
<push_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <stack_ok@plt>
cmp    $0x0,%eax
jne    11a0 <push_from_file+0x40>
mov    -0x10(%rbp),%rdi
call   1070 <stack_dump@plt>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <assert@plt>
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
call   1080 <stack_push@plt>
mov    -0x10(%rbp),%rdi
call   1060 <stack_ok@plt>
cmp    $0x0,%eax
jne    11ff <push_from_file+0x9f>
mov    -0x10(%rbp),%rdi
call   1070 <stack_dump@plt>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push_from_file>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <stack_ok@plt>
test   %eax,%eax
jne    1191 <push_from_file+0x31>
mov    %rbx,%rdi
call   1070 <stack_dump@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <assert@plt>
movabs $0xc084d00000000000,%rax
d0 84 c0
mov    %rax,(%rsp)
lea    0xe5a(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
call   1040 <fscanf@plt>
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
call   1080 <stack_push@plt>
mov    %rbx,%rdi
call   1060 <stack_ok@plt>
test   %eax,%eax
jne    11e5 <push_from_file+0x85>
mov    %rbx,%rdi
call   1070 <stack_dump@plt>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
@.str = [53 x i8] c"INVALID STACK IN THE BEGINNING OF push_from_file!!!\0A\00"
@.str.1 = [4 x i8] c"%lg\00"
@.str.2 = [47 x i8] c"INVALID STACK IN THE END OF push_from_file!!!\0A\00"
define i32 @push_from_file(i32* %0, %struct.Stack* %1) {
%3 = alloca i32*
%4 = alloca %struct.Stack*
%5 = alloca double
store i32* %0, i32** %3
store %struct.Stack* %1, %struct.Stack** %4
%6 = load %struct.Stack*, %struct.Stack** %4
%7 = call i32 @stack_ok(%struct.Stack* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load %struct.Stack*, %struct.Stack** %4
%11 = call i32 @stack_dump(%struct.Stack* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @assert(i32* null)
br label %14
14: ; preds = %9, %2
store double -6.660000e+02, double* %5
%15 = load i32*, i32** %3
%16 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%17 = load %struct.Stack*, %struct.Stack** %4
%18 = load double, double* %5
%19 = call i32 @stack_push(%struct.Stack* %17, double %18)
%20 = load %struct.Stack*, %struct.Stack** %4
%21 = call i32 @stack_ok(%struct.Stack* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %14
%24 = load %struct.Stack*, %struct.Stack** %4
%25 = call i32 @stack_dump(%struct.Stack* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @assert(i32* null)
br label %28
28: ; preds = %23, %14
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@.str.1 = [4 x i8] c"%lg\00"
@str = [52 x i8] c"INVALID STACK IN THE BEGINNING OF push_from_file!!!\00"
@str.3 = [46 x i8] c"INVALID STACK IN THE END OF push_from_file!!!\00"
define i32 @push_from_file(i32* nocapture %0, %struct.Stack* %1) {
%3 = alloca double
%4 = tail call i32 @stack_ok(%struct.Stack* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 @stack_dump(%struct.Stack* %1)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @assert(i32* null)
br label %10
10: ; preds = %6, %2
%11 = bitcast double* %3 to i8*
store double -6.660000e+02, double* %3
%12 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%13 = load double, double* %3
%14 = call i32 @stack_push(%struct.Stack* %1, double %13)
%15 = call i32 @stack_ok(%struct.Stack* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = call i32 @stack_dump(%struct.Stack* %1)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.3, i64 0, i64 0))
%20 = call i32 @assert(i32* null)
br label %21
21: ; preds = %17, %10
ret i32 0
}