#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 */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
scalar_t__ rd_byte(int /*<<< orphan*/);
void fstrcpy_in(char *str, uint64_t loc) {
  int i = 0;
  while (rd_byte(loc))
    str[i++] = (char)rd_byte(loc++);
  str[i] = 0;
  return;
}


x86 assembly (clang, -O0):
<fstrcpy_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <rd_byte@plt>
cmp    $0x0,%rax
je     1164 <fstrcpy_in+0x54>
mov    -0xc(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
call   1030 <rd_byte@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1126 <fstrcpy_in+0x16>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fstrcpy_in>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%edi
call   1030 <rd_byte@plt>
test   %rax,%rax
je     1165 <fstrcpy_in+0x55>
lea    0x1(%r14),%r12d
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%rbx,1),%edi
lea    (%r12,%rbx,1),%ebp
call   1030 <rd_byte@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
mov    %ebp,%edi
call   1030 <rd_byte@plt>
test   %rax,%rax
jne    1140 <fstrcpy_in+0x30>
mov    %ebx,%eax
jmp    1167 <fstrcpy_in+0x57>
xor    %eax,%eax
movb   $0x0,(%r15,%rax,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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