#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*/ length(struct node *);
int /*<<< orphan*/ print(struct node *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push(struct node **, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char ans;
  int num;
  struct node *head = NULL;
  do {
    printf("Enter a number: ");
    scanf("%d", &num);
    push(&head, num);
    printf("Do you want another num (y or n): ");
    scanf("%1s", &ans);
  } while (ans == 'y');
  print(head, length(head));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1070 <push@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
je     1167 <main+0x17>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <length@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <print@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
lea    0xea3(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xe95(%rip),%rbx
lea    0xeb1(%rip),%rbp
lea    0xb(%rsp),%r14
nopl   0x0(%rax,%rax,1)
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r13,%rdi
call   1070 <push@plt>
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpb   $0x79,0xb(%rsp)
je     1190 <main+0x40>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <length@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <print@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Do you want another num (y or n): \00"
@.str.3 = [4 x i8] c"%1s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca %struct.node*
store i32 0, i32* %1
store %struct.node* null, %struct.node** %4
br label %5
5: ; preds = %12, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 @push(%struct.node** %4, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %12
12: ; preds = %5
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 121
br i1 %15, label %5, label %16
16: ; preds = %12
%17 = load %struct.node*, %struct.node** %4
%18 = load %struct.node*, %struct.node** %4
%19 = call i32 @length(%struct.node* %18)
%20 = call i32 @print(%struct.node* %17, i32 %19)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Do you want another num (y or n): \00"
@.str.3 = [4 x i8] c"%1s\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca %struct.node*
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.node** %3 to i8*
store %struct.node* null, %struct.node** %3
br label %6
6: ; preds = %6, %0
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i32 @push(%struct.node** %3, i32 %9)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 121
br i1 %14, label %6, label %15
15: ; preds = %6
%16 = load %struct.node*, %struct.node** %3
%17 = call i32 @length(%struct.node* %16)
%18 = call i32 @print(%struct.node* %16, i32 %17)
ret i32 0
}