int of_read(int handle, void *buf, int buf_len) {
  struct {
    const char *name;
    int num_args;
    int num_returns;
    int handle;
    void *buf;
    int buf_len;
    int size;
  } args;
  args.name = "read";
  args.num_args = 3;
  args.num_returns = 1;
  args.handle = handle;
  args.buf = buf;
  args.buf_len = buf_len;
  of(&args);
  return args.size;
}


x86 assembly (clang, -O0):
<of_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed7(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x3,-0x38(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1030 <of@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<of_read>:
sub    $0x28,%rsp
lea    0xee5(%rip),%rax
mov    %rax,(%rsp)
movabs $0x100000003,%rax
mov    %rax,0x8(%rsp)
mov    %edi,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %edx,0x20(%rsp)
mov    %rsp,%rdi
xor    %eax,%eax
call   1030 <of@plt>
mov    0x24(%rsp),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i32, i32, i32, i8*, i32, i32 }
@.str = [5 x i8] c"read\00"
define i32 @of_read(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.anon
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 1
store i32 3, i32* %9
%10 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 2
store i32 1, i32* %10
%11 = load i32, i32* %4
%12 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 3
store i32 %11, i32* %12
%13 = load i8*, i8** %5
%14 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 4
store i8* %13, i8** %14
%15 = load i32, i32* %6
%16 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 5
store i32 %15, i32* %16
%17 = call i32 (%struct.anon*, ...) bitcast (i32 (...)* @of to i32 (%struct.anon*, ...)*)(%struct.anon* %7)
%18 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 6
%19 = load i32, i32* %18
ret i32 %19
}

LLVM IR (-O2):
%struct.anon = type { i8*, i32, i32, i32, i8*, i32, i32 }
@.str = [5 x i8] c"read\00"
define i32 @of_read(i32 %0, i8* %1, i32 %2) {
%4 = alloca %struct.anon
%5 = bitcast %struct.anon* %4 to i8*
%6 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 1
store i32 3, i32* %7
%8 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 2
store i32 1, i32* %8
%9 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 3
store i32 %0, i32* %9
%10 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 4
store i8* %1, i8** %10
%11 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 5
store i32 %2, i32* %11
%12 = call i32 (%struct.anon*, ...) bitcast (i32 (...)* @of to i32 (%struct.anon*, ...)*)(%struct.anon* %4)
%13 = getelementptr inbounds %struct.anon, %struct.anon* %4, i64 0, i32 6
%14 = load i32, i32* %13
ret i32 %14
}