#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 cardCount(int, int);
int getVal(char *);
int /*<<< orphan*/ input(char *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  char card_name[3];
  int count = 0;
  int val = 0;
  while (card_name[0] != 'X') {
    input(card_name);
    val = getVal(card_name);
    if (val == -1) {
      continue;
    }
    count = cardCount(count, val);
    printf("Current count: %i\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
je     11b0 <main+0x70>
lea    -0x7(%rbp),%rdi
call   1030 <input@plt>
lea    -0x7(%rbp),%rdi
call   1060 <getVal@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    118e <main+0x4e>
jmp    115d <main+0x1d>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <cardCount@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
lea    0xd(%rsp),%rbx
lea    0xeaa(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x58,0xd(%rsp)
je     1193 <main+0x53>
mov    %rbx,%rdi
call   1030 <input@plt>
mov    %rbx,%rdi
call   1060 <getVal@plt>
cmp    $0xffffffff,%eax
je     1160 <main+0x20>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <cardCount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Current count: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %18, %17, %0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 88
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%12 = call i32 @input(i8* %11)
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%14 = call i32 @getVal(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %10
br label %5
18: ; preds = %10
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32 @cardCount(i32 %19, i32 %20)
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %5
24: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Current count: %i\0A\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %12, %0
%4 = phi i32 [ %13, %12 ], [ 0, %0 ]
br label %5
5: ; preds = %3, %8
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 88
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = call i32 @input(i8* %2)
%10 = call i32 @getVal(i8* %2)
%11 = icmp eq i32 %10, -1
br i1 %11, label %5, label %12
12: ; preds = %8
%13 = call i32 @cardCount(i32 %4, i32 %10)
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %3
15: ; preds = %5
ret i32 0
}