#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 */
int atoi(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int get_even_positive(char *desc) {
  int n = 0;
  char s[21];
  while (n <= 0 || n / 2 * 2 != n) {
    printf("Please enter %s (must be even and positive): ", desc);
    scanf("%20s", s);
    n = atoi(s);
  }
  return n;
}


x86 assembly (clang, -O0):
<get_even_positive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x31(%rbp)
jle    1169 <get_even_positive+0x39>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
shl    $0x1,%eax
cmp    -0xc(%rbp),%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1179 <get_even_positive+0x49>
jmp    11aa <get_even_positive+0x7a>
mov    -0x8(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
jmp    1143 <get_even_positive+0x13>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_even_positive>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r12
lea    0xebb(%rip),%r14
lea    0xee2(%rip),%r15
mov    %rsp,%rbx
nop
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
test   %eax,%eax
jle    1150 <get_even_positive+0x20>
cmp    %eax,%ecx
jne    1150 <get_even_positive+0x20>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter %s (must be even and positive): \00"
@.str.1 = [5 x i8] c"%20s\00"
define i32 @get_even_positive(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [21 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 2
%11 = mul nsw i32 %10, 2
%12 = load i32, i32* %3
%13 = icmp ne i32 %11, %12
br label %14
14: ; preds = %8, %5
%15 = phi i1 [ true, %5 ], [ %13, %8 ]
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = load i8*, i8** %2
%18 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%20 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %3
br label %5
23: ; preds = %14
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter %s (must be even and positive): \00"
@.str.1 = [5 x i8] c"%20s\00"
define i32 @get_even_positive(i8* %0) {
%2 = alloca [21 x i8]
%3 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %4
%5 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @atoi(i8* %3)
%8 = icmp sgt i32 %7, 0
%9 = and i32 %7, -2
%10 = icmp eq i32 %9, %7
%11 = and i1 %8, %10
br i1 %11, label %12, label %4
12: ; preds = %4
ret i32 %7
}