#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 */

/* Variables and functions */
scalar_t__ owFirst(int /*<<< orphan*/, int, int /*<<< orphan*/);
scalar_t__ owNext(int /*<<< orphan*/, int, int /*<<< orphan*/);
bool selectMemory(int n) {
  if (owFirst(0, 1, 0)) {
    n--;
    while (n >= 0 && owNext(0, 1, 0)) {
      n--;
    }
  }
  if (n < 0) {
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<selectMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
xor    %edx,%edx
mov    $0x1,%esi
mov    %edx,%edi
call   1030 <owFirst@plt>
cmp    $0x0,%rax
je     1196 <selectMemory+0x76>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     1173 <selectMemory+0x53>
xor    %edx,%edx
mov    $0x1,%esi
mov    %edx,%edi
call   1040 <owNext@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1183 <selectMemory+0x63>
jmp    1191 <selectMemory+0x71>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    114c <selectMemory+0x2c>
jmp    1196 <selectMemory+0x76>
cmpl   $0x0,-0x8(%rbp)
jge    11ac <selectMemory+0x8c>
movl   $0x1,-0x4(%rbp)
jmp    11b3 <selectMemory+0x93>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectMemory>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <owFirst@plt>
test   %rax,%rax
je     116e <selectMemory+0x4e>
test   %ebx,%ebx
cmovs  %ebx,%ebp
add    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ebx,%ebx
jle    116c <selectMemory+0x4c>
xor    %edi,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <owNext@plt>
add    $0xffffffff,%ebx
test   %rax,%rax
jne    1150 <selectMemory+0x30>
jmp    116e <selectMemory+0x4e>
mov    %ebp,%ebx
shr    $0x1f,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @selectMemory(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i64 @owFirst(i32 0, i32 1, i32 0)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %1
%7 = load i32, i32* %3
%8 = add nsw i32 %7, -1
store i32 %8, i32* %3
br label %9
9: ; preds = %17, %6
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i64 @owNext(i32 0, i32 1, i32 0)
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i32, i32* %3
%19 = add nsw i32 %18, -1
store i32 %19, i32* %3
br label %9
20: ; preds = %15
br label %21
21: ; preds = %20, %1
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %2
br label %26
25: ; preds = %21
store i32 0, i32* %2
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @selectMemory(i32 %0) {
%2 = tail call i64 @owFirst(i32 0, i32 1, i32 0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = call i32 @llvm.smin.i32(i32 %0, i32 0)
%6 = add i32 %5, -1
br label %7
7: ; preds = %4, %11
%8 = phi i32 [ %9, %11 ], [ %0, %4 ]
%9 = add nsw i32 %8, -1
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i64 @owNext(i32 0, i32 1, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %11, %7, %1
%15 = phi i32 [ %0, %1 ], [ %9, %11 ], [ %6, %7 ]
%16 = lshr i32 %15, 31
ret i32 %16
}