#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
unsigned long long parse_card(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
unsigned long long get_card(unsigned long long *deck) {
  unsigned long long card;
  do {
    char buffer[8];
    printf("Input card: ");
    if (!fgets(buffer, sizeof(buffer), stdin)) {
      fprintf(stderr, "ERROR: Problem reading input.\n");
      continue;
    }
    card = parse_card(buffer);
    if (!card) {
      fprintf(stderr, "ERROR: Unable to parse card.\n");
      continue;
    } else if (!(card & *deck)) {
      printf("ATTENTION: This card has already been selected, please choose "
             "another.\n");
      continue;
    }
    break;
  } while (1);
  *deck &= ~card;
  return card;
}


x86 assembly (clang, -O0):
<get_card>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%eax
jne    1192 <get_card+0x52>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11f4 <get_card+0xb4>
lea    -0x18(%rbp),%rdi
call   1040 <parse_card@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c4 <get_card+0x84>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11f4 <get_card+0xb4>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
and    (%rcx),%rax
cmp    $0x0,%rax
jne    11ea <get_card+0xaa>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    11f4 <get_card+0xb4>
jmp    11ef <get_card+0xaf>
jmp    1203 <get_card+0xc3>
mov    $0x1,%al
test   $0x1,%al
jne    114c <get_card+0xc>
jmp    1203 <get_card+0xc3>
mov    -0x10(%rbp),%rcx
xor    $0xffffffffffffffff,%rcx
mov    -0x8(%rbp),%rax
and    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_card>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe9b(%rip),%r15
mov    0x2e7c(%rip),%r13
mov    %rsp,%rbx
mov    0x2e62(%rip),%r12
lea    0xecd(%rip),%rbp
jmp    1190 <get_card+0x40>
nop
mov    (%r12),%edi
lea    0xe82(%rip),%rsi
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fgets@plt>
test   %eax,%eax
je     1180 <get_card+0x30>
mov    %rbx,%rdi
call   1050 <parse_card@plt>
test   %rax,%rax
je     11d0 <get_card+0x80>
mov    (%r14),%rcx
test   %rax,%rcx
jne    11e2 <get_card+0x92>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    1190 <get_card+0x40>
nopl   0x0(%rax)
mov    (%r12),%edi
lea    0xe51(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1190 <get_card+0x40>
mov    %rax,%rdx
not    %rdx
and    %rdx,%rcx
mov    %rcx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Input card: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"ERROR: Problem reading input.\0A\00"
@.str.2 = [30 x i8] c"ERROR: Unable to parse card.\0A\00"
@.str.3 = [72 x i8] c"ATTENTION: This card has already been selected, please choose another.\0A\00"
define i64 @get_card(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
%4 = alloca [8 x i8]
store i64* %0, i64** %2
br label %5
5: ; preds = %32, %1
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 8, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %32
14: ; preds = %5
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%16 = call i64 @parse_card(i8* %15)
store i64 %16, i64* %3
%17 = load i64, i64* %3
%18 = icmp ne i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %32
22: ; preds = %14
%23 = load i64, i64* %3
%24 = load i64*, i64** %2
%25 = load i64, i64* %24
%26 = and i64 %23, %25
%27 = icmp ne i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0))
br label %32
30: ; preds = %22
br label %31
31: ; preds = %30
br label %33
32: ; preds = %28, %19, %11
br i1 true, label %5, label %33
33: ; preds = %32, %31
%34 = load i64, i64* %3
%35 = xor i64 %34, -1
%36 = load i64*, i64** %2
%37 = load i64, i64* %36
%38 = and i64 %37, %35
store i64 %38, i64* %36
%39 = load i64, i64* %3
ret i64 %39
}

LLVM IR (-O2):
@.str = [13 x i8] c"Input card: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"ERROR: Problem reading input.\0A\00"
@.str.2 = [30 x i8] c"ERROR: Unable to parse card.\0A\00"
@str = [71 x i8] c"ATTENTION: This card has already been selected, please choose another.\00"
define i64 @get_card(i64* nocapture %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %24, %1
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %3, i32 8, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %24
12: ; preds = %4
%13 = call i64 @parse_card(i8* %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %24
18: ; preds = %12
%19 = load i64, i64* %0
%20 = and i64 %19, %13
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %15, %9
br label %4
25: ; preds = %18
%26 = xor i64 %13, -1
%27 = and i64 %19, %26
store i64 %27, i64* %0
ret i64 %13
}