#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 get_card_val(int, char *);
int increment_counter(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char card_name[3];
  int count = 0;
  int val;
  while (card_name[0] != 'X') {
    printf("Enter card name\n");
    scanf("%2s", card_name);
    val = get_card_val(val, card_name);
    if (val == 0) {
      continue;
    }
    count = increment_counter(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)
movsbl -0x7(%rbp),%eax
cmp    $0x58,%eax
je     11c3 <main+0x83>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x7(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%edi
lea    -0x7(%rbp),%rsi
call   1050 <get_card_val@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    119f <main+0x5f>
jmp    1156 <main+0x16>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <increment_counter@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeb4(%rip),%r14
lea    0xe97(%rip),%r15
lea    0x5(%rsp),%rbx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x58,0x5(%rsp)
je     11d0 <main+0x80>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1060 <get_card_val@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     1180 <main+0x30>
mov    %eax,%ebp
mov    %r13d,%edi
mov    %eax,%esi
call   1070 <increment_counter@plt>
mov    %eax,%r13d
lea    0xe42(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%r12d
jmp    1180 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter card name\0A\00"
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [18 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
br label %5
5: ; preds = %20, %19, %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 %26
10: ; preds = %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %4
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%16 = call i32 @get_card_val(i32 %14, i8* %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %10
br label %5
20: ; preds = %10
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @increment_counter(i32 %21, i32 %22)
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %5
26: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%2s\00"
@.str.2 = [18 x i8] c"Current count %i\0A\00"
@str = [16 x i8] c"Enter card name\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 = %15, %0
%4 = phi i32 [ %16, %15 ], [ 0, %0 ]
%5 = phi i32 [ %13, %15 ], [ undef, %0 ]
br label %6
6: ; preds = %3, %10
%7 = phi i32 [ 0, %10 ], [ %5, %3 ]
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 88
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%13 = call i32 @get_card_val(i32 %7, i8* %2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %6, label %15
15: ; preds = %10
%16 = call i32 @increment_counter(i32 %4, i32 %13)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %3
18: ; preds = %6
ret i32 0
}