#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 atoi(char *);
int strcmp(char *, char *);
int chromNameComp(const void *a, const void *b) {
  int an = 0, bn = 0;
  char *ac, *bc;
  ac = (char *)*(char **)a;
  bc = (char *)*(char **)b;
  an = atoi(ac + 3);
  bn = atoi(bc + 3);
  if (an > 0 && bn > 0) {
    return (an < bn ? -1 : (an > bn ? 1 : 0));
  } else {
    return strcmp(ac, bc);
  }
}


x86 assembly (clang, -O0):
<chromNameComp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x3,%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x3,%rdi
call   1040 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11c1 <chromNameComp+0xa1>
cmpl   $0x0,-0x20(%rbp)
jle    11c1 <chromNameComp+0xa1>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11a1 <chromNameComp+0x81>
mov    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11b6 <chromNameComp+0x96>
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovg  %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <chromNameComp+0xb1>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chromNameComp>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%rbx
mov    (%rsi),%r14
lea    0x3(%rbx),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
lea    0x3(%r14),%rdi
call   1040 <atoi@plt>
test   %ebp,%ebp
jle    115a <chromNameComp+0x3a>
test   %eax,%eax
jle    115a <chromNameComp+0x3a>
xor    %ecx,%ecx
cmp    %eax,%ebp
seta   %cl
mov    $0xffffffff,%eax
cmovae %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <strcmp@plt>

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

LLVM IR (-O2):
define i32 @chromNameComp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i8**
%4 = load i8*, i8** %3
%5 = bitcast i8* %1 to i8**
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %4, i64 3
%8 = tail call i32 @atoi(i8* %7)
%9 = getelementptr inbounds i8, i8* %6, i64 3
%10 = tail call i32 @atoi(i8* %9)
%11 = icmp sgt i32 %8, 0
%12 = icmp sgt i32 %10, 0
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = icmp ult i32 %8, %10
%16 = icmp ugt i32 %8, %10
%17 = zext i1 %16 to i32
%18 = select i1 %15, i32 -1, i32 %17
br label %21
19: ; preds = %2
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(1) %6)
br label %21
21: ; preds = %19, %14
%22 = phi i32 [ %18, %14 ], [ %20, %19 ]
ret i32 %22
}