#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void insert(char (*names)[21], char *name, int size) {
  int i;
  if (size == 1) {
    strcpy(names[0], name);
  }
  for (i = size - 1; i > 0; i--) {
    if (strcmp(names[i - 1], name) > 0) {
      strcpy(names[i], names[i - 1]);
    } else {
      break;
    }
  }
  strcpy(names[i], name);
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    114a <insert+0x2a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11c7 <insert+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x15,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jle    11af <insert+0x8f>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
imul   $0x15,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x15,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
jmp    11b4 <insert+0x94>
jmp    11c7 <insert+0xa7>
jmp    11b9 <insert+0x99>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <insert+0x33>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
imul   $0x15,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
cmp    $0x1,%edx
jne    1145 <insert+0x25>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
xor    %ebp,%ebp
jmp    11c0 <insert+0xa0>
mov    %edx,%r12d
lea    -0x1(%r12),%ebp
cmp    $0x2,%edx
jl     11c0 <insert+0xa0>
mov    %ebp,%ebp
add    $0xfffffffe,%r12d
lea    0x0(,%rbp,4),%rax
add    %rbp,%rax
lea    0x0(,%rax,4),%r13
add    %rbp,%r13
add    %r15,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%eax
lea    (%rax,%rax,4),%rcx
lea    (%rax,%rcx,4),%rbx
add    %r15,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jle    11c0 <insert+0xa0>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    -0x1(%rbp),%rax
add    $0xffffffff,%r12d
add    $0xffffffffffffffeb,%r13
cmp    $0x1,%rbp
mov    %rax,%rbp
jg     1180 <insert+0x60>
jmp    1141 <insert+0x21>
movslq %ebp,%rax
lea    (%rax,%rax,4),%rcx
lea    (%rax,%rcx,4),%rax
add    %rax,%r15
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @insert([21 x i8]* %0, i8* %1, i32 %2) {
%4 = alloca [21 x i8]*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store [21 x i8]* %0, [21 x i8]** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = load [21 x i8]*, [21 x i8]** %4
%12 = getelementptr inbounds [21 x i8], [21 x i8]* %11, i64 0
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %12, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = call i32 @strcpy(i8* %13, i8* %14)
br label %16
16: ; preds = %10, %3
%17 = load i32, i32* %6
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %7
br label %19
19: ; preds = %47, %16
%20 = load i32, i32* %7
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %50
22: ; preds = %19
%23 = load [21 x i8]*, [21 x i8]** %4
%24 = load i32, i32* %7
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [21 x i8], [21 x i8]* %23, i64 %26
%28 = getelementptr inbounds [21 x i8], [21 x i8]* %27, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %22
%33 = load [21 x i8]*, [21 x i8]** %4
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [21 x i8], [21 x i8]* %33, i64 %35
%37 = getelementptr inbounds [21 x i8], [21 x i8]* %36, i64 0, i64 0
%38 = load [21 x i8]*, [21 x i8]** %4
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [21 x i8], [21 x i8]* %38, i64 %41
%43 = getelementptr inbounds [21 x i8], [21 x i8]* %42, i64 0, i64 0
%44 = call i32 @strcpy(i8* %37, i8* %43)
br label %46
45: ; preds = %22
br label %50
46: ; preds = %32
br label %47
47: ; preds = %46
%48 = load i32, i32* %7
%49 = add nsw i32 %48, -1
store i32 %49, i32* %7
br label %19
50: ; preds = %45, %19
%51 = load [21 x i8]*, [21 x i8]** %4
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [21 x i8], [21 x i8]* %51, i64 %53
%55 = getelementptr inbounds [21 x i8], [21 x i8]* %54, i64 0, i64 0
%56 = load i8*, i8** %5
%57 = call i32 @strcpy(i8* %55, i8* %56)
ret void
}

LLVM IR (-O2):
define void @insert([21 x i8]* %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 1
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %0, i64 0, i64 0
%7 = tail call i32 @strcpy(i8* %6, i8* %1)
br label %29
8: ; preds = %3
%9 = add i32 %2, -1
%10 = icmp sgt i32 %2, 1
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %11, %22
%14 = phi i64 [ %12, %11 ], [ %25, %22 ]
%15 = phi i32 [ %2, %11 ], [ %21, %22 ]
%16 = add nsw i32 %15, -2
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [21 x i8], [21 x i8]* %0, i64 %17, i64 0
%19 = tail call i64 @strcmp(i8* %18, i8* %1)
%20 = icmp sgt i64 %19, 0
%21 = trunc i64 %14 to i32
br i1 %20, label %22, label %27
22: ; preds = %13
%23 = getelementptr inbounds [21 x i8], [21 x i8]* %0, i64 %14, i64 0
%24 = tail call i32 @strcpy(i8* %23, i8* %18)
%25 = add nsw i64 %14, -1
%26 = icmp sgt i64 %14, 1
br i1 %26, label %13, label %29
27: ; preds = %13
%28 = trunc i64 %14 to i32
br label %29
29: ; preds = %27, %22, %5, %8
%30 = phi i32 [ %9, %8 ], [ 0, %5 ], [ %28, %27 ], [ 0, %22 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [21 x i8], [21 x i8]* %0, i64 %31, i64 0
%33 = tail call i32 @strcpy(i8* %32, i8* %1)
ret void
}