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

/* Variables and functions */
int /*<<< orphan*/ _memread(struct imap *, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int);
int /*<<< orphan*/ _setval(struct imap *, int, int /*<<< orphan*/);
int dfsz(int, int /*<<< orphan*/);
void readptr(struct imap *ci, int seg, int a0, int a1) {
  _setval(ci, a0, _memread(ci, 0, 0, 0, 0, a0));
  _setval(ci, seg, _memread(ci, 0, 0, 0, 0, dfsz(a0, 0)));
}


x86 assembly (clang, -O0):
<readptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%r9d
xor    %r8d,%r8d
mov    %r8d,%esi
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <_memread@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
call   1030 <_setval@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
xor    %esi,%esi
call   1040 <dfsz@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%r9d
xor    %r8d,%r8d
mov    %r8d,%esi
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <_memread@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    %eax,%edx
call   1030 <_setval@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readptr>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %ebp,%r9d
call   1050 <_memread@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <_setval@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <dfsz@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %eax,%r9d
call   1050 <_memread@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %eax,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <_setval@plt>

LLVM IR (-O0):
%struct.imap = type { i32 }
define void @readptr(%struct.imap* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.imap*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.imap* %0, %struct.imap** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load %struct.imap*, %struct.imap** %5
%10 = load i32, i32* %7
%11 = load %struct.imap*, %struct.imap** %5
%12 = load i32, i32* %7
%13 = call i32 @_memread(%struct.imap* %11, i32 0, i32 0, i32 0, i32 0, i32 %12)
%14 = call i32 @_setval(%struct.imap* %9, i32 %10, i32 %13)
%15 = load %struct.imap*, %struct.imap** %5
%16 = load i32, i32* %6
%17 = load %struct.imap*, %struct.imap** %5
%18 = load i32, i32* %7
%19 = call i32 @dfsz(i32 %18, i32 0)
%20 = call i32 @_memread(%struct.imap* %17, i32 0, i32 0, i32 0, i32 0, i32 %19)
%21 = call i32 @_setval(%struct.imap* %15, i32 %16, i32 %20)
ret void
}

LLVM IR (-O2):
%struct.imap = type { i32 }
define void @readptr(%struct.imap* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @_memread(%struct.imap* %0, i32 0, i32 0, i32 0, i32 0, i32 %2)
%6 = tail call i32 @_setval(%struct.imap* %0, i32 %2, i32 %5)
%7 = tail call i32 @dfsz(i32 %2, i32 0)
%8 = tail call i32 @_memread(%struct.imap* %0, i32 0, i32 0, i32 0, i32 0, i32 %7)
%9 = tail call i32 @_setval(%struct.imap* %0, i32 %1, i32 %8)
ret void
}