#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 /*<<< orphan*/ data_gethand(int, int *);
int data_numcards(int p) {
  int hand[7];
  data_gethand(p, hand);
  int numcards;
  for (numcards = 0; numcards < 7 && hand[numcards] > -1; numcards++)
    ;
  return numcards;
}


x86 assembly (clang, -O0):
<data_numcards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <data_gethand@plt>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x7,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jge    114c <data_numcards+0x3c>
movslq -0x24(%rbp),%rax
cmpl   $0xffffffff,-0x20(%rbp,%rax,4)
setg   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    115c <data_numcards+0x4c>
jmp    116f <data_numcards+0x5f>
jmp    1161 <data_numcards+0x51>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112e <data_numcards+0x1e>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_numcards>:
sub    $0x28,%rsp
mov    %rsp,%rsi
call   1030 <data_gethand@plt>
cmpl   $0x0,(%rsp)
js     1156 <data_numcards+0x46>
cmpl   $0x0,0x4(%rsp)
js     115d <data_numcards+0x4d>
cmpl   $0x0,0x8(%rsp)
js     1167 <data_numcards+0x57>
cmpl   $0x0,0xc(%rsp)
js     1171 <data_numcards+0x61>
cmpl   $0x0,0x10(%rsp)
js     117b <data_numcards+0x6b>
cmpl   $0x0,0x14(%rsp)
js     1185 <data_numcards+0x75>
mov    0x18(%rsp),%eax
not    %eax
shr    $0x1f,%eax
or     $0x6,%eax
add    $0x28,%rsp
ret
xor    %eax,%eax
add    $0x28,%rsp
ret
mov    $0x1,%eax
add    $0x28,%rsp
ret
mov    $0x2,%eax
add    $0x28,%rsp
ret
mov    $0x3,%eax
add    $0x28,%rsp
ret
mov    $0x4,%eax
add    $0x28,%rsp
ret
mov    $0x5,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @data_numcards(i32 %0) {
%2 = alloca i32
%3 = alloca [7 x i32]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%7 = call i32 @data_gethand(i32 %5, i32* %6)
store i32 0, i32* %4
br label %8
8: ; preds = %20, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 7
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, -1
br label %17
17: ; preds = %11, %8
%18 = phi i1 [ false, %8 ], [ %16, %11 ]
br i1 %18, label %19, label %23
19: ; preds = %17
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %17
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
define i32 @data_numcards(i32 %0) {
%2 = alloca [7 x i32]
%3 = bitcast [7 x i32]* %2 to i8*
%4 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%5 = call i32 @data_gethand(i32 %0, i32* %4)
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %33
8: ; preds = %1
%9 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 1
%10 = load i32, i32* %9
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %33
12: ; preds = %8
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 2
%14 = load i32, i32* %13
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 3
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 4
%22 = load i32, i32* %21
%23 = icmp sgt i32 %22, -1
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 5
%26 = load i32, i32* %25
%27 = icmp sgt i32 %26, -1
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 6
%30 = load i32, i32* %29
%31 = icmp sgt i32 %30, -1
%32 = select i1 %31, i32 7, i32 6
br label %33
33: ; preds = %28, %24, %20, %16, %12, %8, %1
%34 = phi i32 [ 0, %1 ], [ 1, %8 ], [ 2, %12 ], [ 3, %16 ], [ 4, %20 ], [ 5, %24 ], [ %32, %28 ]
ret i32 %34
}