#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*/ change_count(int *, int);
int /*<<< orphan*/ determine_val(int *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ prompt_for_card(char *);
int main() {
  char card_name[3];
  int count = 0;
  int val = 0;
  while (1) {
    prompt_for_card(card_name);
    if (*card_name == 'X') {
      break;
    }
    determine_val(&val, card_name);
    change_count(&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)
lea    -0x7(%rbp),%rdi
call   1030 <prompt_for_card@plt>
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
jne    1178 <main+0x38>
jmp    11a5 <main+0x65>
lea    -0x7(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1050 <determine_val@plt>
mov    -0x10(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1060 <change_count@plt>
mov    -0xc(%rbp),%esi
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xd(%rsp),%rdi
call   1030 <prompt_for_card@plt>
cmpb   $0x58,0xd(%rsp)
je     11c2 <main+0x82>
lea    0x10(%rsp),%r14
lea    0xd(%rsp),%rbx
lea    0x14(%rsp),%r15
lea    0xe7e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <determine_val@plt>
mov    0x10(%rsp),%esi
mov    %r15,%rdi
call   1060 <change_count@plt>
mov    0x14(%rsp),%esi
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <prompt_for_card@plt>
cmpb   $0x58,0xd(%rsp)
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
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 [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 = %0, %13
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = call i32 @prompt_for_card(i8* %6)
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 88
br i1 %11, label %12, label %13
12: ; preds = %5
br label %20
13: ; preds = %5
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%15 = call i32 @determine_val(i32* %4, i8* %14)
%16 = load i32, i32* %4
%17 = call i32 @change_count(i32* %3, i32 %16)
%18 = load i32, i32* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %5
20: ; preds = %12
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 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = call i32 @prompt_for_card(i8* %4)
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 88
br i1 %9, label %19, label %10
10: ; preds = %0, %10
%11 = call i32 @determine_val(i32* %3, i8* %4)
%12 = load i32, i32* %3
%13 = call i32 @change_count(i32* %2, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @prompt_for_card(i8* %4)
%17 = load i8, i8* %4
%18 = icmp eq i8 %17, 88
br i1 %18, label %19, label %10
19: ; preds = %10, %0
ret i32 0
}