#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 */
struct card {
  int dummy;
};

/* Variables and functions */
int check_eff_card_type(struct card *);
int cmp_comp_card_same_type(struct card *, struct card *, int);
int /*<<< orphan*/ sort_cards(struct card *, int);
int cmp_comp_card(struct card *c1, struct card *c2) {
  sort_cards(c1, 5);
  sort_cards(c2, 5);
  int type1 = check_eff_card_type(c1);
  int type2 = check_eff_card_type(c2);
  if (type1 > type2) {
    return 1;
  }
  if (type1 < type2) {
    return -1;
  }
  return cmp_comp_card_same_type(c1, c2, type1);
}


x86 assembly (clang, -O0):
<cmp_comp_card>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1050 <sort_cards@plt>
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1050 <sort_cards@plt>
mov    -0x10(%rbp),%rdi
call   1030 <check_eff_card_type@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <check_eff_card_type@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    118c <cmp_comp_card+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <cmp_comp_card+0x87>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11a4 <cmp_comp_card+0x74>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <cmp_comp_card+0x87>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <cmp_comp_card_same_type@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_comp_card>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x5,%esi
call   1050 <sort_cards@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <sort_cards@plt>
mov    %rbx,%rdi
call   1030 <check_eff_card_type@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <check_eff_card_type@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%ebp
jg     1175 <cmp_comp_card+0x45>
mov    $0xffffffff,%eax
jge    117a <cmp_comp_card+0x4a>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <cmp_comp_card_same_type@plt>

LLVM IR (-O0):
%struct.card = type { i32 }
define i32 @cmp_comp_card(%struct.card* %0, %struct.card* %1) {
%3 = alloca i32
%4 = alloca %struct.card*
%5 = alloca %struct.card*
%6 = alloca i32
%7 = alloca i32
store %struct.card* %0, %struct.card** %4
store %struct.card* %1, %struct.card** %5
%8 = load %struct.card*, %struct.card** %4
%9 = call i32 @sort_cards(%struct.card* %8, i32 5)
%10 = load %struct.card*, %struct.card** %5
%11 = call i32 @sort_cards(%struct.card* %10, i32 5)
%12 = load %struct.card*, %struct.card** %4
%13 = call i32 @check_eff_card_type(%struct.card* %12)
store i32 %13, i32* %6
%14 = load %struct.card*, %struct.card** %5
%15 = call i32 @check_eff_card_type(%struct.card* %14)
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 1, i32* %3
br label %30
20: ; preds = %2
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 -1, i32* %3
br label %30
25: ; preds = %20
%26 = load %struct.card*, %struct.card** %4
%27 = load %struct.card*, %struct.card** %5
%28 = load i32, i32* %6
%29 = call i32 @cmp_comp_card_same_type(%struct.card* %26, %struct.card* %27, i32 %28)
store i32 %29, i32* %3
br label %30
30: ; preds = %25, %24, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.card = type { i32 }
define i32 @cmp_comp_card(%struct.card* %0, %struct.card* %1) {
%3 = tail call i32 @sort_cards(%struct.card* %0, i32 5)
%4 = tail call i32 @sort_cards(%struct.card* %1, i32 5)
%5 = tail call i32 @check_eff_card_type(%struct.card* %0)
%6 = tail call i32 @check_eff_card_type(%struct.card* %1)
%7 = icmp sgt i32 %5, %6
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = icmp slt i32 %5, %6
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @cmp_comp_card_same_type(%struct.card* %0, %struct.card* %1, i32 %5)
br label %12
12: ; preds = %8, %2, %10
%13 = phi i32 [ %11, %10 ], [ 1, %2 ], [ -1, %8 ]
ret i32 %13
}