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

/* Variables and functions */
struct tree *create_tree(char *, int /*<<< orphan*/);
int /*<<< orphan*/ deepth(int /*<<< orphan*/);
int /*<<< orphan*/ pr_thrtree(struct tree *);
int /*<<< orphan*/ pr_tree(struct tree *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ threading(struct tree *);
int main() {
  struct tree *t;
  char s[] = "abcdefghijk";
  printf("creating tree by string `%s`...\n", s);
  t = create_tree(s, deepth(strlen(s)));
  printf("print tree:\n");
  pr_tree(t);
  putchar('\n');
  threading(t);
  printf("threading tree...\n");
  printf("print threaded tree:\n");
  pr_thrtree(t);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xe71(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xe6f(%rip),%eax
mov    %eax,-0xc(%rbp)
lea    -0x14(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1080 <deepth@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <create_tree@plt>
mov    %rax,-0x8(%rbp)
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1090 <pr_tree@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <threading@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <pr_thrtree@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x6867666564636261,%rax
66 67 68
mov    %rax,(%rsp)
movl   $0x6b6a69,0x8(%rsp)
lea    0xe5a(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1090 <deepth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <create_tree@plt>
mov    %rax,%rbx
lea    0xe4b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   10a0 <pr_tree@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   10b0 <threading@plt>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1080 <pr_thrtree@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tree = type { i32 }
@__const.main.s = [12 x i8] c"abcdefghijk\00"
@.str = [33 x i8] c"creating tree by string `%s`...\0A\00"
@.str.1 = [13 x i8] c"print tree:\0A\00"
@.str.2 = [19 x i8] c"threading tree...\0A\00"
@.str.3 = [22 x i8] c"print threaded tree:\0A\00"
define i32 @main() {
%1 = alloca %struct.tree*
%2 = alloca [12 x i8]
%3 = bitcast [12 x i8]* %2 to i8*
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @deepth(i32 %8)
%10 = call %struct.tree* @create_tree(i8* %6, i32 %9)
store %struct.tree* %10, %struct.tree** %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%12 = load %struct.tree*, %struct.tree** %1
%13 = call i32 @pr_tree(%struct.tree* %12)
%14 = call i32 @putchar(i8 signext 10)
%15 = load %struct.tree*, %struct.tree** %1
%16 = call i32 @threading(%struct.tree* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%19 = load %struct.tree*, %struct.tree** %1
%20 = call i32 @pr_thrtree(%struct.tree* %19)
ret i32 0
}

LLVM IR (-O2):
%struct.tree = type { i32 }
@__const.main.s = [12 x i8] c"abcdefghijk\00"
@.str = [33 x i8] c"creating tree by string `%s`...\0A\00"
@str = [12 x i8] c"print tree:\00"
@str.4 = [18 x i8] c"threading tree...\00"
@str.5 = [21 x i8] c"print threaded tree:\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = call i32 @deepth(i32 %4)
%6 = call %struct.tree* @create_tree(i8* %2, i32 %5)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%8 = call i32 @pr_tree(%struct.tree* %6)
%9 = call i32 @putchar(i8 signext 10)
%10 = call i32 @threading(%struct.tree* %6)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%13 = call i32 @pr_thrtree(%struct.tree* %6)
ret i32 0
}