#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 db_put_raw(void *, char const *, scalar_t__, char const *, scalar_t__,
               int /*<<< orphan*/);
scalar_t__ strlen(char const *);
int db_put_str(void *dbh, const char *keystr, const char *valstr) {
  if (valstr)
    return db_put_raw(dbh, keystr, strlen(keystr) + 1, valstr,
                      strlen(valstr) + 1, 0);
  else
    return db_put_raw(dbh, keystr, strlen(keystr) + 1, NULL, 0, 0);
}


x86 assembly (clang, -O0):
<db_put_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1198 <db_put_str+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %rax,%r8
add    $0x1,%r8
xor    %r9d,%r9d
call   1030 <db_put_raw@plt>
mov    %eax,-0x4(%rbp)
jmp    11d3 <db_put_str+0xb3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
mov    %r8,%rcx
call   1030 <db_put_raw@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_put_str>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
add    $0x1,%rbx
test   %r12,%r12
je     115f <db_put_str+0x3f>
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%r8
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
jmp    116d <db_put_str+0x4d>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <db_put_raw@plt>

LLVM IR (-O0):
define i32 @db_put_str(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %21
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i8*, i8** %6
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %14, 1
%16 = load i8*, i8** %7
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
%19 = add nsw i64 %18, 1
%20 = call i32 @db_put_raw(i8* %11, i8* %12, i64 %15, i8* %16, i64 %19, i32 0)
store i32 %20, i32* %4
br label %28
21: ; preds = %3
%22 = load i8*, i8** %5
%23 = load i8*, i8** %6
%24 = load i8*, i8** %6
%25 = call i64 @strlen(i8* %24)
%26 = add nsw i64 %25, 1
%27 = call i32 @db_put_raw(i8* %22, i8* %23, i64 %26, i8* null, i64 0, i32 0)
store i32 %27, i32* %4
br label %28
28: ; preds = %21, %10
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @db_put_str(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = add nsw i64 %5, 1
br i1 %4, label %11, label %7
7: ; preds = %3
%8 = tail call i64 @strlen(i8* %2)
%9 = add nsw i64 %8, 1
%10 = tail call i32 @db_put_raw(i8* %0, i8* %1, i64 %6, i8* %2, i64 %9, i32 0)
br label %13
11: ; preds = %3
%12 = tail call i32 @db_put_raw(i8* %0, i8* %1, i64 %6, i8* null, i64 0, i32 0)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %10, %7 ], [ %12, %11 ]
ret i32 %14
}