#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  struct entry {
    int value;
    struct entry *next;
  };
  struct entry n1, n2, n3;
  struct entry *list_pointer = &n1;
  n1.value = 1;
  n1.next = &n2;
  n2.value = 2;
  n2.next = &n3;
  n3.value = 3;
  n3.next = (struct entry *)0;
  while (list_pointer != (struct entry *)0) {
    printf("%i\n", list_pointer->value);
    list_pointer = list_pointer->next;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x28(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x3,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1182 <main+0x72>
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    1154 <main+0x44>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
movl   $0x2,0x18(%rsp)
lea    0x8(%rsp),%rax
mov    %rax,0x20(%rsp)
movl   $0x3,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xeb6(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    (%rsp),%rbx
test   %rbx,%rbx
je     1183 <main+0x73>
lea    0xe9c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%rbx
test   %rbx,%rbx
jne    1170 <main+0x60>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.entry = type { i32, %struct.entry* }
@.str = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.entry
%3 = alloca %struct.entry
%4 = alloca %struct.entry
%5 = alloca %struct.entry*
store i32 0, i32* %1
store %struct.entry* %2, %struct.entry** %5
%6 = getelementptr inbounds %struct.entry, %struct.entry* %2, i32 0, i32 0
store i32 1, i32* %6
%7 = getelementptr inbounds %struct.entry, %struct.entry* %2, i32 0, i32 1
store %struct.entry* %3, %struct.entry** %7
%8 = getelementptr inbounds %struct.entry, %struct.entry* %3, i32 0, i32 0
store i32 2, i32* %8
%9 = getelementptr inbounds %struct.entry, %struct.entry* %3, i32 0, i32 1
store %struct.entry* %4, %struct.entry** %9
%10 = getelementptr inbounds %struct.entry, %struct.entry* %4, i32 0, i32 0
store i32 3, i32* %10
%11 = getelementptr inbounds %struct.entry, %struct.entry* %4, i32 0, i32 1
store %struct.entry* null, %struct.entry** %11
br label %12
12: ; preds = %15, %0
%13 = load %struct.entry*, %struct.entry** %5
%14 = icmp ne %struct.entry* %13, null
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load %struct.entry*, %struct.entry** %5
%17 = getelementptr inbounds %struct.entry, %struct.entry* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load %struct.entry*, %struct.entry** %5
%21 = getelementptr inbounds %struct.entry, %struct.entry* %20, i32 0, i32 1
%22 = load %struct.entry*, %struct.entry** %21
store %struct.entry* %22, %struct.entry** %5
br label %12
23: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
%struct.entry = type { i32, %struct.entry* }
@.str = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca %struct.entry*
%2 = alloca %struct.entry
%3 = alloca %struct.entry
%4 = bitcast %struct.entry** %1 to i8*
%5 = bitcast %struct.entry* %2 to i8*
%6 = bitcast %struct.entry* %3 to i8*
store %struct.entry* %2, %struct.entry** %1
%7 = getelementptr inbounds %struct.entry, %struct.entry* %2, i64 0, i32 0
store i32 2, i32* %7
%8 = getelementptr inbounds %struct.entry, %struct.entry* %2, i64 0, i32 1
store %struct.entry* %3, %struct.entry** %8
%9 = getelementptr inbounds %struct.entry, %struct.entry* %3, i64 0, i32 0
store i32 3, i32* %9
%10 = getelementptr inbounds %struct.entry, %struct.entry* %3, i64 0, i32 1
store %struct.entry* null, %struct.entry** %10
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = load %struct.entry*, %struct.entry** %1
%13 = icmp eq %struct.entry* %12, null
br i1 %13, label %22, label %14
14: ; preds = %0, %14
%15 = phi %struct.entry* [ %20, %14 ], [ %12, %0 ]
%16 = getelementptr inbounds %struct.entry, %struct.entry* %15, i64 0, i32 0
%17 = getelementptr inbounds %struct.entry, %struct.entry* %15, i64 0, i32 1
%18 = load i32, i32* %16
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load %struct.entry*, %struct.entry** %17
%21 = icmp eq %struct.entry* %20, null
br i1 %21, label %22, label %14
22: ; preds = %14, %0
ret i32 0
}