#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*/ uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, char const *, int);
int strlen(char const *);
int rat_opt_cpuri_set_val_uri(const char *argv, uint8_t *data, uint16_t len) {
  do {
  } while (0);
  if (strlen(argv) > len || strlen(argv) > 253)
    goto exit_err;
  memcpy(data, argv, (((strlen(argv)) < (len)) ? (strlen(argv)) : (len)));
  return 0;
exit_err:
  return -1;
}


x86 assembly (clang, -O0):
<rat_opt_cpuri_set_val_uri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
jmp    1138 <rat_opt_cpuri_set_val_uri+0x18>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jg     115e <rat_opt_cpuri_set_val_uri+0x3e>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xfd,%eax
jle    1163 <rat_opt_cpuri_set_val_uri+0x43>
jmp    11b8 <rat_opt_cpuri_set_val_uri+0x98>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jge    1196 <rat_opt_cpuri_set_val_uri+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
jmp    119c <rat_opt_cpuri_set_val_uri+0x7c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bf <rat_opt_cpuri_set_val_uri+0x9f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rat_opt_cpuri_set_val_uri>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0xffffffff,%ebp
cmp    %r15d,%eax
jg     1176 <rat_opt_cpuri_set_val_uri+0x56>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xfd,%eax
jg     1176 <rat_opt_cpuri_set_val_uri+0x56>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %r15d,%eax
jge    1166 <rat_opt_cpuri_set_val_uri+0x46>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <memcpy@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rat_opt_cpuri_set_val_uri(i8* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
br label %8
8: ; preds = %3
br label %9
9: ; preds = %8
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = load i32, i32* %7
%13 = icmp sgt i32 %11, %12
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = icmp sgt i32 %16, 253
br i1 %17, label %18, label %19
18: ; preds = %14, %9
br label %34
19: ; preds = %14
%20 = load i32*, i32** %6
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @strlen(i8* %22)
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = call i32 @strlen(i8* %27)
br label %31
29: ; preds = %19
%30 = load i32, i32* %7
br label %31
31: ; preds = %29, %26
%32 = phi i32 [ %28, %26 ], [ %30, %29 ]
%33 = call i32 @memcpy(i32* %20, i8* %21, i32 %32)
store i32 0, i32* %4
br label %35
34: ; preds = %18
store i32 -1, i32* %4
br label %35
35: ; preds = %34, %31
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @rat_opt_cpuri_set_val_uri(i8* %0, i32* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, %2
br i1 %5, label %17, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 253
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp slt i32 %10, %2
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @strlen(i8* %0)
br label %14
14: ; preds = %9, %12
%15 = phi i32 [ %13, %12 ], [ %2, %9 ]
%16 = tail call i32 @memcpy(i32* %1, i8* %0, i32 %15)
br label %17
17: ; preds = %6, %3, %14
%18 = phi i32 [ 0, %14 ], [ -1, %3 ], [ -1, %6 ]
ret i32 %18
}