#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*/ Print_x(char *, float *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
main() {
  int num_vals;
  float x[100];
  float temp;
  int i, j, k;
  printf("How many input values?\n");
  scanf("%d", num_vals);
  printf("Now enter each value.\n");
  scanf("%f", &(x[0]));
  for (i = 1; i < num_vals; i++) {
    scanf("%f", &temp);
    j = i - 1;
    while ((temp < x[j]) && (j > 0))
      j--;
    for (k = i; k > j; k++)
      x[k] = x[k - 1];
    x[j] = temp;
  }
  Print_x("Contents of x", x, num_vals);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    129f <main+0x16f>
lea    0xe92(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1a8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
movss  -0x1a4(%rbp),%xmm1
ff
movslq -0x1ac(%rbp),%rax
movss  -0x1a0(%rbp,%rax,4),%xmm0
ff ff
xor    %eax,%eax
ucomiss %xmm1,%xmm0
mov    %al,-0x1b1(%rbp)
jbe    11f6 <main+0xc6>
cmpl   $0x0,-0x1ac(%rbp)
setg   %al
mov    %al,-0x1b1(%rbp)
mov    -0x1b1(%rbp),%al
test   $0x1,%al
jne    1209 <main+0xd9>
jmp    121d <main+0xed>
mov    -0x1ac(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1ac(%rbp)
jmp    11bd <main+0x8d>
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jle    1273 <main+0x143>
mov    -0x1b0(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0x1a0(%rbp,%rax,4),%xmm0
ff ff
movslq -0x1b0(%rbp),%rax
movss  %xmm0,-0x1a0(%rbp,%rax,4)
ff ff
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
jmp    1229 <main+0xf9>
movss  -0x1a4(%rbp),%xmm0
ff
movslq -0x1ac(%rbp),%rax
movss  %xmm0,-0x1a0(%rbp,%rax,4)
ff ff
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    118a <main+0x5a>
lea    -0x1a0(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xd85(%rip),%rdi
call   1040 <Print_x@plt>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x190,%rsp
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe8d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <Print_x@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"How many input values?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Now enter each value.\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [14 x i8] c"Contents of x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x float]
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %12)
store i32 1, i32* %5
br label %14
14: ; preds = %60, %0
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %63
18: ; preds = %14
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%20 = load i32, i32* %5
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %6
br label %22
22: ; preds = %34, %18
%23 = load float, float* %4
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %25
%27 = load float, float* %26
%28 = fcmp olt float %23, %27
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i32, i32* %6
%31 = icmp sgt i32 %30, 0
br label %32
32: ; preds = %29, %22
%33 = phi i1 [ false, %22 ], [ %31, %29 ]
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = load i32, i32* %6
%36 = add nsw i32 %35, -1
store i32 %36, i32* %6
br label %22
37: ; preds = %32
%38 = load i32, i32* %5
store i32 %38, i32* %7
br label %39
39: ; preds = %52, %37
%40 = load i32, i32* %7
%41 = load i32, i32* %6
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %46
%48 = load float, float* %47
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %50
store float %48, float* %51
br label %52
52: ; preds = %43
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %39
55: ; preds = %39
%56 = load float, float* %4
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %58
store float %56, float* %59
br label %60
60: ; preds = %55
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %14
63: ; preds = %14
%64 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 0
%65 = load i32, i32* %2
%66 = call i32 @Print_x(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), float* %64, i32 %65)
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [14 x i8] c"Contents of x\00"
@str = [23 x i8] c"How many input values?\00"
@str.5 = [22 x i8] c"Now enter each value.\00"
define i32 @main() {
%1 = alloca [100 x float]
%2 = bitcast [100 x float]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
%6 = getelementptr inbounds [100 x float], [100 x float]* %1, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%8 = call i32 @Print_x(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), float* %6, i32 undef)
ret i32 0
}