#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 */
char *ascii2hex(char *, int *);
int /*<<< orphan*/ free(char *);
int is_cleartext(char *);
char *modvalue(char *, int, int /*<<< orphan*/ *);
char *strchr(char *, char);
int strlen(char *);
char *dvalue(char *ptr) {
  char *modv, *str, *sb;
  int len;
  if (1 == is_cleartext(ptr))
    return (NULL);
  sb = strchr(ptr, '}');
  sb++;
  len = strlen(sb);
  str = ascii2hex(sb, &len);
  modv = modvalue(str, len, NULL);
  free(str);
  str = NULL;
  return (modv);
}


x86 assembly (clang, -O0):
<dvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <is_cleartext@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1191 <dvalue+0x31>
movq   $0x0,-0x8(%rbp)
jmp    11f9 <dvalue+0x99>
mov    -0x10(%rbp),%rdi
mov    $0x7d,%esi
call   1060 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <ascii2hex@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <modvalue@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvalue>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <is_cleartext@plt>
cmp    $0x1,%eax
jne    1175 <dvalue+0x15>
xor    %ebx,%ebx
jmp    11bb <dvalue+0x5b>
mov    %rbx,%rdi
mov    $0x7d,%esi
call   1060 <strchr@plt>
lea    0x1(%rax),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <ascii2hex@plt>
mov    %rax,%r14
mov    0x4(%rsp),%esi
mov    %rax,%rdi
xor    %edx,%edx
call   1080 <modvalue@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @dvalue(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @is_cleartext(i8* %8)
%10 = icmp eq i32 1, %9
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %27
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i8* @strchr(i8* %13, i8 signext 125)
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %7
%19 = load i8*, i8** %6
%20 = call i8* @ascii2hex(i8* %19, i32* %7)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = call i8* @modvalue(i8* %21, i32 %22, i32* null)
store i8* %23, i8** %4
%24 = load i8*, i8** %5
%25 = call i32 @free(i8* %24)
store i8* null, i8** %5
%26 = load i8*, i8** %4
store i8* %26, i8** %2
br label %27
27: ; preds = %12, %11
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
define i8* @dvalue(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @is_cleartext(i8* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 125)
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = tail call i32 @strlen(i8* %8)
store i32 %9, i32* %2
%10 = call i8* @ascii2hex(i8* %8, i32* %2)
%11 = load i32, i32* %2
%12 = call i8* @modvalue(i8* %10, i32 %11, i32* null)
%13 = call i32 @free(i8* %10)
br label %14
14: ; preds = %1, %6
%15 = phi i8* [ %12, %6 ], [ null, %1 ]
ret i8* %15
}