#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 picolIsInt(char const *);
int picolScanInt(char const *, int);
int picolQsortCompInt(const void *a, const void *b) {
  int base, diff, int_a, int_b;
  const char *cp = *(const char **)a;
  base = picolIsInt(cp);
  if (base < 1) {
    return 0;
  }
  int_a = picolScanInt(cp, base);
  cp = *(const char **)b;
  base = picolIsInt(cp);
  if (base < 1) {
    return 0;
  }
  int_b = picolScanInt(cp, base);
  diff = int_a - int_b;
  return (diff > 0 ? 1 : diff < 0 ? -1 : 0);
}


x86 assembly (clang, -O0):
<picolQsortCompInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <picolIsInt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    115d <picolQsortCompInt+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <picolQsortCompInt+0xc1>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <picolScanInt@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <picolIsInt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    1199 <picolQsortCompInt+0x79>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <picolQsortCompInt+0xc1>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <picolScanInt@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    11c8 <picolQsortCompInt+0xa8>
mov    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11db <picolQsortCompInt+0xbb>
mov    -0x20(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<picolQsortCompInt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    (%rdi),%rbp
mov    %rbp,%rdi
call   1030 <picolIsInt@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    1176 <picolQsortCompInt+0x56>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <picolScanInt@plt>
mov    %eax,%r14d
mov    (%r15),%rbp
mov    %rbp,%rdi
call   1030 <picolIsInt@plt>
test   %eax,%eax
jle    1176 <picolQsortCompInt+0x56>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <picolScanInt@plt>
xor    %ecx,%ecx
cmp    %eax,%r14d
setne  %cl
neg    %ecx
cmp    %eax,%r14d
mov    $0x1,%ebx
cmovle %ecx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @picolQsortCompInt(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to i8**
%13 = load i8*, i8** %12
store i8* %13, i8** %10
%14 = load i8*, i8** %10
%15 = call i32 @picolIsInt(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 0, i32* %3
br label %48
19: ; preds = %2
%20 = load i8*, i8** %10
%21 = load i32, i32* %6
%22 = call i32 @picolScanInt(i8* %20, i32 %21)
store i32 %22, i32* %8
%23 = load i8*, i8** %5
%24 = bitcast i8* %23 to i8**
%25 = load i8*, i8** %24
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = call i32 @picolIsInt(i8* %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 1
br i1 %29, label %30, label %31
30: ; preds = %19
store i32 0, i32* %3
br label %48
31: ; preds = %19
%32 = load i8*, i8** %10
%33 = load i32, i32* %6
%34 = call i32 @picolScanInt(i8* %32, i32 %33)
store i32 %34, i32* %9
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = sub nsw i32 %35, %36
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %31
br label %46
41: ; preds = %31
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 -1, i32 0
br label %46
46: ; preds = %41, %40
%47 = phi i32 [ 1, %40 ], [ %45, %41 ]
store i32 %47, i32* %3
br label %48
48: ; preds = %46, %30, %18
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @picolQsortCompInt(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i8**
%4 = load i8*, i8** %3
%5 = tail call i32 @picolIsInt(i8* %4)
%6 = icmp slt i32 %5, 1
br i1 %6, label %20, label %7
7: ; preds = %2
%8 = tail call i32 @picolScanInt(i8* %4, i32 %5)
%9 = bitcast i8* %1 to i8**
%10 = load i8*, i8** %9
%11 = tail call i32 @picolIsInt(i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %20, label %13
13: ; preds = %7
%14 = tail call i32 @picolScanInt(i8* %10, i32 %11)
%15 = sub nsw i32 %8, %14
%16 = icmp ne i32 %15, 0
%17 = sext i1 %16 to i32
%18 = icmp slt i32 %15, 1
%19 = select i1 %18, i32 %17, i32 1
br label %20
20: ; preds = %7, %2, %13
%21 = phi i32 [ %19, %13 ], [ 0, %2 ], [ 0, %7 ]
ret i32 %21
}