#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 string_length(char *);
int /*<<< orphan*/ trim_new(char *, char *);
int less(char *str1, char *str2) {
  int str1_length, str2_length, i;
  char *ptr1, *ptr2;
  trim_new(str1, str1);
  trim_new(str2, str2);
  str1_length = string_length(str1);
  str2_length = string_length(str2);
  if (str1_length > str2_length) {
    return 2;
  } else if (str1_length < str2_length) {
    return 1;
  } else {
    for (i = 0, ptr1 = str1, ptr2 = str2; i < str1_length;
         i++, ptr1++, ptr2++) {
      if (*(ptr1) > *(ptr2)) {
        return 2;
      } else if (*(ptr1) < *(ptr2)) {
        return 1;
      } else {
        continue;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<less>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <trim_new@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <trim_new@plt>
mov    -0x10(%rbp),%rdi
call   1030 <string_length@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <string_length@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    117a <less+0x5a>
movl   $0x2,-0x4(%rbp)
jmp    1235 <less+0x115>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1192 <less+0x72>
movl   $0x1,-0x4(%rbp)
jmp    1235 <less+0x115>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1224 <less+0x104>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    -0x38(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jle    11d7 <less+0xb7>
movl   $0x2,-0x4(%rbp)
jmp    1235 <less+0x115>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    -0x38(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jge    11f9 <less+0xd9>
movl   $0x1,-0x4(%rbp)
jmp    1235 <less+0x115>
jmp    11fe <less+0xde>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a9 <less+0x89>
jmp    1229 <less+0x109>
jmp    122e <less+0x10e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<less>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdi,%rsi
call   1040 <trim_new@plt>
mov    %r14,%rdi
mov    %r14,%rsi
call   1040 <trim_new@plt>
mov    %rbx,%rdi
call   1030 <string_length@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <string_length@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%ebp
jg     1186 <less+0x66>
jge    1163 <less+0x43>
mov    $0x1,%eax
jmp    1186 <less+0x66>
test   %ebp,%ebp
jle    1184 <less+0x64>
mov    %ebp,%esi
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rdx,1),%ecx
cmp    %cl,(%rbx,%rdx,1)
jg     1186 <less+0x66>
jl     115c <less+0x3c>
add    $0x1,%rdx
cmp    %edx,%esi
jne    1170 <less+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @less(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = load i8*, i8** %4
%13 = call i32 @trim_new(i8* %11, i8* %12)
%14 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @trim_new(i8* %14, i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @string_length(i8* %17)
store i32 %18, i32* %6
%19 = load i8*, i8** %5
%20 = call i32 @string_length(i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 2, i32* %3
br label %66
25: ; preds = %2
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1, i32* %3
br label %66
30: ; preds = %25
store i32 0, i32* %8
%31 = load i8*, i8** %4
store i8* %31, i8** %9
%32 = load i8*, i8** %5
store i8* %32, i8** %10
br label %33
33: ; preds = %56, %30
%34 = load i32, i32* %8
%35 = load i32, i32* %6
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %63
37: ; preds = %33
%38 = load i8*, i8** %9
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = load i8*, i8** %10
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp sgt i32 %40, %43
br i1 %44, label %45, label %46
45: ; preds = %37
store i32 2, i32* %3
br label %66
46: ; preds = %37
%47 = load i8*, i8** %9
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = load i8*, i8** %10
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp slt i32 %49, %52
br i1 %53, label %54, label %55
54: ; preds = %46
store i32 1, i32* %3
br label %66
55: ; preds = %46
br label %56
56: ; preds = %55
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
%59 = load i8*, i8** %9
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %9
%61 = load i8*, i8** %10
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %10
br label %33
63: ; preds = %33
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64
store i32 0, i32* %3
br label %66
66: ; preds = %65, %54, %45, %29, %24
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
define i32 @less(i8* %0, i8* %1) {
%3 = tail call i32 @trim_new(i8* %0, i8* %0)
%4 = tail call i32 @trim_new(i8* %1, i8* %1)
%5 = tail call i32 @string_length(i8* %0)
%6 = tail call i32 @string_length(i8* %1)
%7 = icmp sgt i32 %5, %6
br i1 %7, label %26, label %8
8: ; preds = %2
%9 = icmp slt i32 %5, %6
br i1 %9, label %26, label %10
10: ; preds = %8
%11 = icmp sgt i32 %5, 0
br i1 %11, label %12, label %26
12: ; preds = %10, %21
%13 = phi i8* [ %24, %21 ], [ %1, %10 ]
%14 = phi i8* [ %23, %21 ], [ %0, %10 ]
%15 = phi i32 [ %22, %21 ], [ 0, %10 ]
%16 = load i8, i8* %14
%17 = load i8, i8* %13
%18 = icmp sgt i8 %16, %17
br i1 %18, label %26, label %19
19: ; preds = %12
%20 = icmp slt i8 %16, %17
br i1 %20, label %26, label %21
21: ; preds = %19
%22 = add nuw nsw i32 %15, 1
%23 = getelementptr inbounds i8, i8* %14, i64 1
%24 = getelementptr inbounds i8, i8* %13, i64 1
%25 = icmp eq i32 %22, %5
br i1 %25, label %26, label %12
26: ; preds = %12, %19, %21, %10, %8, %2
%27 = phi i32 [ 2, %2 ], [ 1, %8 ], [ 0, %10 ], [ 2, %12 ], [ 1, %19 ], [ 0, %21 ]
ret i32 %27
}