#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*/ db_clean(char *, char *, size_t const);
int /*<<< orphan*/ db_safe(char *, char *, size_t const);
int /*<<< orphan*/ strlcpy(char *, char *, size_t const);
void db_insert_safe(char *str, char *data, const size_t size) {
  if (!*data) {
    strlcpy(str, "Unknown", size);
    return;
  }
  db_clean(str, data, size);
  strlcpy(data, str, size);
  db_safe(str, data, size);
  if (!*str)
    strlcpy(str, "Unknown", size);
}


x86 assembly (clang, -O0):
<db_insert_safe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116a <db_insert_safe+0x3a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xea0(%rip),%rsi
call   1040 <strlcpy@plt>
jmp    11be <db_insert_safe+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <db_clean@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <strlcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <db_safe@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11be <db_insert_safe+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe47(%rip),%rsi
call   1040 <strlcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_insert_safe>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%r15
cmpb   $0x0,(%rsi)
je     1176 <db_insert_safe+0x46>
mov    %rsi,%rbx
mov    %r15,%rdi
mov    %r14,%rdx
call   1030 <db_clean@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <strlcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <db_safe@plt>
cmpb   $0x0,(%r15)
je     1176 <db_insert_safe+0x46>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe83(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strlcpy@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Unknown\00"
define void @db_insert_safe(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = load i64, i64* %6
%13 = call i32 @strlcpy(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %34
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = load i64, i64* %6
%18 = call i32 @db_clean(i8* %15, i8* %16, i64 %17)
%19 = load i8*, i8** %5
%20 = load i8*, i8** %4
%21 = load i64, i64* %6
%22 = call i32 @strlcpy(i8* %19, i8* %20, i64 %21)
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i64, i64* %6
%26 = call i32 @db_safe(i8* %23, i8* %24, i64 %25)
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %14
%31 = load i8*, i8** %4
%32 = load i64, i64* %6
%33 = call i32 @strlcpy(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %32)
br label %34
34: ; preds = %10, %30, %14
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"Unknown\00"
define void @db_insert_safe(i8* %0, i8* %1, i64 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @strlcpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %2)
br label %16
8: ; preds = %3
%9 = tail call i32 @db_clean(i8* %0, i8* %1, i64 %2)
%10 = tail call i32 @strlcpy(i8* %1, i8* %0, i64 %2)
%11 = tail call i32 @db_safe(i8* %0, i8* %1, i64 %2)
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 @strlcpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %2)
br label %16
16: ; preds = %6, %14, %8
ret void
}