#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*/ strcpy(char *, char *);
void sort(int num[], char name[][30]) {
  int i, j, min, temp;
  char copy[30];
  for (i = 0; i < 10 - 1; i++) {
    min = i;
    for (j = i; j < 10; j++) {
      if (num[min] > num[j])
        min = j;
    }
    temp = num[i];
    num[i] = num[min];
    num[min] = temp;
    strcpy(copy, name[i]);
    strcpy(name[i], name[min]);
    strcpy(name[min], copy);
  }
  printf("result:\n");
  for (i = 0; i < 10; i++) {
    printf("\n%d %s", num[i], name[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    121f <sort+0xff>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    118c <sort+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1179 <sort+0x59>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <sort+0x5e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <sort+0x2d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
lea    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <sort+0x17>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1274 <sort+0x154>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rdx
movslq -0x14(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdx
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1234 <sort+0x114>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
xor    %ebp,%ebp
jmp    11c5 <sort+0x85>
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%eax
movslq %edx,%r15
mov    (%rbx,%r15,4),%ecx
mov    %ecx,(%rbx,%rbp,4)
mov    %eax,(%rbx,%r15,4)
mov    %rbp,%r12
shl    $0x5,%r12
sub    %rbp,%r12
sub    %rbp,%r12
add    0x8(%rsp),%r12
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r15,%r13
shl    $0x5,%r13
sub    %r15,%r13
sub    %r15,%r13
add    0x8(%rsp),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
add    $0x1,%rbp
cmp    $0x9,%rbp
je     11ed <sort+0xad>
mov    %rbp,%rax
mov    %ebp,%ecx
jmp    11dc <sort+0x9c>
nopl   0x0(%rax)
add    $0x1,%rax
mov    %edx,%ecx
cmp    $0xa,%rax
je     1160 <sort+0x20>
movslq %ecx,%rdx
mov    (%rbx,%rdx,4),%esi
mov    %eax,%edx
cmp    (%rbx,%rax,4),%esi
jg     11d0 <sort+0x90>
mov    %ecx,%edx
jmp    11d0 <sort+0x90>
lea    0xe13(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%esi
lea    0xdfe(%rip),%r15
mov    %r15,%rdi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rbx),%esi
lea    0x1e(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%esi
lea    0x3c(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rbx),%esi
lea    0x5a(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rbx),%esi
lea    0x78(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rbx),%esi
lea    0x96(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rbx),%esi
lea    0xb4(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rbx),%esi
lea    0xd2(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rbx),%esi
lea    0xf0(%rbp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rbx),%esi
add    $0x10e,%rbp
mov    %r15,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"result:\0A\00"
@.str.1 = [7 x i8] c"\0A%d %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @sort(i32* %0, [30 x i8]* %1) {
%3 = alloca i32*
%4 = alloca [30 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [30 x i8]
store i32* %0, i32** %3
store [30 x i8]* %1, [30 x i8]** %4
store i32 0, i32* %5
br label %10
10: ; preds = %82, %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 9
br i1 %12, label %13, label %85
13: ; preds = %10
%14 = load i32, i32* %5
store i32 %14, i32* %7
%15 = load i32, i32* %5
store i32 %15, i32* %6
br label %16
16: ; preds = %34, %13
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %37
19: ; preds = %16
%20 = load i32*, i32** %3
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = load i32*, i32** %3
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = icmp sgt i32 %24, %29
br i1 %30, label %31, label %33
31: ; preds = %19
%32 = load i32, i32* %6
store i32 %32, i32* %7
br label %33
33: ; preds = %31, %19
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %16
37: ; preds = %16
%38 = load i32*, i32** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
store i32 %42, i32* %8
%43 = load i32*, i32** %3
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = load i32*, i32** %3
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
store i32 %47, i32* %51
%52 = load i32, i32* %8
%53 = load i32*, i32** %3
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
store i32 %52, i32* %56
%57 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%58 = load [30 x i8]*, [30 x i8]** %4
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [30 x i8], [30 x i8]* %58, i64 %60
%62 = getelementptr inbounds [30 x i8], [30 x i8]* %61, i64 0, i64 0
%63 = call i32 @strcpy(i8* %57, i8* %62)
%64 = load [30 x i8]*, [30 x i8]** %4
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [30 x i8], [30 x i8]* %64, i64 %66
%68 = getelementptr inbounds [30 x i8], [30 x i8]* %67, i64 0, i64 0
%69 = load [30 x i8]*, [30 x i8]** %4
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [30 x i8], [30 x i8]* %69, i64 %71
%73 = getelementptr inbounds [30 x i8], [30 x i8]* %72, i64 0, i64 0
%74 = call i32 @strcpy(i8* %68, i8* %73)
%75 = load [30 x i8]*, [30 x i8]** %4
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [30 x i8], [30 x i8]* %75, i64 %77
%79 = getelementptr inbounds [30 x i8], [30 x i8]* %78, i64 0, i64 0
%80 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%81 = call i32 @strcpy(i8* %79, i8* %80)
br label %82
82: ; preds = %37
%83 = load i32, i32* %5
%84 = add nsw i32 %83, 1
store i32 %84, i32* %5
br label %10
85: ; preds = %10
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %87
87: ; preds = %102, %85
%88 = load i32, i32* %5
%89 = icmp slt i32 %88, 10
br i1 %89, label %90, label %105
90: ; preds = %87
%91 = load i32*, i32** %3
%92 = load i32, i32* %5
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32, i32* %91, i64 %93
%95 = load i32, i32* %94
%96 = load [30 x i8]*, [30 x i8]** %4
%97 = load i32, i32* %5
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [30 x i8], [30 x i8]* %96, i64 %98
%100 = getelementptr inbounds [30 x i8], [30 x i8]* %99, i64 0, i64 0
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %95, i8* %100)
br label %102
102: ; preds = %90
%103 = load i32, i32* %5
%104 = add nsw i32 %103, 1
store i32 %104, i32* %5
br label %87
105: ; preds = %87
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

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