#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 /*<<< orphan*/ scanf(char *, int *);
main() {
  int i, temp, srt, nums[8];
  printf("Please insert %d integers:\n", 8);
  for (i = 0; i < 8; i++) {
    scanf("%d", &nums[i]);
  }
  srt = 0;
  while (!srt) {
    for (i = 0; i < 8 - 1; i++) {
      srt = 1;
      if (nums[i] > nums[i + 1]) {
        temp = nums[i];
        nums[i] = nums[i + 1];
        nums[i + 1] = temp;
        srt = 0;
        i = 8;
      }
    }
  }
  printf("In order:\n");
  for (i = 0; i < 8; i++) {
    printf("nums[%d]: %d\n", i, nums[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    117c <main+0x5c>
movslq -0x8(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb3(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x29>
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1199 <main+0x79>
jmp    1220 <main+0x100>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    121b <main+0xfb>
movl   $0x1,-0x10(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    1208 <main+0xe8>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
movl   $0x0,-0x10(%rbp)
movl   $0x8,-0x8(%rbp)
jmp    120d <main+0xed>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a0 <main+0x80>
jmp    1183 <main+0x63>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1266 <main+0x146>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1235 <main+0x115>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
lea    0xec3(%rip),%rdi
xor    %ebp,%ebp
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
jmp    11cd <main+0x9d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %ebp,%esi
mov    %edx,(%rsp,%rax,4)
mov    %ecx,(%rsp,%rsi,4)
xor    %ebp,%ebp
mov    %ebp,%eax
mov    (%rsp,%rax,4),%ecx
mov    0x4(%rsp,%rax,4),%edx
cmp    %edx,%ecx
jg     11c0 <main+0x90>
lea    0x1(%rax),%ebp
cmp    $0x6,%eax
jb     11cd <main+0x9d>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%edx
lea    0xe27(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please insert %d integers:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"In order:\0A\00"
@.str.3 = [14 x i8] c"nums[%d]: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [8 x i32]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 8)
store i32 0, i32* %2
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %7
18: ; preds = %7
store i32 0, i32* %4
br label %19
19: ; preds = %60, %18
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br i1 %22, label %23, label %61
23: ; preds = %19
store i32 0, i32* %2
br label %24
24: ; preds = %57, %23
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 7
br i1 %26, label %27, label %60
27: ; preds = %24
store i32 1, i32* %4
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp sgt i32 %31, %36
br i1 %37, label %38, label %56
38: ; preds = %27
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %40
%42 = load i32, i32* %41
store i32 %42, i32* %3
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %49
store i32 %47, i32* %50
%51 = load i32, i32* %3
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %54
store i32 %51, i32* %55
store i32 0, i32* %4
store i32 8, i32* %2
br label %56
56: ; preds = %38, %27
br label %57
57: ; preds = %56
%58 = load i32, i32* %2
%59 = add nsw i32 %58, 1
store i32 %59, i32* %2
br label %24
60: ; preds = %24
br label %19
61: ; preds = %19
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %63
63: ; preds = %73, %61
%64 = load i32, i32* %2
%65 = icmp slt i32 %64, 8
br i1 %65, label %66, label %76
66: ; preds = %63
%67 = load i32, i32* %2
%68 = load i32, i32* %2
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %67, i32 %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
br label %63
76: ; preds = %63
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str = [28 x i8] c"Please insert %d integers:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"nums[%d]: %d\0A\00"
@str = [10 x i8] c"In order:\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 8)
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %24
20: ; preds = %24
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %26
%22 = zext i32 %29 to i64
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %22
store i32 %32, i32* %21
store i32 %28, i32* %23
br label %37
24: ; preds = %37, %0
%25 = phi i32 [ 0, %0 ], [ %38, %37 ]
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = add nuw nsw i32 %25, 1
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = icmp sgt i32 %28, %32
br i1 %33, label %20, label %34
34: ; preds = %24
%35 = add nuw nsw i32 %25, 1
%36 = icmp ult i32 %25, 6
br i1 %36, label %37, label %39
37: ; preds = %34, %20
%38 = phi i32 [ %35, %34 ], [ 0, %20 ]
br label %24
39: ; preds = %34
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %41)
%43 = load i32, i32* %6
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %43)
%45 = load i32, i32* %8
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %45)
%47 = load i32, i32* %10
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %47)
%49 = load i32, i32* %12
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %49)
%51 = load i32, i32* %14
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %51)
%53 = load i32, i32* %16
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %53)
%55 = load i32, i32* %18
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %55)
ret i32 0
}