#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 dealACard();
int getLine(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rankHand(int const **, int *, int *);
int /*<<< orphan*/ sortHand(int const **, int *);
void playerDiscards(const int wDeck[][13], int *playerHand,
                    int *playerHandRank) {
  int playerToDiscard[5] = {0};
  int arrLen = 5 * 2 + 1;
  char input[arrLen];
  printf("Choose cards to throw (eg 145): ");
  arrLen = getLine(input, arrLen);
  char c;
  int cardPos, i = 0;
  while (c = input[i++] != '\0' && c != '\n' && i < arrLen) {
    cardPos = c - 49;
    if (cardPos >= 0 && cardPos < 5)
      playerToDiscard[cardPos] = 1;
  }
  for (i = 0; i < 5; i++)
    if (playerToDiscard[i] == 1)
      playerHand[i] = dealACard();
  sortHand(wDeck, playerHand);
  rankHand(wDeck, playerHand, playerHandRank);
}


x86 assembly (clang, -O0):
<playerDiscards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0xb,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x60(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <getLine@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x61(%rbp)
je     1203 <playerDiscards+0xb3>
movsbl -0x49(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x61(%rbp)
je     1203 <playerDiscards+0xb3>
mov    -0x54(%rbp),%eax
cmp    -0x34(%rbp),%eax
setl   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x49(%rbp)
cmp    $0x0,%al
je     1245 <playerDiscards+0xf5>
movsbl -0x49(%rbp),%eax
sub    $0x31,%eax
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jl     1240 <playerDiscards+0xf0>
cmpl   $0x5,-0x50(%rbp)
jge    1240 <playerDiscards+0xf0>
movslq -0x50(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
jmp    11c1 <playerDiscards+0x71>
movl   $0x0,-0x54(%rbp)
cmpl   $0x5,-0x54(%rbp)
jge    128c <playerDiscards+0x13c>
movslq -0x54(%rbp),%rax
cmpl   $0x1,-0x30(%rbp,%rax,4)
jne    1279 <playerDiscards+0x129>
mov    $0x0,%al
call   1070 <dealACard@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    127e <playerDiscards+0x12e>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    124c <playerDiscards+0xfc>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <sortHand@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <rankHand@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<playerDiscards>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%rdi
mov    $0xb,%esi
call   1060 <getLine@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <sortHand@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <rankHand@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Choose cards to throw (eg 145): \00"
define void @playerDiscards([13 x i32]* %0, i32* %1, i32* %2) {
%4 = alloca [13 x i32]*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [5 x i32]
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
store [13 x i32]* %0, [13 x i32]** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%14 = bitcast [5 x i32]* %7 to i8*
store i32 11, i32* %8
%15 = load i32, i32* %8
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %9
%18 = alloca i8, i64 %16
store i64 %16, i64* %10
%19 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* %8
%21 = call i32 @getLine(i8* %18, i32 %20)
store i32 %21, i32* %8
store i32 0, i32* %13
br label %22
22: ; preds = %56, %3
%23 = load i32, i32* %13
%24 = add nsw i32 %23, 1
store i32 %24, i32* %13
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8, i8* %18, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %22
%31 = load i8, i8* %11
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* %13
%36 = load i32, i32* %8
%37 = icmp slt i32 %35, %36
br label %38
38: ; preds = %34, %30, %22
%39 = phi i1 [ false, %30 ], [ false, %22 ], [ %37, %34 ]
%40 = zext i1 %39 to i32
%41 = trunc i32 %40 to i8
store i8 %41, i8* %11
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %57
43: ; preds = %38
%44 = load i8, i8* %11
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 49
store i32 %46, i32* %12
%47 = load i32, i32* %12
%48 = icmp sge i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %43
%50 = load i32, i32* %12
%51 = icmp slt i32 %50, 5
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %54
store i32 1, i32* %55
br label %56
56: ; preds = %52, %49, %43
br label %22
57: ; preds = %38
store i32 0, i32* %13
br label %58
58: ; preds = %74, %57
%59 = load i32, i32* %13
%60 = icmp slt i32 %59, 5
br i1 %60, label %61, label %77
61: ; preds = %58
%62 = load i32, i32* %13
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = icmp eq i32 %65, 1
br i1 %66, label %67, label %73
67: ; preds = %61
%68 = call i32 (...) @dealACard()
%69 = load i32*, i32** %5
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
store i32 %68, i32* %72
br label %73
73: ; preds = %67, %61
br label %74
74: ; preds = %73
%75 = load i32, i32* %13
%76 = add nsw i32 %75, 1
store i32 %76, i32* %13
br label %58
77: ; preds = %58
%78 = load [13 x i32]*, [13 x i32]** %4
%79 = bitcast [13 x i32]* %78 to i32**
%80 = load i32*, i32** %5
%81 = call i32 @sortHand(i32** %79, i32* %80)
%82 = load [13 x i32]*, [13 x i32]** %4
%83 = bitcast [13 x i32]* %82 to i32**
%84 = load i32*, i32** %5
%85 = load i32*, i32** %6
%86 = call i32 @rankHand(i32** %83, i32* %84, i32* %85)
%87 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Choose cards to throw (eg 145): \00"
define void @playerDiscards([13 x i32]* %0, i32* %1, i32* %2) {
%4 = alloca [11 x i8]
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @getLine(i8* %5, i32 11)
%8 = bitcast [13 x i32]* %0 to i32**
%9 = call i32 @sortHand(i32** %8, i32* %1)
%10 = call i32 @rankHand(i32** %8, i32* %1, i32* %2)
ret void
}