#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 fstr {
  int dummy;
};

/* Variables and functions */
struct fstr *fstr_cpy(struct fstr *, int /*<<< orphan*/, int);
int /*<<< orphan*/ fstr_free(struct fstr *);
struct fstr *fstr_new(char *);
int /*<<< orphan*/ fstr_show(struct fstr *);
int main(int argc, char *argv[]) {
  struct fstr *string = fstr_new("Hello world of Assembly");
  fstr_show(string);
  struct fstr *sub_string = fstr_cpy(string, 0, 10);
  fstr_show(sub_string);
  fstr_free(string);
  fstr_show(sub_string);
  fstr_free(sub_string);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <fstr_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fstr_show@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <fstr_cpy@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fstr_show@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fstr_free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fstr_show@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fstr_free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1040 <fstr_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <fstr_show@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <fstr_cpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fstr_show@plt>
mov    %r14,%rdi
call   1060 <fstr_free@plt>
mov    %rbx,%rdi
call   1050 <fstr_show@plt>
mov    %rbx,%rdi
call   1060 <fstr_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.fstr = type { i32 }
@.str = [24 x i8] c"Hello world of Assembly\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.fstr*
%6 = alloca %struct.fstr*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call %struct.fstr* @fstr_new(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store %struct.fstr* %7, %struct.fstr** %5
%8 = load %struct.fstr*, %struct.fstr** %5
%9 = call i32 @fstr_show(%struct.fstr* %8)
%10 = load %struct.fstr*, %struct.fstr** %5
%11 = call %struct.fstr* @fstr_cpy(%struct.fstr* %10, i32 0, i32 10)
store %struct.fstr* %11, %struct.fstr** %6
%12 = load %struct.fstr*, %struct.fstr** %6
%13 = call i32 @fstr_show(%struct.fstr* %12)
%14 = load %struct.fstr*, %struct.fstr** %5
%15 = call i32 @fstr_free(%struct.fstr* %14)
%16 = load %struct.fstr*, %struct.fstr** %6
%17 = call i32 @fstr_show(%struct.fstr* %16)
%18 = load %struct.fstr*, %struct.fstr** %6
%19 = call i32 @fstr_free(%struct.fstr* %18)
ret i32 0
}

LLVM IR (-O2):
%struct.fstr = type { i32 }
@.str = [24 x i8] c"Hello world of Assembly\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.fstr* @fstr_new(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @fstr_show(%struct.fstr* %3)
%5 = tail call %struct.fstr* @fstr_cpy(%struct.fstr* %3, i32 0, i32 10)
%6 = tail call i32 @fstr_show(%struct.fstr* %5)
%7 = tail call i32 @fstr_free(%struct.fstr* %3)
%8 = tail call i32 @fstr_show(%struct.fstr* %5)
%9 = tail call i32 @fstr_free(%struct.fstr* %5)
ret i32 0
}