#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 uint32_t;

/* Variables and functions */
int compare(char, char *);
uint32_t test_compare() {
  char array0[] = {'a', 'b'};
  int result0 = compare('a', array0);
  if (!(result0 < 0)) {
    return 1;
  }
  char array1[] = {0, 0, 0};
  int result1 = compare(0, array1);
  if (!(result1 == 0)) {
    return 2;
  }
  char array2[] = {'c', 'b', 'a'};
  int result2 = compare('b', array2 + 1);
  if (!(result2 > 0)) {
    return 3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0x6(%rbp),%rsi
mov    $0x61,%edi
call   1040 <compare@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     115a <test_compare+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    11d4 <test_compare+0xb4>
lea    -0xf(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <memset@plt>
lea    -0xf(%rbp),%rsi
xor    %edi,%edi
call   1040 <compare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     118e <test_compare+0x6e>
movl   $0x2,-0x4(%rbp)
jmp    11d4 <test_compare+0xb4>
mov    0xe6d(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xe65(%rip),%al
mov    %al,-0x15(%rbp)
lea    -0x17(%rbp),%rsi
add    $0x1,%rsi
mov    $0x62,%edi
call   1040 <compare@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     11cd <test_compare+0xad>
movl   $0x3,-0x4(%rbp)
jmp    11d4 <test_compare+0xb4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_compare>:
sub    $0x18,%rsp
movw   $0x6261,0x16(%rsp)
lea    0x16(%rsp),%rsi
mov    $0x61,%edi
call   1030 <compare@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
js     113a <test_compare+0x2a>
add    $0x18,%rsp
ret
movb   $0x0,0x14(%rsp)
movw   $0x0,0x12(%rsp)
lea    0x12(%rsp),%rsi
xor    %edi,%edi
call   1030 <compare@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    1135 <test_compare+0x25>
movb   $0x61,0x10(%rsp)
movw   $0x6263,0xe(%rsp)
lea    0xf(%rsp),%rsi
mov    $0x62,%edi
call   1030 <compare@plt>
xor    %ecx,%ecx
test   %eax,%eax
setle  %cl
lea    (%rcx,%rcx,2),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_compare.array0 = [2 x i8] c"ab"
@__const.test_compare.array2 = [3 x i8] c"cba"
define i32 @test_compare() {
%1 = alloca i32
%2 = alloca [2 x i8]
%3 = alloca i32
%4 = alloca [3 x i8]
%5 = alloca i32
%6 = alloca [3 x i8]
%7 = alloca i32
%8 = bitcast [2 x i8]* %2 to i8*
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%10 = call i32 @compare(i8 signext 97, i8* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %0
store i32 1, i32* %1
br label %30
14: ; preds = %0
%15 = bitcast [3 x i8]* %4 to i8*
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%17 = call i32 @compare(i8 signext 0, i8* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 2, i32* %1
br label %30
21: ; preds = %14
%22 = bitcast [3 x i8]* %6 to i8*
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i32 @compare(i8 signext 98, i8* %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp sgt i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %21
store i32 3, i32* %1
br label %30
29: ; preds = %21
store i32 0, i32* %1
br label %30
30: ; preds = %29, %28, %20, %13
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@__const.test_compare.array2 = [3 x i8] c"cba"
define i32 @test_compare() {
%1 = alloca i16
%2 = alloca [3 x i8]
%3 = alloca [3 x i8]
%4 = bitcast i16* %1 to i8*
store i16 25185, i16* %1
%5 = call i32 @compare(i8 signext 97, i8* %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %0
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%9 = call i32 @compare(i8 signext 0, i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
%14 = call i32 @compare(i8 signext 98, i8* %13)
%15 = icmp sgt i32 %14, 0
%16 = select i1 %15, i32 0, i32 3
br label %17
17: ; preds = %7, %11
%18 = phi i32 [ %16, %11 ], [ 2, %7 ]
br label %19
19: ; preds = %0, %17
%20 = phi i32 [ %18, %17 ], [ 1, %0 ]
ret i32 %20
}