#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__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reorder(int, char **);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main(void) {
  int i, n = 0;
  char *x[10];
  printf("Enter each string on a separate line below\n\n");
  printf("Type \'END\' when finished\n\n");
  do {
    x[n] = (char *)malloc(12 * sizeof(char));
    printf("string %d: ", n + 1);
    scanf("%s", x[n]);
  } while (strcmp(x[n++], "END"));
  reorder(--n, x);
  printf("\n\nReorder List of Strings: \n");
  for (i = 0; i < n; ++i)
    printf("\nstring %d: %s", i + 1, x[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rsi
lea    0xec5(%rip),%rdi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    -0x60(%rbp,%rax,8),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1182 <main+0x32>
mov    -0xc(%rbp),%edi
add    $0xffffffff,%edi
mov    %edi,-0xc(%rbp)
lea    -0x60(%rbp),%rsi
call   1060 <reorder@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1247 <main+0xf7>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
movslq -0x8(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1210 <main+0xc0>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r13d
mov    %rsp,%rbp
lea    0xe6a(%rip),%r14
lea    0xe7f(%rip),%r15
lea    0xe68(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x0(%rbp)
lea    0x2(%r13),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
add    $0x1,%r13d
add    $0x8,%rbp
test   %rax,%rax
jne    11b0 <main+0x50>
mov    %rsp,%rsi
mov    %r13d,%edi
call   1070 <reorder@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
test   %r13d,%r13d
je     1239 <main+0xd9>
mov    %r13d,%ebp
lea    0xdf8(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rdx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%rbp
jne    1220 <main+0xc0>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter each string on a separate line below\0A\0A\00"
@.str.1 = [27 x i8] c"Type 'END' when finished\0A\0A\00"
@.str.2 = [12 x i8] c"string %d: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"END\00"
@.str.5 = [29 x i8] c"\0A\0AReorder List of Strings: \0A\00"
@.str.6 = [15 x i8] c"\0Astring %d: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8*]
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %21, %0
%8 = call i64 @malloc(i32 12)
%9 = inttoptr i64 %8 to i8*
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %11
store i8* %9, i8** %12
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %7
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %7, label %29
29: ; preds = %21
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
%32 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
%33 = call i32 @reorder(i32 %31, i8** %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %35
35: ; preds = %47, %29
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %50
39: ; preds = %35
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %41, i8* %45)
br label %47
47: ; preds = %39
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %35
50: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [12 x i8] c"string %d: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"END\00"
@.str.6 = [15 x i8] c"\0Astring %d: %s\00"
@str = [44 x i8] c"Enter each string on a separate line below\0A\00"
@str.7 = [26 x i8] c"Type 'END' when finished\0A\00"
@str.8 = [28 x i8] c"\0A\0AReorder List of Strings: \00"
define i32 @main() {
%1 = alloca [10 x i8*]
%2 = bitcast [10 x i8*]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %10, %5 ], [ 0, %0 ]
%7 = tail call i64 @malloc(i32 12)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 %6
store i8* %8, i8** %9
%10 = add nuw i64 %6, 1
%11 = trunc i64 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%14 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5
%17 = trunc i64 %6 to i32
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 0
%19 = call i32 @reorder(i32 %17, i8** %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%21 = icmp eq i32 %17, 0
br i1 %21, label %32, label %22
22: ; preds = %16
%23 = and i64 %6, 4294967295
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ 0, %22 ], [ %26, %24 ]
%26 = add nuw nsw i64 %25, 1
%27 = getelementptr inbounds [10 x i8*], [10 x i8*]* %1, i64 0, i64 %25
%28 = load i8*, i8** %27
%29 = trunc i64 %26 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %29, i8* %28)
%31 = icmp eq i64 %26, %23
br i1 %31, label %32, label %24
32: ; preds = %24, %16
ret i32 0
}