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

/* Variables and functions */
struct double_node *add_double_linked_list(struct double_node *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
struct double_node *add_nodes_double_linked_list(struct double_node *list) {
  int data;
  printf("enter numbers!(enter 0 to leave loop)\r\n");
  for (;;) {
    scanf("%d", &data);
    if (data == 0)
      return list;
    list = add_double_linked_list(list, data);
  }
}


x86 assembly (clang, -O0):
<add_nodes_double_linked_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    116c <add_nodes_double_linked_list+0x3c>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <add_double_linked_list@plt>
mov    %rax,-0x8(%rbp)
jmp    1148 <add_nodes_double_linked_list+0x18>

x86 assembly (clang, -O2):
<add_nodes_double_linked_list>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     118e <add_nodes_double_linked_list+0x5e>
lea    0xe98(%rip),%r14
lea    0xc(%rsp),%r15
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <add_double_linked_list@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jne    1170 <add_nodes_double_linked_list+0x40>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.double_node = type { i32 }
@.str = [40 x i8] c"enter numbers!(enter 0 to leave loop)\0D\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define %struct.double_node* @add_nodes_double_linked_list(%struct.double_node* %0) {
%2 = alloca %struct.double_node*
%3 = alloca i32
store %struct.double_node* %0, %struct.double_node** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %11, %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = load %struct.double_node*, %struct.double_node** %2
ret %struct.double_node* %10
11: ; preds = %5
%12 = load %struct.double_node*, %struct.double_node** %2
%13 = load i32, i32* %3
%14 = call %struct.double_node* @add_double_linked_list(%struct.double_node* %12, i32 %13)
store %struct.double_node* %14, %struct.double_node** %2
br label %5
}

LLVM IR (-O2):
%struct.double_node = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@str = [39 x i8] c"enter numbers!(enter 0 to leave loop)\0D\00"
define %struct.double_node* @add_nodes_double_linked_list(%struct.double_node* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %10, %1
%9 = phi %struct.double_node* [ %0, %1 ], [ %13, %10 ]
ret %struct.double_node* %9
10: ; preds = %1, %10
%11 = phi i32 [ %15, %10 ], [ %6, %1 ]
%12 = phi %struct.double_node* [ %13, %10 ], [ %0, %1 ]
%13 = call %struct.double_node* @add_double_linked_list(%struct.double_node* %12, i32 %11)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
br i1 %16, label %8, label %10
}