#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*/ OPM_SymRCh(unsigned char *);
int Platform_Halt(int);
void OPT_InName(unsigned char *name, long long name__len) {
  int i;
  unsigned char ch;
  i = 0;
  do {
    OPM_SymRCh(&ch);
    name[(((unsigned long long)(i) < (unsigned long long)(name__len))
              ? i
              : (Platform_Halt(-2), 0))] = ch;
    i += 1;
  } while (!(ch == 0x00));
}


x86 assembly (clang, -O0):
<OPT_InName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x15(%rbp),%rdi
call   1040 <OPM_SymRCh@plt>
mov    -0x15(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1167 <OPT_InName+0x47>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1176 <OPT_InName+0x56>
mov    $0xfffffffe,%edi
call   1030 <Platform_Halt@plt>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x21(%rbp),%dl
mov    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movzbl -0x15(%rbp),%eax
cmp    $0x0,%eax
sete   %al
xor    $0xff,%al
test   $0x1,%al
jne    1137 <OPT_InName+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OPT_InName>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
lea    0xf(%rsp),%r15
jmp    114e <OPT_InName+0x2e>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ecx
mov    %bpl,(%r12,%rcx,1)
add    $0x1,%rbx
test   %al,%al
je     1178 <OPT_InName+0x58>
mov    %r15,%rdi
call   1040 <OPM_SymRCh@plt>
movzbl 0xf(%rsp),%ebp
mov    %ebp,%eax
mov    %rbx,%rcx
cmp    %r14,%rbx
jb     1140 <OPT_InName+0x20>
mov    $0xfffffffe,%edi
call   1030 <Platform_Halt@plt>
movzbl 0xf(%rsp),%eax
xor    %ecx,%ecx
jmp    1140 <OPT_InName+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @OPT_InName(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 0, i32* %5
br label %7
7: ; preds = %25, %2
%8 = call i32 @OPM_SymRCh(i8* %6)
%9 = load i8, i8* %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = load i32, i32* %5
br label %19
17: ; preds = %7
%18 = call i32 @Platform_Halt(i32 -2)
br label %19
19: ; preds = %17, %15
%20 = phi i32 [ %16, %15 ], [ 0, %17 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %10, i64 %21
store i8 %9, i8* %22
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %25
25: ; preds = %19
%26 = load i8, i8* %6
%27 = zext i8 %26 to i32
%28 = icmp eq i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %7, label %30
30: ; preds = %25
ret void
}

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