#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 */
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  char const *str;
  int /*<<< orphan*/ length;
};
struct TYPE_5__ {
  TYPE_1__ description;
};
typedef TYPE_2__ ITEM;

/* Variables and functions */
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ strlen(char const *);
void set_item_description(ITEM *item, const char *description) {
  if (item->description.str != NULL) {
    free((void *)(item->description).str);
  }
  item->description.length = strlen(description);
  item->description.str = description;
}


x86 assembly (clang, -O0):
<set_item_description>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     114a <set_item_description+0x2a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_item_description>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1137 <set_item_description+0x17>
call   1030 <free@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,0x8(%rbx)
mov    %r14,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i8*, i32 }
define void @set_item_description(%struct.TYPE_5__* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0, i32 0
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @free(i8* %4)
br label %8
8: ; preds = %6, %2
%9 = tail call i32 @strlen(i8* %1)
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0, i32 1
store i32 %9, i32* %10
store i8* %1, i8** %3
ret void
}