#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 */
struct plainstring {
  int dummy;
};

/* Variables and functions */
struct plainstring *plainstring_new();
int /*<<< orphan*/ plainstring_set(struct plainstring *, char const *);
struct plainstring *plainstring_new_str(const char *value) {
  struct plainstring *str = plainstring_new();
  if (!str)
    return str;
  if ((value) && (value[0]))
    plainstring_set(str, value);
  return str;
}


x86 assembly (clang, -O0):
<plainstring_new_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <plainstring_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114f <plainstring_new_str+0x2f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <plainstring_new_str+0x5f>
cmpq   $0x0,-0x10(%rbp)
je     1177 <plainstring_new_str+0x57>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1177 <plainstring_new_str+0x57>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <plainstring_set@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plainstring_new_str>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <plainstring_new@plt>
mov    %rax,%rbx
test   %r14,%r14
je     114c <plainstring_new_str+0x2c>
test   %rbx,%rbx
je     114c <plainstring_new_str+0x2c>
cmpb   $0x0,(%r14)
je     114c <plainstring_new_str+0x2c>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <plainstring_set@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.plainstring = type { i32 }
define %struct.plainstring* @plainstring_new_str(i8* %0) {
%2 = alloca %struct.plainstring*
%3 = alloca i8*
%4 = alloca %struct.plainstring*
store i8* %0, i8** %3
%5 = call %struct.plainstring* (...) @plainstring_new()
store %struct.plainstring* %5, %struct.plainstring** %4
%6 = load %struct.plainstring*, %struct.plainstring** %4
%7 = icmp ne %struct.plainstring* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = load %struct.plainstring*, %struct.plainstring** %4
store %struct.plainstring* %9, %struct.plainstring** %2
br label %25
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load %struct.plainstring*, %struct.plainstring** %4
%21 = load i8*, i8** %3
%22 = call i32 @plainstring_set(%struct.plainstring* %20, i8* %21)
br label %23
23: ; preds = %19, %13, %10
%24 = load %struct.plainstring*, %struct.plainstring** %4
store %struct.plainstring* %24, %struct.plainstring** %2
br label %25
25: ; preds = %23, %8
%26 = load %struct.plainstring*, %struct.plainstring** %2
ret %struct.plainstring* %26
}

LLVM IR (-O2):
%struct.plainstring = type { i32 }
define %struct.plainstring* @plainstring_new_str(i8* %0) {
%2 = tail call %struct.plainstring* (...) @plainstring_new()
%3 = icmp eq %struct.plainstring* %2, null
%4 = icmp eq i8* %0, null
%5 = or i1 %4, %3
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @plainstring_set(%struct.plainstring* %2, i8* %0)
br label %11
11: ; preds = %6, %9, %1
ret %struct.plainstring* %2
}