#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 const *);
scalar_t__ number(char const *);
int strcasecmp(char const *, char const *);
int msg_compare(const char *s1, const char *s2) {
  if (*s1 && *s2 && number(s1) && number(s2)) {
    return (atoi(s1) - atoi(s2));
  } else {
    return strcasecmp(s1, s2);
  }
}


x86 assembly (clang, -O0):
<msg_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11aa <msg_compare+0x7a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11aa <msg_compare+0x7a>
mov    -0x10(%rbp),%rdi
call   1040 <number@plt>
cmp    $0x0,%rax
je     11aa <msg_compare+0x7a>
mov    -0x18(%rbp),%rdi
call   1040 <number@plt>
cmp    $0x0,%rax
je     11aa <msg_compare+0x7a>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11ba <msg_compare+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_compare>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     117d <msg_compare+0x4d>
cmpb   $0x0,(%r14)
je     117d <msg_compare+0x4d>
mov    %rbx,%rdi
call   1040 <number@plt>
test   %rax,%rax
je     117d <msg_compare+0x4d>
mov    %r14,%rdi
call   1040 <number@plt>
test   %rax,%rax
je     117d <msg_compare+0x4d>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <atoi@plt>
sub    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcasecmp@plt>

LLVM IR (-O0):
define i32 @msg_compare(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i64 @number(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = call i64 @number(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = call i32 @atoi(i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @atoi(i8* %26)
%28 = sub nsw i32 %25, %27
store i32 %28, i32* %3
br label %33
29: ; preds = %19, %15, %10, %2
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = call i32 @strcasecmp(i8* %30, i8* %31)
store i32 %32, i32* %3
br label %33
33: ; preds = %29, %23
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @msg_compare(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = tail call i64 @number(i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = tail call i64 @number(i8* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i32 @atoi(i8* %0)
%16 = tail call i32 @atoi(i8* %1)
%17 = sub nsw i32 %15, %16
br label %20
18: ; preds = %11, %8, %5, %2
%19 = tail call i32 @strcasecmp(i8* %0, i8* %1)
br label %20
20: ; preds = %18, %14
%21 = phi i32 [ %17, %14 ], [ %19, %18 ]
ret i32 %21
}