#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 forth_instance {
  int dummy;
};

/* Variables and functions */
scalar_t__ read(int, char *, int);
int st_pop(struct forth_instance *);
int /*<<< orphan*/ st_push(struct forth_instance *, int);
void read_func(struct forth_instance *fi) {
  int fd, len;
  char *dest;
  len = st_pop(fi);
  dest = (char *)st_pop(fi);
  fd = st_pop(fi);
  st_push(fi, (int)read(fd, dest, len));
}


x86 assembly (clang, -O0):
<read_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <st_pop@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <st_pop@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <st_pop@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <read@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <st_push@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_func>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <st_pop@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <st_pop@plt>
movslq %eax,%rbp
mov    %rbx,%rdi
call   1030 <st_pop@plt>
mov    %eax,%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1040 <read@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <st_push@plt>

LLVM IR (-O0):
%struct.forth_instance = type { i32 }
define void @read_func(%struct.forth_instance* %0) {
%2 = alloca %struct.forth_instance*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store %struct.forth_instance* %0, %struct.forth_instance** %2
%6 = load %struct.forth_instance*, %struct.forth_instance** %2
%7 = call i32 @st_pop(%struct.forth_instance* %6)
store i32 %7, i32* %4
%8 = load %struct.forth_instance*, %struct.forth_instance** %2
%9 = call i32 @st_pop(%struct.forth_instance* %8)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
%12 = load %struct.forth_instance*, %struct.forth_instance** %2
%13 = call i32 @st_pop(%struct.forth_instance* %12)
store i32 %13, i32* %3
%14 = load %struct.forth_instance*, %struct.forth_instance** %2
%15 = load i32, i32* %3
%16 = load i8*, i8** %5
%17 = load i32, i32* %4
%18 = call i64 @read(i32 %15, i8* %16, i32 %17)
%19 = trunc i64 %18 to i32
%20 = call i32 @st_push(%struct.forth_instance* %14, i32 %19)
ret void
}

LLVM IR (-O2):
%struct.forth_instance = type { i32 }
define void @read_func(%struct.forth_instance* %0) {
%2 = tail call i32 @st_pop(%struct.forth_instance* %0)
%3 = tail call i32 @st_pop(%struct.forth_instance* %0)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @st_pop(%struct.forth_instance* %0)
%7 = tail call i64 @read(i32 %6, i8* %5, i32 %2)
%8 = trunc i64 %7 to i32
%9 = tail call i32 @st_push(%struct.forth_instance* %0, i32 %8)
ret void
}