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

/* Variables and functions */
int compareDevice(struct device *, struct device *);
int devCmp(void *, void *);
int parallelCompareDevice(struct parallelDevice *dev1,
                          struct parallelDevice *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):
<parallelCompareDevice>:
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 <parallelCompareDevice+0x3f>
cmpl   $0x2,-0x1c(%rbp)
je     115f <parallelCompareDevice+0x3f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <parallelCompareDevice+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <devCmp@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     1183 <parallelCompareDevice+0x63>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <parallelCompareDevice+0x69>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parallelCompareDevice>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <compareDevice@plt>
mov    %eax,%ebx
test   $0xfffffffd,%eax
jne    1149 <parallelCompareDevice+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.parallelDevice = type { i32 }
%struct.device = type { i32 }
define i32 @parallelCompareDevice(%struct.parallelDevice* %0, %struct.parallelDevice* %1) {
%3 = alloca i32
%4 = alloca %struct.parallelDevice*
%5 = alloca %struct.parallelDevice*
%6 = alloca i32
%7 = alloca i32
store %struct.parallelDevice* %0, %struct.parallelDevice** %4
store %struct.parallelDevice* %1, %struct.parallelDevice** %5
%8 = load %struct.parallelDevice*, %struct.parallelDevice** %4
%9 = bitcast %struct.parallelDevice* %8 to %struct.device*
%10 = load %struct.parallelDevice*, %struct.parallelDevice** %5
%11 = bitcast %struct.parallelDevice* %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.parallelDevice*, %struct.parallelDevice** %4
%22 = bitcast %struct.parallelDevice* %21 to i8*
%23 = load %struct.parallelDevice*, %struct.parallelDevice** %5
%24 = bitcast %struct.parallelDevice* %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.parallelDevice = type { i32 }
%struct.device = type { i32 }
define i32 @parallelCompareDevice(%struct.parallelDevice* %0, %struct.parallelDevice* %1) {
%3 = bitcast %struct.parallelDevice* %0 to %struct.device*
%4 = bitcast %struct.parallelDevice* %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.parallelDevice* %0 to i8*
%10 = bitcast %struct.parallelDevice* %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
}