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

/* Variables and functions */
struct list_node_s *Create_node(int, struct list_node_s *);
int /*<<< orphan*/ Print(struct list_node_s *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  struct list_node_s *head_p = NULL;
  int val;
  printf("Enter an int, <= 0 to stop\n");
  scanf("%d", &val);
  while (val > 0) {
    head_p = Create_node(val, head_p);
    scanf("%d", &val);
  }
  Print(head_p);
  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
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11a2 <main+0x62>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Create_node@plt>
mov    %rax,-0x10(%rbp)
lea    0xe88(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1173 <main+0x33>
mov    -0x10(%rbp),%rdi
call   1060 <Print@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
xor    %ebx,%ebx
test   %edi,%edi
jle    119e <main+0x5e>
lea    0xe89(%rip),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax)
mov    %rbx,%rsi
call   1040 <Create_node@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jg     1180 <main+0x40>
mov    %rbx,%rdi
call   1060 <Print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.list_node_s = type { i32 }
@.str = [28 x i8] c"Enter an int, <= 0 to stop\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.list_node_s*
%3 = alloca i32
store i32 0, i32* %1
store %struct.list_node_s* null, %struct.list_node_s** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 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* %3)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load %struct.list_node_s*, %struct.list_node_s** %2
%12 = call %struct.list_node_s* @Create_node(i32 %10, %struct.list_node_s* %11)
store %struct.list_node_s* %12, %struct.list_node_s** %2
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
14: ; preds = %6
%15 = load %struct.list_node_s*, %struct.list_node_s** %2
%16 = call i32 @Print(%struct.list_node_s* %15)
ret i32 0
}

LLVM IR (-O2):
%struct.list_node_s = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@str = [27 x i8] c"Enter an int, <= 0 to stop\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = phi i32 [ %12, %7 ], [ %5, %0 ]
%9 = phi %struct.list_node_s* [ %10, %7 ], [ null, %0 ]
%10 = call %struct.list_node_s* @Create_node(i32 %8, %struct.list_node_s* %9)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %7, %0
%15 = phi %struct.list_node_s* [ null, %0 ], [ %10, %7 ]
%16 = call i32 @Print(%struct.list_node_s* %15)
ret i32 0
}