#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 */

/* Variables and functions */
int /*<<< orphan*/ __get_user(int /*<<< orphan*/, int);
void memcpy_fromfs(void *to, const void *from, unsigned long n) {
  char *d = (char *)to;
  const char *s = (const char *)from;
  while (n-- > 0) {
    *d++ = __get_user(s++, 1);
  }
}


x86 assembly (clang, -O0):
<memcpy_fromfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
jbe    1180 <memcpy_fromfs+0x70>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <__get_user@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1134 <memcpy_fromfs+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpy_fromfs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     114b <memcpy_fromfs+0x3b>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%r14,%rbx,1),%edi
mov    $0x1,%esi
call   1030 <__get_user@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <memcpy_fromfs+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @memcpy_fromfs(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %7
%10 = load i8*, i8** %5
store i8* %10, i8** %8
br label %11
11: ; preds = %15, %3
%12 = load i64, i64* %6
%13 = add i64 %12, -1
store i64 %13, i64* %6
%14 = icmp ugt i64 %12, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i8*, i8** %8
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %8
%18 = ptrtoint i8* %16 to i32
%19 = call i32 @__get_user(i32 %18, i32 1)
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
store i8 %20, i8* %21
br label %11
23: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @memcpy_fromfs(i8* nocapture writeonly %0, i8* %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %3, %5
%6 = phi i8* [ %10, %5 ], [ %1, %3 ]
%7 = phi i8* [ %15, %5 ], [ %0, %3 ]
%8 = phi i64 [ %9, %5 ], [ %2, %3 ]
%9 = add i64 %8, -1
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = ptrtoint i8* %6 to i64
%12 = trunc i64 %11 to i32
%13 = tail call i32 @__get_user(i32 %12, i32 1)
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %14, i8* %7
%16 = icmp eq i64 %9, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %3
ret void
}