#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 unittype {
  int dummy;
};

/* Variables and functions */
int reduceproduct(struct unittype *, int);
int reduceunit(struct unittype *theunit) {
  int ret;
  ret = 1;
  while (ret & 1) {
    ret = reduceproduct(theunit, 0) | reduceproduct(theunit, 1);
    if (ret & 4)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<reduceunit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1178 <reduceunit+0x68>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <reduceproduct@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <reduceproduct@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1173 <reduceunit+0x63>
movl   $0x1,-0x4(%rbp)
jmp    117f <reduceunit+0x6f>
jmp    1123 <reduceunit+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reduceunit>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x1,%eax
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   $0x1,%al
je     1155 <reduceunit+0x45>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <reduceproduct@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <reduceproduct@plt>
or     %ebx,%eax
test   $0x4,%al
je     1130 <reduceunit+0x20>
jmp    1157 <reduceunit+0x47>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.unittype = type { i32 }
define i32 @reduceunit(%struct.unittype* %0) {
%2 = alloca i32
%3 = alloca %struct.unittype*
%4 = alloca i32
store %struct.unittype* %0, %struct.unittype** %3
store i32 1, i32* %4
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %4
%7 = and i32 %6, 1
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = load %struct.unittype*, %struct.unittype** %3
%11 = call i32 @reduceproduct(%struct.unittype* %10, i32 0)
%12 = load %struct.unittype*, %struct.unittype** %3
%13 = call i32 @reduceproduct(%struct.unittype* %12, i32 1)
%14 = or i32 %11, %13
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = and i32 %15, 4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %9
store i32 1, i32* %2
br label %21
19: ; preds = %9
br label %5
20: ; preds = %5
store i32 0, i32* %2
br label %21
21: ; preds = %20, %18
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
%struct.unittype = type { i32 }
define i32 @reduceunit(%struct.unittype* %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i32 [ 1, %1 ], [ %9, %6 ]
%4 = and i32 %3, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32 @reduceproduct(%struct.unittype* %0, i32 0)
%8 = tail call i32 @reduceproduct(%struct.unittype* %0, i32 1)
%9 = or i32 %8, %7
%10 = and i32 %9, 4
%11 = icmp eq i32 %10, 0
br i1 %11, label %2, label %12
12: ; preds = %2, %6
%13 = phi i32 [ 1, %6 ], [ 0, %2 ]
ret i32 %13
}