#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*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int a[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 1}, *head, *p, *q, temp;
  for (head = p = q = a; head < a + 10; head++) {
    if (*head > *p)
      p = head;
    if (*head < *q)
      q = head;
  }
  temp = *q;
  *q = *a;
  *a = temp;
  temp = *p;
  *p = *(a + 9);
  *(a + 9) = temp;
  for (head = a; head < a + 10; head++)
    printf("%3d", *head);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    %rax,-0x40(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
add    $0x28,%rcx
cmp    %rcx,%rax
jae    11c3 <main+0x93>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    -0x40(%rbp),%rcx
cmp    (%rcx),%eax
jle    1193 <main+0x63>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    -0x48(%rbp),%rcx
cmp    (%rcx),%eax
jge    11ad <main+0x7d>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    11b2 <main+0x82>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
jmp    1164 <main+0x34>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4c(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
add    $0x28,%rcx
cmp    %rcx,%rax
jae    1233 <main+0x103>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
jmp    11fb <main+0xcb>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xef0(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
lea    0x28(%rsp),%r14
lea    0x4(%rsp),%rax
mov    %rdx,%rdi
jmp    116f <main+0x4f>
xchg   %ax,%ax
add    $0x4,%rax
mov    %rsi,%rdx
mov    %rcx,%rdi
cmp    %r14,%rax
jae    1187 <main+0x67>
mov    (%rax),%ebx
mov    %rax,%rcx
cmp    (%rdi),%ebx
jg     117b <main+0x5b>
mov    %rdi,%rcx
mov    %rax,%rsi
cmp    (%rdx),%ebx
jl     1160 <main+0x40>
mov    %rdx,%rsi
jmp    1160 <main+0x40>
mov    %rsp,%rbx
mov    (%rsi),%eax
movl   $0x2,(%rsi)
mov    %eax,(%rsp)
mov    (%rcx),%eax
mov    0x24(%rsp),%edx
mov    %edx,(%rcx)
mov    %eax,0x24(%rsp)
lea    0xe80(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x4,%rbx
cmp    %r14,%rbx
jb     11b0 <main+0x90>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [10 x i32] [i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1]
@.str = [4 x i8] c"%3d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [10 x i32]* %2 to i8*
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32* %8, i32** %5
store i32* %8, i32** %4
store i32* %8, i32** %3
br label %9
9: ; preds = %31, %0
%10 = load i32*, i32** %3
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%12 = getelementptr inbounds i32, i32* %11, i64 10
%13 = icmp ult i32* %10, %12
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = load i32*, i32** %3
%16 = load i32, i32* %15
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = icmp sgt i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = load i32*, i32** %3
store i32* %21, i32** %4
br label %22
22: ; preds = %20, %14
%23 = load i32*, i32** %3
%24 = load i32, i32* %23
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32*, i32** %3
store i32* %29, i32** %5
br label %30
30: ; preds = %28, %22
br label %31
31: ; preds = %30
%32 = load i32*, i32** %3
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %3
br label %9
34: ; preds = %9
%35 = load i32*, i32** %5
%36 = load i32, i32* %35
store i32 %36, i32* %6
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%38 = load i32, i32* %37
%39 = load i32*, i32** %5
store i32 %38, i32* %39
%40 = load i32, i32* %6
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32 %40, i32* %41
%42 = load i32*, i32** %4
%43 = load i32, i32* %42
store i32 %43, i32* %6
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%45 = getelementptr inbounds i32, i32* %44, i64 9
%46 = load i32, i32* %45
%47 = load i32*, i32** %4
store i32 %46, i32* %47
%48 = load i32, i32* %6
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%50 = getelementptr inbounds i32, i32* %49, i64 9
store i32 %48, i32* %50
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32* %51, i32** %3
br label %52
52: ; preds = %61, %34
%53 = load i32*, i32** %3
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%55 = getelementptr inbounds i32, i32* %54, i64 10
%56 = icmp ult i32* %53, %55
br i1 %56, label %57, label %64
57: ; preds = %52
%58 = load i32*, i32** %3
%59 = load i32, i32* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %57
%62 = load i32*, i32** %3
%63 = getelementptr inbounds i32, i32* %62, i32 1
store i32* %63, i32** %3
br label %52
64: ; preds = %52
%65 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [10 x i32] [i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1]
@.str = [4 x i8] c"%3d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 10
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
br label %6
6: ; preds = %0, %6
%7 = phi i32* [ %5, %0 ], [ %17, %6 ]
%8 = phi i32* [ %3, %0 ], [ %16, %6 ]
%9 = phi i32* [ %3, %0 ], [ %14, %6 ]
%10 = load i32, i32* %7
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp sgt i32 %10, %11
%14 = select i1 %13, i32* %7, i32* %9
%15 = icmp slt i32 %10, %12
%16 = select i1 %15, i32* %7, i32* %8
%17 = getelementptr inbounds i32, i32* %7, i64 1
%18 = icmp ult i32* %17, %4
br i1 %18, label %6, label %19
19: ; preds = %6
%20 = load i32, i32* %16
store i32 2, i32* %16
store i32 %20, i32* %3
%21 = load i32, i32* %14
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%23 = load i32, i32* %22
store i32 %23, i32* %14
store i32 %21, i32* %22
br label %24
24: ; preds = %19, %24
%25 = phi i32* [ %3, %19 ], [ %28, %24 ]
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i32, i32* %25, i64 1
%29 = icmp ult i32* %28, %4
br i1 %29, label %24, label %30
30: ; preds = %24
%31 = call i32 (...) @getchar()
ret i32 0
}