#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*/ cpy(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int cmp(char s[100], char t[100]) {
  char string[100];
  int i = 0;
  for (i = 0; i < 100 && t[i]; i++)
    if (s[i] > t[i]) {
      cpy(string, s);
      cpy(s, t);
      cpy(t, string);
      break;
    }
  printf("%s %s\n", s, t);
  return 0;
}


x86 assembly (clang, -O0):
<cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x84(%rbp)
xor    %eax,%eax
cmpl   $0x64,-0x84(%rbp)
mov    %al,-0x85(%rbp)
jge    1177 <cmp+0x57>
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x85(%rbp)
mov    -0x85(%rbp),%al
test   $0x1,%al
jne    118a <cmp+0x6a>
jmp    11f5 <cmp+0xd5>
mov    -0x8(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x84(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jle    11dc <cmp+0xbc>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <cpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <cpy@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <cpy@plt>
jmp    11f5 <cmp+0xd5>
jmp    11e1 <cmp+0xc1>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1147 <cmp+0x27>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl -0x1(%r14,%rax,1),%ecx
test   %cl,%cl
je     118e <cmp+0x6e>
cmp    %cl,-0x1(%rbx,%rax,1)
jg     116a <cmp+0x4a>
movzbl (%r14,%rax,1),%ecx
test   %cl,%cl
je     118e <cmp+0x6e>
cmp    %cl,(%rbx,%rax,1)
jg     116a <cmp+0x4a>
add    $0x2,%rax
cmp    $0x65,%rax
jne    1140 <cmp+0x20>
jmp    118e <cmp+0x6e>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <cpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <cpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <cpy@plt>
lea    0xe6b(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s %s\0A\00"
define i32 @cmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
store i32 0, i32* %6
br label %7
7: ; preds = %45, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %10, %7
%19 = phi i1 [ false, %7 ], [ %17, %10 ]
br i1 %19, label %20, label %48
20: ; preds = %18
%21 = load i8*, i8** %3
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %4
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp sgt i32 %26, %32
br i1 %33, label %34, label %44
34: ; preds = %20
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%36 = load i8*, i8** %3
%37 = call i32 @cpy(i8* %35, i8* %36)
%38 = load i8*, i8** %3
%39 = load i8*, i8** %4
%40 = call i32 @cpy(i8* %38, i8* %39)
%41 = load i8*, i8** %4
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%43 = call i32 @cpy(i8* %41, i8* %42)
br label %48
44: ; preds = %20
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %7
48: ; preds = %34, %18
%49 = load i8*, i8** %3
%50 = load i8*, i8** %4
%51 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %49, i8* %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s %s\0A\00"
define i32 @cmp(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
br label %17
5: ; preds = %22
%6 = or i64 %18, 1
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %30, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %0, i64 %6
%12 = load i8, i8* %11
%13 = icmp sgt i8 %12, %8
br i1 %13, label %26, label %14
14: ; preds = %10
%15 = add nuw nsw i64 %18, 2
%16 = icmp eq i64 %15, 100
br i1 %16, label %30, label %17
17: ; preds = %14, %2
%18 = phi i64 [ 0, %2 ], [ %15, %14 ]
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %30, label %22
22: ; preds = %17
%23 = getelementptr inbounds i8, i8* %0, i64 %18
%24 = load i8, i8* %23
%25 = icmp sgt i8 %24, %20
br i1 %25, label %26, label %5
26: ; preds = %10, %22
%27 = call i32 @cpy(i8* %4, i8* %0)
%28 = call i32 @cpy(i8* %0, i8* %1)
%29 = call i32 @cpy(i8* %1, i8* %4)
br label %30
30: ; preds = %17, %5, %14, %26
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
ret i32 0
}