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

/* Variables and functions */
int contains(struct Tnode *, int);
int /*<<< orphan*/ insert(struct Tnode **, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  struct Tnode *tree;
  int x;
  tree = NULL;
  printf("整数データを木構造に格納します\n");
  printf("いくつか入力してください(入力終りは -1)\n");
  while (1) {
    scanf("%d", &x);
    if (x == -1) {
      break;
    }
    insert(&tree, x);
  }
  printf("整数データを木構造から探します\n");
  printf("いくつか入力してください(入力終りは -1)\n");
  while (1) {
    scanf("%d", &x);
    if (x == -1) {
      break;
    }
    if (contains(tree, x) == 1) {
      printf(" %d はあります\n", x);
    } else {
      printf(" %d はありません\n", x);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1192 <main+0x52>
jmp    11a3 <main+0x63>
mov    -0x14(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1060 <insert@plt>
jmp    1173 <main+0x33>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11de <main+0x9e>
jmp    121f <main+0xdf>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <contains@plt>
cmp    $0x1,%eax
jne    1209 <main+0xc9>
mov    -0x14(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121a <main+0xda>
mov    -0x14(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bf <main+0x7f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0xffffffff,%esi
je     11cc <main+0x7c>
lea    0x10(%rsp),%r14
lea    0xe5e(%rip),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <insert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0xffffffff,%esi
jne    11b0 <main+0x60>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xe15(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0xffffffff,%esi
je     1253 <main+0x103>
lea    0xdfe(%rip),%r15
lea    0xe0c(%rip),%r12
lea    0xded(%rip),%r14
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
call   1050 <contains@plt>
cmp    $0x1,%eax
mov    0xc(%rsp),%esi
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0xffffffff,%esi
jne    1220 <main+0xd0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Tnode = type { i32 }
@.str = [47 x i8] c"\E6\95\B4\E6\95\B0\E3\83\87\E3\83\BC\E3\82\BF\E3\82\92\E6\9C\A8\E6\A7\8B\E9\80\A0\E3\81\AB\E6\A0\BC\E7\B4\8D\E3\81\97\E3\81\BE\E3\81\99\0A\00"
@.str.1 = [58 x i8] c"\E3\81\84\E3\81\8F\E3\81\A4\E3\81\8B\E5\85\A5\E5\8A\9B\E3\81\97\E3\81\A6\E3\81\8F\E3\81\A0\E3\81\95\E3\81\84(\E5\85\A5\E5\8A\9B\E7\B5\82\E3\82\8A\E3\81\AF -1)\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [47 x i8] c"\E6\95\B4\E6\95\B0\E3\83\87\E3\83\BC\E3\82\BF\E3\82\92\E6\9C\A8\E6\A7\8B\E9\80\A0\E3\81\8B\E3\82\89\E6\8E\A2\E3\81\97\E3\81\BE\E3\81\99\0A\00"
@.str.4 = [21 x i8] c" %d \E3\81\AF\E3\81\82\E3\82\8A\E3\81\BE\E3\81\99\0A\00"
@.str.5 = [24 x i8] c" %d \E3\81\AF\E3\81\82\E3\82\8A\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Tnode*
%3 = alloca i32
store i32 0, i32* %1
store %struct.Tnode* null, %struct.Tnode** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %0, %11
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %6
br label %14
11: ; preds = %6
%12 = load i32, i32* %3
%13 = call i32 @insert(%struct.Tnode** %2, i32 %12)
br label %6
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %14, %33
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %17
br label %34
22: ; preds = %17
%23 = load %struct.Tnode*, %struct.Tnode** %2
%24 = load i32, i32* %3
%25 = call i32 @contains(%struct.Tnode* %23, i32 %24)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %33
30: ; preds = %22
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %27
br label %17
34: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
%struct.Tnode = type { i32 }
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [21 x i8] c" %d \E3\81\AF\E3\81\82\E3\82\8A\E3\81\BE\E3\81\99\0A\00"
@.str.5 = [24 x i8] c" %d \E3\81\AF\E3\81\82\E3\82\8A\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@str = [46 x i8] c"\E6\95\B4\E6\95\B0\E3\83\87\E3\83\BC\E3\82\BF\E3\82\92\E6\9C\A8\E6\A7\8B\E9\80\A0\E3\81\AB\E6\A0\BC\E7\B4\8D\E3\81\97\E3\81\BE\E3\81\99\00"
@str.7 = [46 x i8] c"\E6\95\B4\E6\95\B0\E3\83\87\E3\83\BC\E3\82\BF\E3\82\92\E6\9C\A8\E6\A7\8B\E9\80\A0\E3\81\8B\E3\82\89\E6\8E\A2\E3\81\97\E3\81\BE\E3\81\99\00"
@str.8 = [57 x i8] c"\E3\81\84\E3\81\8F\E3\81\A4\E3\81\8B\E5\85\A5\E5\8A\9B\E3\81\97\E3\81\A6\E3\81\8F\E3\81\A0\E3\81\95\E3\81\84(\E5\85\A5\E5\8A\9B\E7\B5\82\E3\82\8A\E3\81\AF -1)\00"
define i32 @main() {
%1 = alloca %struct.Tnode*
%2 = alloca i32
%3 = bitcast %struct.Tnode** %1 to i8*
%4 = bitcast i32* %2 to i8*
store %struct.Tnode* null, %struct.Tnode** %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.8, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, -1
br i1 %9, label %16, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %14, %10 ], [ %8, %0 ]
%12 = call i32 @insert(%struct.Tnode** %1, i32 %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %10
16: ; preds = %10, %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.7, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.8, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, -1
br i1 %21, label %33, label %22
22: ; preds = %16, %22
%23 = phi i32 [ %31, %22 ], [ %20, %16 ]
%24 = load %struct.Tnode*, %struct.Tnode** %1
%25 = call i32 @contains(%struct.Tnode* %24, i32 %23)
%26 = icmp eq i32 %25, 1
%27 = load i32, i32* %2
%28 = select i1 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, i32 %27)
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %22
33: ; preds = %22, %16
ret i32 0
}