#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 */
typedef int /*<<< orphan*/ XFontStruct;

/* Variables and functions */
scalar_t__ XTextWidth(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int lencompare(const void *p1, const void *p2) {
  char longstr[] = "Test string 0.00001 for comparison";
  if (XTextWidth(*(XFontStruct **)p1, longstr, strlen(longstr)) >
      XTextWidth(*(XFontStruct **)p2, longstr, strlen(longstr)))
    return 1;
  else
    return -1;
}


x86 assembly (clang, -O0):
<lencompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x23,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1050 <XTextWidth@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1050 <XTextWidth@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jle    11cb <lencompare+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11d2 <lencompare+0xa2>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lencompare>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x6e6f73,0x1f(%rsp)
mov    (%rdi),%rbx
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <XTextWidth@plt>
mov    %rax,%r12
mov    (%r14),%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <XTextWidth@plt>
xor    %ecx,%ecx
cmp    %rax,%r12
setg   %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.lencompare.longstr = [35 x i8] c"Test string 0.00001 for comparison\00"
define i32 @lencompare(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [35 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = bitcast [35 x i8]* %6 to i8*
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32**
%10 = load i32*, i32** %9
%11 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i64 @XTextWidth(i32* %10, i8* %11, i32 %13)
%15 = load i8*, i8** %5
%16 = bitcast i8* %15 to i32**
%17 = load i32*, i32** %16
%18 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = call i64 @XTextWidth(i32* %17, i8* %18, i32 %20)
%22 = icmp sgt i64 %14, %21
br i1 %22, label %23, label %24
23: ; preds = %2
store i32 1, i32* %3
br label %25
24: ; preds = %2
store i32 -1, i32* %3
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@__const.lencompare.longstr = [35 x i8] c"Test string 0.00001 for comparison\00"
define i32 @lencompare(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [35 x i8]
%4 = getelementptr inbounds [35 x i8], [35 x i8]* %3, i64 0, i64 0
%5 = bitcast i8* %0 to i32**
%6 = load i32*, i32** %5
%7 = call i32 @strlen(i8* %4)
%8 = call i64 @XTextWidth(i32* %6, i8* %4, i32 %7)
%9 = bitcast i8* %1 to i32**
%10 = load i32*, i32** %9
%11 = call i32 @strlen(i8* %4)
%12 = call i64 @XTextWidth(i32* %10, i8* %4, i32 %11)
%13 = icmp sgt i64 %8, %12
%14 = select i1 %13, i32 1, i32 -1
ret i32 %14
}