#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*/ memset(char *, char, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void sort_name(char name[256][256], int len) {
  char str[256];
  int i, j;
  int flag;
  memset(str, '\0', 256 * sizeof(char));
  flag = 1;
  for (i = 0; i < len && flag; ++i) {
    flag = 0;
    for (j = len - 1; j > i; --j) {
      if (0 < strcmp(name[j], name[j - 1])) {
        strcpy(str, name[j]);
        strcpy(name[j], name[j - 1]);
        strcpy(name[j - 1], str);
        flag = 1;
      }
    }
  }
}


x86 assembly (clang, -O0):
<sort_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movl   $0x1,-0x11c(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x11d(%rbp)
jge    1190 <sort_name+0x60>
cmpl   $0x0,-0x11c(%rbp)
setne  %al
mov    %al,-0x11d(%rbp)
mov    -0x11d(%rbp),%al
test   $0x1,%al
jne    11a3 <sort_name+0x73>
jmp    12af <sort_name+0x17f>
movl   $0x0,-0x11c(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x114(%rbp),%eax
jle    1296 <sort_name+0x166>
mov    -0x8(%rbp),%rdi
movslq -0x118(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x118(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x8,%rax
add    %rax,%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jge    127d <sort_name+0x14d>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x118(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x118(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x118(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x8,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x118(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x8,%rax
add    %rax,%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x11c(%rbp)
jmp    1282 <sort_name+0x152>
mov    -0x118(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x118(%rbp)
jmp    11b9 <sort_name+0x89>
jmp    129b <sort_name+0x16b>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1169 <sort_name+0x39>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %esi,%ebx
mov    %rdi,%r12
lea    0x40(%rsp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
test   %ebx,%ebx
jle    1256 <sort_name+0x126>
mov    %rbx,%rax
lea    -0x1(%rbx),%ecx
mov    %rcx,0x30(%rsp)
mov    %eax,%ecx
mov    %rcx,0x20(%rsp)
add    $0xffffffffffffffff,%rcx
add    $0xfffffffe,%eax
mov    %rax,0x28(%rsp)
mov    %rcx,0x18(%rsp)
shl    $0x8,%rcx
add    %r12,%rcx
mov    %rcx,0x10(%rsp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    0x30(%rsp),%r14
jae    1256 <sort_name+0x126>
movl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%r13
mov    0x28(%rsp),%rax
mov    %eax,%ebp
mov    0x18(%rsp),%r15
mov    %r14,0x38(%rsp)
jmp    11e3 <sort_name+0xb3>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r15
add    $0xffffffff,%ebp
add    $0xffffffffffffff00,%r13
cmp    %r14,%r15
jle    1240 <sort_name+0x110>
movslq %ebp,%rbx
shl    $0x8,%rbx
add    %r12,%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11d0 <sort_name+0xa0>
mov    %r12,%r14
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%r12
mov    0x38(%rsp),%r14
call   1030 <strcpy@plt>
movl   $0x1,0xc(%rsp)
jmp    11d0 <sort_name+0xa0>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    0x20(%rsp),%r14
jae    1256 <sort_name+0x126>
cmpl   $0x0,0xc(%rsp)
jne    11a0 <sort_name+0x70>
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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