#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*/ compress(char **, int *);
scalar_t__ strlen(char *);
const char *black_card(char names[11][100], int *turns) {
  int length;
  for (int i = 0; i < 11; i++) {
    if (strlen(names[i]) == 0) {
      length = i;
      break;
    }
  }
  while (length != 1) {
    names[(*turns % length) - 1][0] = '\0';
    length--;
    compress(names, &length);
  }
  return (names[0]);
}


x86 assembly (clang, -O0):
<black_card>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xb,-0x18(%rbp)
jge    117d <black_card+0x5d>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
imul   $0x64,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    116a <black_card+0x4a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    117d <black_card+0x5d>
jmp    116f <black_card+0x4f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <black_card+0x17>
jmp    1182 <black_card+0x62>
cmpl   $0x1,-0x14(%rbp)
je     11cd <black_card+0xad>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x20(%rbp),%rax
sub    $0x1,%edx
movslq %edx,%rcx
imul   $0x64,%rcx,%rcx
add    %rcx,%rax
movb   $0x0,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <compress@plt>
jmp    1182 <black_card+0x62>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<black_card>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11df <black_card+0xbf>
lea    0x64(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     124f <black_card+0x12f>
lea    0xc8(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11e3 <black_card+0xc3>
lea    0x12c(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11ea <black_card+0xca>
lea    0x190(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11f1 <black_card+0xd1>
lea    0x1f4(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11f8 <black_card+0xd8>
lea    0x258(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11ff <black_card+0xdf>
lea    0x2bc(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     1206 <black_card+0xe6>
lea    0x320(%rbx),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     120d <black_card+0xed>
lea    0x384(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%rax
mov    $0xa,%ecx
sbb    $0x0,%ecx
jmp    1212 <black_card+0xf2>
xor    %ecx,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x2,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x3,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x4,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x5,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x6,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x7,%ecx
jmp    1212 <black_card+0xf2>
mov    $0x8,%ecx
lea    0xc(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r14),%eax
cltd
idiv   %ecx
add    $0xffffffff,%edx
movslq %edx,%rax
imul   $0x64,%rax,%rax
movb   $0x0,(%rbx,%rax,1)
add    $0xffffffff,%ecx
mov    %ecx,0xc(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <compress@plt>
mov    0xc(%rsp),%ecx
cmp    $0x1,%ecx
jne    1220 <black_card+0x100>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @black_card([100 x i8]* %0, i32* %1) {
%3 = alloca [100 x i8]*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store [100 x i8]* %0, [100 x i8]** %3
store i32* %1, i32** %4
store i32 0, i32* %6
br label %7
7: ; preds = %21, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 11
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = load [100 x i8]*, [100 x i8]** %3
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 %13
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = load i32, i32* %6
store i32 %19, i32* %5
br label %24
20: ; preds = %10
br label %21
21: ; preds = %20
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %7
24: ; preds = %18, %7
br label %25
25: ; preds = %28, %24
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %43
28: ; preds = %25
%29 = load [100 x i8]*, [100 x i8]** %3
%30 = load i32*, i32** %4
%31 = load i32, i32* %30
%32 = load i32, i32* %5
%33 = srem i32 %31, %32
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %29, i64 %35
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %36, i64 0, i64 0
store i8 0, i8* %37
%38 = load i32, i32* %5
%39 = add nsw i32 %38, -1
store i32 %39, i32* %5
%40 = load [100 x i8]*, [100 x i8]** %3
%41 = bitcast [100 x i8]* %40 to i8**
%42 = call i32 @compress(i8** %41, i32* %5)
br label %25
43: ; preds = %25
%44 = load [100 x i8]*, [100 x i8]** %3
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %44, i64 0
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %45, i64 0, i64 0
ret i8* %46
}

LLVM IR (-O2):
define i8* @black_card([100 x i8]* %0, i32* nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 0, i64 0
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %45, label %8
8: ; preds = %2
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 1, i64 0
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %59, label %12
12: ; preds = %8
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 2, i64 0
%14 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %45, label %16
16: ; preds = %12
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 3, i64 0
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %45, label %20
20: ; preds = %16
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 4, i64 0
%22 = tail call i64 @strlen(i8* dereferenceable(1) %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %45, label %24
24: ; preds = %20
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 5, i64 0
%26 = tail call i64 @strlen(i8* dereferenceable(1) %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %45, label %28
28: ; preds = %24
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 6, i64 0
%30 = tail call i64 @strlen(i8* dereferenceable(1) %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %45, label %32
32: ; preds = %28
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 7, i64 0
%34 = tail call i64 @strlen(i8* dereferenceable(1) %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %45, label %36
36: ; preds = %32
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 8, i64 0
%38 = tail call i64 @strlen(i8* dereferenceable(1) %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %36
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 9, i64 0
%42 = tail call i64 @strlen(i8* dereferenceable(1) %41)
%43 = icmp eq i64 %42, 0
%44 = select i1 %43, i32 9, i32 10
br label %45
45: ; preds = %40, %36, %32, %28, %24, %20, %16, %12, %2
%46 = phi i32 [ 8, %36 ], [ 7, %32 ], [ 6, %28 ], [ 5, %24 ], [ 4, %20 ], [ 3, %16 ], [ 2, %12 ], [ 0, %2 ], [ %44, %40 ]
%47 = bitcast [100 x i8]* %0 to i8**
br label %48
48: ; preds = %45, %48
%49 = phi i32 [ %46, %45 ], [ %57, %48 ]
%50 = load i32, i32* %1
%51 = srem i32 %50, %49
%52 = add nsw i32 %51, -1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %0, i64 %53, i64 0
store i8 0, i8* %54
%55 = add nsw i32 %49, -1
store i32 %55, i32* %3
%56 = call i32 @compress(i8** %47, i32* %3)
%57 = load i32, i32* %3
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %48
59: ; preds = %48, %8
ret i8* %5
}