#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*/ card_val(char *);
int handle_count(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ user_input(char *);
int main() {
  int count = 0;
  char card_name[3];
  while (card_name[0] != 'X') {
    user_input(card_name);
    count = count + handle_count(card_val(card_name));
    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,-0x8(%rbp)
movsbl -0xb(%rbp),%eax
cmp    $0x58,%eax
je     11a0 <main+0x60>
lea    -0xb(%rbp),%rdi
call   1040 <user_input@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0xb(%rbp),%rdi
call   1030 <card_val@plt>
mov    %eax,%edi
call   1060 <handle_count@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0xd(%rsp),%r14
lea    0xea9(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <user_input@plt>
mov    %r14,%rdi
call   1030 <card_val@plt>
mov    %eax,%edi
call   1060 <handle_count@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
cmpb   $0x58,0xd(%rsp)
jne    1160 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Current count: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %9, %0
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 88
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%11 = call i32 @user_input(i8* %10)
%12 = load i32, i32* %2
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%14 = call i32 @card_val(i8* %13)
%15 = call i32 @handle_count(i32 %14)
%16 = add nsw i32 %12, %15
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %4
19: ; preds = %4
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 = %0, %3
%4 = phi i32 [ %8, %3 ], [ 0, %0 ]
%5 = call i32 @user_input(i8* %2)
%6 = call i32 @card_val(i8* %2)
%7 = call i32 @handle_count(i32 %6)
%8 = add nsw i32 %7, %4
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 88
br i1 %11, label %12, label %3
12: ; preds = %3
ret i32 0
}