#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int *list, i = 0, j = 0, size = 0, tmp;
  printf("How many elements do you want in your list?\n");
  scanf("%d", &size);
  list = (int *)malloc(size * sizeof(int));
  printf("Please enter the numbers.\n");
  for (i = 0; i < size; i++) {
    scanf("%d", list + i);
  }
  printf("The list you entered is ");
  for (i = 0; i < size; i++) {
    printf("%d ", *(list + i));
  }
  printf(".\n");
  for (i = 0; i < size - 1; i++) {
    for (j = i + 1; j < size; j++) {
      if (*(list + i) > *(list + j)) {
        tmp = *(list + i);
        *(list + i) = *(list + j);
        *(list + j) = tmp;
      } else
        continue;
    }
  }
  printf("The list sorted in ascending order is ");
  for (i = 0; i < size; i++) {
    printf("%d ", *(list + i));
  }
  printf(".\n");
  free(list);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11df <main+0x9f>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe61(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11aa <main+0x6a>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1227 <main+0xe7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f4 <main+0xb4>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12e0 <main+0x1a0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12cd <main+0x18d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    12b5 <main+0x175>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    12ba <main+0x17a>
jmp    12bf <main+0x17f>
jmp    12bf <main+0x17f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1256 <main+0x116>
jmp    12d2 <main+0x192>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123c <main+0xfc>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1328 <main+0x1e8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12f5 <main+0x1b5>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xee0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xee0(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    11cd <main+0x7d>
xor    %r12d,%r12d
lea    0xe57(%rip),%r14
mov    %rbx,%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%r12
jl     11b0 <main+0x60>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    120c <main+0xbc>
lea    0xe33(%rip),%r14
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    (%rbx,%r15,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
movslq 0x4(%rsp),%rax
cmp    %rax,%r15
jl     11f0 <main+0xa0>
lea    0xe78(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jl     127e <main+0x12e>
mov    $0x1,%r9d
xor    %r8d,%r8d
jmp    123f <main+0xef>
nopl   0x0(%rax)
lea    -0x1(%rax),%ecx
movslq %ecx,%rcx
add    $0x1,%r9
cmp    %rcx,%r8
jge    127e <main+0x12e>
mov    %r8,%rsi
add    $0x1,%r8
movslq %eax,%rcx
cmp    %rcx,%r8
jge    1230 <main+0xe0>
mov    %r9,%rdi
jmp    1268 <main+0x118>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdi
cmp    %edi,%eax
jle    1230 <main+0xe0>
mov    (%rbx,%rsi,4),%edx
mov    (%rbx,%rdi,4),%ecx
cmp    %ecx,%edx
jle    1260 <main+0x110>
mov    %ecx,(%rbx,%rsi,4)
mov    %edx,(%rbx,%rdi,4)
mov    0x4(%rsp),%eax
jmp    1260 <main+0x110>
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    12bc <main+0x16c>
lea    0xd82(%rip),%r14
xor    %r15d,%r15d
nopl   (%rax)
mov    (%rbx,%r15,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
movslq 0x4(%rsp),%rax
cmp    %rax,%r15
jl     12a0 <main+0x150>
lea    0xdc8(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"How many elements do you want in your list?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Please enter the numbers.\0A\00"
@.str.3 = [25 x i8] c"The list you entered is \00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [3 x i8] c".\0A\00"
@.str.6 = [39 x i8] c"The list sorted in ascending order is \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %16
16: ; preds = %26, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i32*, i32** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %20
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %16
29: ; preds = %16
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %31
31: ; preds = %42, %29
%32 = load i32, i32* %3
%33 = load i32, i32* %5
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %45
35: ; preds = %31
%36 = load i32*, i32** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %31
45: ; preds = %31
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %47
47: ; preds = %97, %45
%48 = load i32, i32* %3
%49 = load i32, i32* %5
%50 = sub nsw i32 %49, 1
%51 = icmp slt i32 %48, %50
br i1 %51, label %52, label %100
52: ; preds = %47
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %55
55: ; preds = %93, %52
%56 = load i32, i32* %4
%57 = load i32, i32* %5
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %96
59: ; preds = %55
%60 = load i32*, i32** %2
%61 = load i32, i32* %3
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %63
%65 = load i32*, i32** %2
%66 = load i32, i32* %4
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
%69 = load i32, i32* %68
%70 = icmp sgt i32 %64, %69
br i1 %70, label %71, label %91
71: ; preds = %59
%72 = load i32*, i32** %2
%73 = load i32, i32* %3
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
store i32 %76, i32* %6
%77 = load i32*, i32** %2
%78 = load i32, i32* %4
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32, i32* %77, i64 %79
%81 = load i32, i32* %80
%82 = load i32*, i32** %2
%83 = load i32, i32* %3
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %82, i64 %84
store i32 %81, i32* %85
%86 = load i32, i32* %6
%87 = load i32*, i32** %2
%88 = load i32, i32* %4
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %87, i64 %89
store i32 %86, i32* %90
br label %92
91: ; preds = %59
br label %93
92: ; preds = %71
br label %93
93: ; preds = %92, %91
%94 = load i32, i32* %4
%95 = add nsw i32 %94, 1
store i32 %95, i32* %4
br label %55
96: ; preds = %55
br label %97
97: ; preds = %96
%98 = load i32, i32* %3
%99 = add nsw i32 %98, 1
store i32 %99, i32* %3
br label %47
100: ; preds = %47
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %102
102: ; preds = %113, %100
%103 = load i32, i32* %3
%104 = load i32, i32* %5
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %116
106: ; preds = %102
%107 = load i32*, i32** %2
%108 = load i32, i32* %3
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i32, i32* %107, i64 %109
%111 = load i32, i32* %110
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %106
%114 = load i32, i32* %3
%115 = add nsw i32 %114, 1
store i32 %115, i32* %3
br label %102
116: ; preds = %102
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%118 = load i32*, i32** %2
%119 = call i32 @free(i32* %118)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [25 x i8] c"The list you entered is \00"
@.str.4 = [4 x i8] c"%d \00"
@.str.6 = [39 x i8] c"The list sorted in ascending order is \00"
@str = [44 x i8] c"How many elements do you want in your list?\00"
@str.7 = [26 x i8] c"Please enter the numbers.\00"
@str.9 = [2 x i8] c".\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 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 = shl i32 %5, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds i32, i32* %8, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %20, %24
%25 = phi i64 [ %29, %24 ], [ 0, %20 ]
%26 = getelementptr inbounds i32, i32* %8, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %25, 1
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %24, label %33
33: ; preds = %24, %20
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%35 = load i32, i32* %1
%36 = icmp sgt i32 %35, 1
br i1 %36, label %43, label %68
37: ; preds = %62, %43
%38 = phi i32 [ %44, %43 ], [ %63, %62 ]
%39 = add nsw i32 %38, -1
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %47, %40
%42 = add nuw nsw i64 %46, 1
br i1 %41, label %43, label %68
43: ; preds = %33, %37
%44 = phi i32 [ %38, %37 ], [ %35, %33 ]
%45 = phi i64 [ %47, %37 ], [ 0, %33 ]
%46 = phi i64 [ %42, %37 ], [ 1, %33 ]
%47 = add nuw nsw i64 %45, 1
%48 = sext i32 %44 to i64
%49 = icmp slt i64 %47, %48
br i1 %49, label %50, label %37
50: ; preds = %43
%51 = getelementptr inbounds i32, i32* %8, i64 %45
br label %52
52: ; preds = %50, %62
%53 = phi i32 [ %44, %50 ], [ %63, %62 ]
%54 = phi i32 [ %44, %50 ], [ %64, %62 ]
%55 = phi i64 [ %46, %50 ], [ %65, %62 ]
%56 = load i32, i32* %51
%57 = getelementptr inbounds i32, i32* %8, i64 %55
%58 = load i32, i32* %57
%59 = icmp sgt i32 %56, %58
br i1 %59, label %60, label %62
60: ; preds = %52
store i32 %58, i32* %51
store i32 %56, i32* %57
%61 = load i32, i32* %1
br label %62
62: ; preds = %52, %60
%63 = phi i32 [ %53, %52 ], [ %61, %60 ]
%64 = phi i32 [ %54, %52 ], [ %61, %60 ]
%65 = add nuw nsw i64 %55, 1
%66 = trunc i64 %65 to i32
%67 = icmp sgt i32 %64, %66
br i1 %67, label %52, label %37
68: ; preds = %37, %33
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%70 = load i32, i32* %1
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %81
72: ; preds = %68, %72
%73 = phi i64 [ %77, %72 ], [ 0, %68 ]
%74 = getelementptr inbounds i32, i32* %8, i64 %73
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %75)
%77 = add nuw nsw i64 %73, 1
%78 = load i32, i32* %1
%79 = sext i32 %78 to i64
%80 = icmp slt i64 %77, %79
br i1 %80, label %72, label %81
81: ; preds = %72, %68
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%83 = call i32 @free(i32* %8)
ret i32 0
}