#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 pcmciaDevice {
  int dummy;
};
struct device {
  int dummy;
};

/* Variables and functions */
int compareDevice(struct device *, struct device *);
int devCmp(void *, void *);
int pcmciaCompareDevice(struct pcmciaDevice *dev1, struct pcmciaDevice *dev2) {
  int x, y;
  x = compareDevice((struct device *)dev1, (struct device *)dev2);
  if (x && x != 2)
    return x;
  if ((y = devCmp((void *)dev1, (void *)dev2)))
    return y;
  return x;
}


x86 assembly (clang, -O0):
<pcmciaCompareDevice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <compareDevice@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     115f <pcmciaCompareDevice+0x3f>
cmpl   $0x2,-0x1c(%rbp)
je     115f <pcmciaCompareDevice+0x3f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <pcmciaCompareDevice+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <devCmp@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     1183 <pcmciaCompareDevice+0x63>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <pcmciaCompareDevice+0x69>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcmciaCompareDevice>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <compareDevice@plt>
mov    %eax,%ebx
test   $0xfffffffd,%eax
jne    1149 <pcmciaCompareDevice+0x29>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <devCmp@plt>
test   %eax,%eax
cmovne %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pcmciaDevice = type { i32 }
%struct.device = type { i32 }
define i32 @pcmciaCompareDevice(%struct.pcmciaDevice* %0, %struct.pcmciaDevice* %1) {
%3 = alloca i32
%4 = alloca %struct.pcmciaDevice*
%5 = alloca %struct.pcmciaDevice*
%6 = alloca i32
%7 = alloca i32
store %struct.pcmciaDevice* %0, %struct.pcmciaDevice** %4
store %struct.pcmciaDevice* %1, %struct.pcmciaDevice** %5
%8 = load %struct.pcmciaDevice*, %struct.pcmciaDevice** %4
%9 = bitcast %struct.pcmciaDevice* %8 to %struct.device*
%10 = load %struct.pcmciaDevice*, %struct.pcmciaDevice** %5
%11 = bitcast %struct.pcmciaDevice* %10 to %struct.device*
%12 = call i32 @compareDevice(%struct.device* %9, %struct.device* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32, i32* %6
store i32 %19, i32* %3
br label %31
20: ; preds = %15, %2
%21 = load %struct.pcmciaDevice*, %struct.pcmciaDevice** %4
%22 = bitcast %struct.pcmciaDevice* %21 to i8*
%23 = load %struct.pcmciaDevice*, %struct.pcmciaDevice** %5
%24 = bitcast %struct.pcmciaDevice* %23 to i8*
%25 = call i32 @devCmp(i8* %22, i8* %24)
store i32 %25, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = load i32, i32* %7
store i32 %28, i32* %3
br label %31
29: ; preds = %20
%30 = load i32, i32* %6
store i32 %30, i32* %3
br label %31
31: ; preds = %29, %27, %18
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.pcmciaDevice = type { i32 }
%struct.device = type { i32 }
define i32 @pcmciaCompareDevice(%struct.pcmciaDevice* %0, %struct.pcmciaDevice* %1) {
%3 = bitcast %struct.pcmciaDevice* %0 to %struct.device*
%4 = bitcast %struct.pcmciaDevice* %1 to %struct.device*
%5 = tail call i32 @compareDevice(%struct.device* %3, %struct.device* %4)
%6 = and i32 %5, -3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = bitcast %struct.pcmciaDevice* %0 to i8*
%10 = bitcast %struct.pcmciaDevice* %1 to i8*
%11 = tail call i32 @devCmp(i8* %9, i8* %10)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 %5, i32 %11
br label %14
14: ; preds = %8, %2
%15 = phi i32 [ %5, %2 ], [ %13, %8 ]
ret i32 %15
}