#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 char2_hexvalue(char *);
int /*<<< orphan*/ sp_init_screen_mark();
int strlen(char *);
int memdmp_poke(unsigned char *startpt_p, char *hexvalues) {
  int i, len, value;
  len = strlen(hexvalues) / 2;
  if (len > 16) {
    len = 16;
  }
  for (i = 0; i < len; i++) {
    value = char2_hexvalue(&(hexvalues[i * 2]));
    startpt_p[i] = value;
  }
  sp_init_screen_mark();
  return 1;
}


x86 assembly (clang, -O0):
<memdmp_poke>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jle    1165 <memdmp_poke+0x35>
movl   $0x10,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ad <memdmp_poke+0x7d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
call   1050 <char2_hexvalue@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <memdmp_poke+0x3c>
mov    $0x0,%al
call   1030 <sp_init_screen_mark@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memdmp_poke>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1189 <memdmp_poke+0x59>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cmp    $0x10,%ecx
mov    $0x10,%eax
cmovl  %ecx,%eax
cmp    $0x2,%eax
mov    $0x1,%r15d
cmovge %eax,%r15d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r12,%rdi
call   1050 <char2_hexvalue@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
add    $0x2,%r12
cmp    %rbx,%r15
jne    1170 <memdmp_poke+0x40>
xor    %eax,%eax
call   1030 <sp_init_screen_mark@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @memdmp_poke(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = sdiv i32 %9, 2
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 16
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 16, i32* %6
br label %14
14: ; preds = %13, %2
store i32 0, i32* %5
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = mul nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @char2_hexvalue(i8* %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %19
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %15
35: ; preds = %15
%36 = call i32 (...) @sp_init_screen_mark()
ret i32 1
}

LLVM IR (-O2):
define i32 @memdmp_poke(i8* nocapture writeonly %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = sdiv i32 %3, 2
%5 = icmp sgt i32 %3, 1
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = icmp slt i32 %4, 16
%8 = select i1 %7, i32 %4, i32 16
%9 = call i32 @llvm.smax.i32(i32 %8, i32 1)
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %6, %11
%12 = phi i64 [ 0, %6 ], [ %18, %11 ]
%13 = shl nuw nsw i64 %12, 1
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = tail call i32 @char2_hexvalue(i8* %14)
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 %16, i8* %17
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %11
20: ; preds = %11, %2
%21 = tail call i32 (...) @sp_init_screen_mark()
ret i32 1
}