#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*/ add_node(struct node **, int /*<<< orphan*/);
int /*<<< orphan*/ create_node(int);
scalar_t__ delete (struct node **, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ pre_search_node(struct node *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main() {
  int data[12] = {51, 31, 3, 47, 45, 78, 67, 58, 72, 99, 85, 105};
  int i;
  struct node *root = NULL;
  printf("      ");
  for (i = 0; i < 12; i++) {
    add_node(&root, create_node(data[i]));
    printf("%2d ", data[i]);
  }
  printf("\npre : ");
  pre_search_node(root);
  printf("\n");
  scanf("%d", &i);
  if (delete (&root, i) != 0) {
    fprintf(stderr, "error!\n");
    return -1;
  }
  printf("pre : ");
  pre_search_node(root);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
movq   $0x0,-0x50(%rbp)
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xc,-0x44(%rbp)
jge    1207 <main+0x87>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edi
call   1090 <create_node@plt>
mov    %eax,%esi
lea    -0x50(%rbp),%rdi
call   1040 <add_node@plt>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c1 <main+0x41>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rdi
call   10a0 <pre_search_node@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe11(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x44(%rbp),%esi
lea    -0x50(%rbp),%rdi
call   1080 <delete@plt>
cmp    $0x0,%rax
je     1273 <main+0xf3>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129f <main+0x11f>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rdi
call   10a0 <pre_search_node@plt>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe68(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x33,%edi
call   1090 <create_node@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
lea    0xe45(%rip),%rbp
mov    %rbp,%rdi
mov    $0x33,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x1,0x4(%rsp)
mov    $0x1f,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x1f,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x2,0x4(%rsp)
mov    $0x3,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x3,0x4(%rsp)
mov    $0x2f,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x2f,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x4,0x4(%rsp)
mov    $0x2d,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x2d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x5,0x4(%rsp)
mov    $0x4e,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x4e,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x6,0x4(%rsp)
mov    $0x43,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x43,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x7,0x4(%rsp)
mov    $0x3a,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x3a,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x8,0x4(%rsp)
mov    $0x48,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x48,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x9,0x4(%rsp)
mov    $0x63,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x63,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xa,0x4(%rsp)
mov    $0x55,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x55,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xb,0x4(%rsp)
mov    $0x69,%edi
call   1090 <create_node@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <add_node@plt>
mov    %rbp,%rdi
mov    $0x69,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xc,0x4(%rsp)
lea    0xc53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   10a0 <pre_search_node@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc39(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1080 <delete@plt>
test   %rax,%rax
je     1413 <main+0x293>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
lea    0xc11(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    1435 <main+0x2b5>
lea    0xbf3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   10a0 <pre_search_node@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@__const.main.data = [12 x i32] [i32 51, i32 31, i32 3, i32 47, i32 45, i32 78, i32 67, i32 58, i32 72, i32 99, i32 85, i32 105]
@.str = [7 x i8] c" \00"
@.str.1 = [5 x i8] c"%2d \00"
@.str.2 = [8 x i8] c"\0Apre : \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.5 = [8 x i8] c"error!\0A\00"
@.str.6 = [7 x i8] c"pre : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca i32
%4 = alloca %struct.node*
store i32 0, i32* %1
%5 = bitcast [12 x i32]* %2 to i8*
store %struct.node* null, %struct.node** %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 12
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @create_node(i32 %14)
%16 = call i32 @add_node(%struct.node** %4, i32 %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %10
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %7
25: ; preds = %7
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%27 = load %struct.node*, %struct.node** %4
%28 = call i32 @pre_search_node(%struct.node* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%31 = load i32, i32* %3
%32 = call i64 @delete(%struct.node** %4, i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %25
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %42
37: ; preds = %25
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%39 = load %struct.node*, %struct.node** %4
%40 = call i32 @pre_search_node(%struct.node* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %42
42: ; preds = %37, %34
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [7 x i8] c" \00"
@.str.1 = [5 x i8] c"%2d \00"
@.str.2 = [8 x i8] c"\0Apre : \00"
@.str.4 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.5 = [8 x i8] c"error!\0A\00"
@.str.6 = [7 x i8] c"pre : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.node** %2 to i8*
store %struct.node* null, %struct.node** %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @create_node(i32 51)
%7 = call i32 @add_node(%struct.node** %2, i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 51)
store i32 1, i32* %1
%9 = call i32 @create_node(i32 31)
%10 = call i32 @add_node(%struct.node** %2, i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 31)
store i32 2, i32* %1
%12 = call i32 @create_node(i32 3)
%13 = call i32 @add_node(%struct.node** %2, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 3)
store i32 3, i32* %1
%15 = call i32 @create_node(i32 47)
%16 = call i32 @add_node(%struct.node** %2, i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 47)
store i32 4, i32* %1
%18 = call i32 @create_node(i32 45)
%19 = call i32 @add_node(%struct.node** %2, i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 45)
store i32 5, i32* %1
%21 = call i32 @create_node(i32 78)
%22 = call i32 @add_node(%struct.node** %2, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 78)
store i32 6, i32* %1
%24 = call i32 @create_node(i32 67)
%25 = call i32 @add_node(%struct.node** %2, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 67)
store i32 7, i32* %1
%27 = call i32 @create_node(i32 58)
%28 = call i32 @add_node(%struct.node** %2, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 58)
store i32 8, i32* %1
%30 = call i32 @create_node(i32 72)
%31 = call i32 @add_node(%struct.node** %2, i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 72)
store i32 9, i32* %1
%33 = call i32 @create_node(i32 99)
%34 = call i32 @add_node(%struct.node** %2, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 99)
store i32 10, i32* %1
%36 = call i32 @create_node(i32 85)
%37 = call i32 @add_node(%struct.node** %2, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 85)
store i32 11, i32* %1
%39 = call i32 @create_node(i32 105)
%40 = call i32 @add_node(%struct.node** %2, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 105)
store i32 12, i32* %1
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%43 = load %struct.node*, %struct.node** %2
%44 = call i32 @pre_search_node(%struct.node* %43)
%45 = call i32 @putchar(i32 10)
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%47 = load i32, i32* %1
%48 = call i64 @delete(%struct.node** %2, i32 %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %0
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %58
53: ; preds = %0
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%55 = load %struct.node*, %struct.node** %2
%56 = call i32 @pre_search_node(%struct.node* %55)
%57 = call i32 @putchar(i32 10)
br label %58
58: ; preds = %53, %50
%59 = phi i32 [ -1, %50 ], [ 0, %53 ]
ret i32 %59
}