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

/* Variables and functions */
int intlist_extract_min(struct intlist **);
int /*<<< orphan*/ intlist_free(struct intlist **);
int /*<<< orphan*/ intlist_prepend(int, struct intlist **);
int /*<<< orphan*/ intlist_print(struct intlist **);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i;
  int a[10];
  struct intlist *lp = 0;
  for (i = 0; i < 10; i++)
    a[i] = i;
  for (i = 0; i < 10; i++)
    intlist_prepend(a[i], &lp);
  intlist_print(&lp);
  intlist_free(&lp);
  printf("\n");
  lp = 0;
  intlist_prepend(5, &lp);
  intlist_prepend(3, &lp);
  intlist_prepend(7, &lp);
  while (lp) {
    int min = intlist_extract_min(&lp);
    printf("%d\n", min);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1191 <main+0x41>
mov    -0x8(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x1e>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11c1 <main+0x71>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
lea    -0x38(%rbp),%rsi
call   1070 <intlist_prepend@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <main+0x48>
lea    -0x38(%rbp),%rdi
call   1040 <intlist_print@plt>
lea    -0x38(%rbp),%rdi
call   1050 <intlist_free@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movq   $0x0,-0x38(%rbp)
mov    $0x5,%edi
lea    -0x38(%rbp),%rsi
call   1070 <intlist_prepend@plt>
mov    $0x3,%edi
lea    -0x38(%rbp),%rsi
call   1070 <intlist_prepend@plt>
mov    $0x7,%edi
lea    -0x38(%rbp),%rsi
call   1070 <intlist_prepend@plt>
cmpq   $0x0,-0x38(%rbp)
je     1240 <main+0xf0>
lea    -0x38(%rbp),%rdi
call   1030 <intlist_extract_min@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1213 <main+0xc3>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x6,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x7,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x8,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x9,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    %rbx,%rdi
call   1050 <intlist_print@plt>
mov    %rbx,%rdi
call   1060 <intlist_free@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movq   $0x0,(%rsp)
mov    $0x5,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
mov    $0x7,%edi
mov    %rbx,%rsi
call   1080 <intlist_prepend@plt>
cmpq   $0x0,(%rsp)
je     126b <main+0x10b>
mov    %rsp,%r14
lea    0xdb8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <intlist_extract_min@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
cmpq   $0x0,(%rsp)
jne    1250 <main+0xf0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.intlist = type { i32 }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca %struct.intlist*
%5 = alloca i32
store i32 0, i32* %1
store %struct.intlist* null, %struct.intlist** %4
store i32 0, i32* %2
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %12
store i32 %10, i32* %13
br label %14
14: ; preds = %9
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %6
17: ; preds = %6
store i32 0, i32* %2
br label %18
18: ; preds = %27, %17
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 10
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 @intlist_prepend(i32 %25, %struct.intlist** %4)
br label %27
27: ; preds = %21
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %18
30: ; preds = %18
%31 = call i32 @intlist_print(%struct.intlist** %4)
%32 = call i32 @intlist_free(%struct.intlist** %4)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store %struct.intlist* null, %struct.intlist** %4
%34 = call i32 @intlist_prepend(i32 5, %struct.intlist** %4)
%35 = call i32 @intlist_prepend(i32 3, %struct.intlist** %4)
%36 = call i32 @intlist_prepend(i32 7, %struct.intlist** %4)
br label %37
37: ; preds = %40, %30
%38 = load %struct.intlist*, %struct.intlist** %4
%39 = icmp ne %struct.intlist* %38, null
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i32 @intlist_extract_min(%struct.intlist** %4)
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
br label %37
44: ; preds = %37
ret i32 0
}

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