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

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ add_word_recursively(struct Node *, char *);
int /*<<< orphan*/ clear_tree_recursively(struct Node *);
struct Node *create_node(char *);
char *get_word();
int /*<<< orphan*/ print_tree_recursively(struct Node *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "RUS");
  struct Node *root = NULL;
  char *new_word;
  puts("Введите слова (ввод знака '!' означает прекращение ввода)");
  while (1) {
    new_word = get_word();
    if (new_word == NULL) {
      break;
    }
    if (root == NULL) {
      root = create_node(new_word);
    } else {
      add_word_recursively(root, new_word);
    }
  }
  print_tree_recursively(root);
  clear_tree_recursively(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1050 <setlocale@plt>
movq   $0x0,-0x10(%rbp)
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1060 <get_word@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c3 <main+0x53>
jmp    11f2 <main+0x82>
cmpq   $0x0,-0x10(%rbp)
jne    11e0 <main+0x70>
mov    -0x18(%rbp),%rdi
call   1080 <create_node@plt>
mov    %rax,-0x10(%rbp)
jmp    11ed <main+0x7d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <add_word_recursively@plt>
jmp    11a8 <main+0x38>
mov    -0x10(%rbp),%rdi
call   1090 <print_tree_recursively@plt>
mov    -0x10(%rbp),%rdi
call   1030 <clear_tree_recursively@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1050 <setlocale@plt>
lea    0xe77(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <get_word@plt>
test   %rax,%rax
je     11d9 <main+0x69>
xor    %ebx,%ebx
jmp    11c7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <add_word_recursively@plt>
xor    %eax,%eax
call   1060 <get_word@plt>
test   %rax,%rax
je     11d9 <main+0x69>
test   %rbx,%rbx
jne    11b0 <main+0x40>
mov    %rax,%rdi
call   1080 <create_node@plt>
mov    %rax,%rbx
jmp    11bb <main+0x4b>
mov    %rbx,%rdi
call   1090 <print_tree_recursively@plt>
mov    %rbx,%rdi
call   1030 <clear_tree_recursively@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
@LC_ALL = global i32 0
@.str = [4 x i8] c"RUS\00"
@.str.1 = [103 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D1\81\D0\BB\D0\BE\D0\B2\D0\B0 (\D0\B2\D0\B2\D0\BE\D0\B4 \D0\B7\D0\BD\D0\B0\D0\BA\D0\B0 '!' \D0\BE\D0\B7\D0\BD\D0\B0\D1\87\D0\B0\D0\B5\D1\82 \D0\BF\D1\80\D0\B5\D0\BA\D1\80\D0\B0\D1\89\D0\B5\D0\BD\D0\B8\D0\B5 \D0\B2\D0\B2\D0\BE\D0\B4\D0\B0)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Node*
%3 = alloca i8*
store i32 0, i32* %1
%4 = load i32, i32* @LC_ALL
%5 = call i32 @setlocale(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store %struct.Node* null, %struct.Node** %2
%6 = call i32 @puts(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %0, %22
%8 = call i8* (...) @get_word()
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %7
br label %23
12: ; preds = %7
%13 = load %struct.Node*, %struct.Node** %2
%14 = icmp eq %struct.Node* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = call %struct.Node* @create_node(i8* %16)
store %struct.Node* %17, %struct.Node** %2
br label %22
18: ; preds = %12
%19 = load %struct.Node*, %struct.Node** %2
%20 = load i8*, i8** %3
%21 = call i32 @add_word_recursively(%struct.Node* %19, i8* %20)
br label %22
22: ; preds = %18, %15
br label %7
23: ; preds = %11
%24 = load %struct.Node*, %struct.Node** %2
%25 = call i32 @print_tree_recursively(%struct.Node* %24)
%26 = load %struct.Node*, %struct.Node** %2
%27 = call i32 @clear_tree_recursively(%struct.Node* %26)
ret i32 0
}

LLVM IR (-O2):
%struct.Node = type { i32 }
@LC_ALL = global i32 0
@.str = [4 x i8] c"RUS\00"
@.str.1 = [103 x i8] c"\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D1\81\D0\BB\D0\BE\D0\B2\D0\B0 (\D0\B2\D0\B2\D0\BE\D0\B4 \D0\B7\D0\BD\D0\B0\D0\BA\D0\B0 '!' \D0\BE\D0\B7\D0\BD\D0\B0\D1\87\D0\B0\D0\B5\D1\82 \D0\BF\D1\80\D0\B5\D0\BA\D1\80\D0\B0\D1\89\D0\B5\D0\BD\D0\B8\D0\B5 \D0\B2\D0\B2\D0\BE\D0\B4\D0\B0)\00"
define i32 @main() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i32 @setlocale(i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* (...) @get_word()
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %0, %14
%7 = phi i8* [ %16, %14 ], [ %4, %0 ]
%8 = phi %struct.Node* [ %15, %14 ], [ null, %0 ]
%9 = icmp eq %struct.Node* %8, null
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call %struct.Node* @create_node(i8* %7)
br label %14
12: ; preds = %6
%13 = tail call i32 @add_word_recursively(%struct.Node* %8, i8* %7)
br label %14
14: ; preds = %12, %10
%15 = phi %struct.Node* [ %11, %10 ], [ %8, %12 ]
%16 = tail call i8* (...) @get_word()
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %6
18: ; preds = %14, %0
%19 = phi %struct.Node* [ null, %0 ], [ %15, %14 ]
%20 = tail call i32 @print_tree_recursively(%struct.Node* %19)
%21 = tail call i32 @clear_tree_recursively(%struct.Node* %19)
ret i32 0
}