#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 */
char *ball2str(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char **args) {
  if (argc == 1) {
    fprintf(stderr, "Incorrect number of parameters.\r\n");
    return 1;
  }
  char *que = args[1];
  if (que[0] < 65 || que[0] > 90) {
    fprintf(stderr, "Question must begin with capital letter.\r\n");
    return 1;
  }
  if (que[strlen(que) - 1] != '?') {
    fprintf(stderr, "Not a question.\r\n");
  }
  int sum = 0;
  for (int i = 0; i < strlen(que) - 1; i++) {
    sum = sum + que[i];
  }
  srand(sum);
  printf("%s", ball2str(sum % 20));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1295 <main+0x145>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     11bd <main+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jle    11de <main+0x8e>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1295 <main+0x145>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
je     121d <main+0xcd>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    126c <main+0x11c>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    122b <main+0xdb>
mov    -0x1c(%rbp),%edi
call   1060 <srand@plt>
mov    -0x1c(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <ball2str@plt>
mov    %rax,%rsi
lea    0xdcf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    116e <main+0x1e>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
jmp    118b <main+0x3b>
mov    0x8(%rsi),%r15
mov    (%r15),%al
add    $0xa5,%al
cmp    $0xe5,%al
ja     119b <main+0x4b>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%r14d
jmp    1237 <main+0xe7>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x3f,-0x1(%rax,%r15,1)
je     11c2 <main+0x72>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
cmp    $0x2,%eax
jl     11fd <main+0xad>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%eax
add    %eax,%ebp
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbx
jl     11e0 <main+0x90>
mov    %ebp,%edi
call   1060 <srand@plt>
movslq %ebp,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
call   1040 <ball2str@plt>
lea    0xe30(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Incorrect number of parameters.\0D\0A\00"
@.str.1 = [43 x i8] c"Question must begin with capital letter.\0D\0A\00"
@.str.2 = [18 x i8] c"Not a question.\0D\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %71
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %21, 65
br i1 %22, label %29, label %23
23: ; preds = %14
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp sgt i32 %27, 90
br i1 %28, label %29, label %32
29: ; preds = %23, %14
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %71
32: ; preds = %23
%33 = load i8*, i8** %6
%34 = load i8*, i8** %6
%35 = call i32 @strlen(i8* %34)
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %33, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 63
br i1 %41, label %42, label %45
42: ; preds = %32
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %42, %32
store i32 0, i32* %7
store i32 0, i32* %8
br label %46
46: ; preds = %61, %45
%47 = load i32, i32* %8
%48 = load i8*, i8** %6
%49 = call i32 @strlen(i8* %48)
%50 = sub nsw i32 %49, 1
%51 = icmp slt i32 %47, %50
br i1 %51, label %52, label %64
52: ; preds = %46
%53 = load i32, i32* %7
%54 = load i8*, i8** %6
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = add nsw i32 %53, %59
store i32 %60, i32* %7
br label %61
61: ; preds = %52
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %46
64: ; preds = %46
%65 = load i32, i32* %7
%66 = call i32 @srand(i32 %65)
%67 = load i32, i32* %7
%68 = srem i32 %67, 20
%69 = call i8* @ball2str(i32 %68)
%70 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %64, %29, %11
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Incorrect number of parameters.\0D\0A\00"
@.str.1 = [43 x i8] c"Question must begin with capital letter.\0D\0A\00"
@.str.2 = [18 x i8] c"Not a question.\0D\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %47
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = add i8 %10, -91
%12 = icmp ult i8 %11, -26
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %47
16: ; preds = %7
%17 = tail call i32 @strlen(i8* %9)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %9, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 63
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %23, %16
%27 = tail call i32 @strlen(i8* %9)
%28 = icmp sgt i32 %27, 1
br i1 %28, label %35, label %29
29: ; preds = %35, %26
%30 = phi i32 [ 0, %26 ], [ %41, %35 ]
%31 = tail call i32 @srand(i32 %30)
%32 = srem i32 %30, 20
%33 = tail call i8* @ball2str(i32 %32)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %47
35: ; preds = %26, %35
%36 = phi i64 [ %42, %35 ], [ 0, %26 ]
%37 = phi i32 [ %41, %35 ], [ 0, %26 ]
%38 = getelementptr inbounds i8, i8* %9, i64 %36
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = add nsw i32 %37, %40
%42 = add nuw nsw i64 %36, 1
%43 = tail call i32 @strlen(i8* %9)
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %42, %45
br i1 %46, label %35, label %29
47: ; preds = %13, %29, %4
%48 = phi i32 [ 1, %4 ], [ 1, %13 ], [ 0, %29 ]
ret i32 %48
}