#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 check_invalid(char *, int);
int /*<<< orphan*/ get_input(char *);
int get_value(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int update_count(int, int);
int main() {
  char card_name[3];
  int count = 0;
  int val = 0;
  int valid = 1;
  while (valid != -1) {
    get_input(card_name);
    val = get_value(card_name);
    valid = check_invalid(card_name, val);
    if (valid == 1) {
      count = update_count(count, val);
      printf("Current count: %i\n", count);
    } else if (valid == 0) {
      puts("I don't understand that value!");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     11fe <main+0x9e>
lea    -0x7(%rbp),%rdi
call   1070 <get_input@plt>
lea    -0x7(%rbp),%rdi
call   1060 <get_value@plt>
mov    %eax,-0x10(%rbp)
lea    -0x7(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <check_invalid@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11de <main+0x7e>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1080 <update_count@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe2c(%rip),%rdi
call   1050 <printf@plt>
jmp    11f9 <main+0x99>
cmpl   $0x0,-0x14(%rbp)
jne    11f4 <main+0x94>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
jmp    11f9 <main+0x99>
jmp    1184 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
lea    0x5(%rsp),%r13
lea    0xe99(%rip),%r14
lea    0xe7f(%rip),%r15
jmp    119d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
cmp    $0xffffffff,%ebp
je     11dd <main+0x7d>
mov    %r13,%rdi
call   1070 <get_input@plt>
mov    %r13,%rdi
call   1060 <get_value@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <check_invalid@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1190 <main+0x30>
cmp    $0x1,%ebp
jne    1198 <main+0x38>
mov    %r12d,%edi
mov    %ebx,%esi
call   1080 <update_count@plt>
mov    %eax,%r12d
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
jmp    1198 <main+0x38>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Current count: %i\0A\00"
@.str.1 = [31 x i8] c"I don't understand that value!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
br label %6
6: ; preds = %31, %0
%7 = load i32, i32* %5
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%11 = call i32 @get_input(i8* %10)
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%13 = call i32 @get_value(i8* %12)
store i32 %13, i32* %4
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @check_invalid(i8* %14, i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %25
19: ; preds = %9
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @update_count(i32 %20, i32 %21)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %31
25: ; preds = %9
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
br label %31
31: ; preds = %30, %19
br label %6
32: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Current count: %i\0A\00"
@.str.1 = [31 x i8] c"I don't understand that value!\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, %13
%4 = phi i32 [ 0, %0 ], [ %14, %13 ]
%5 = call i32 @get_input(i8* %2)
%6 = call i32 @get_value(i8* %2)
%7 = call i32 @check_invalid(i8* %2, i32 %6)
switch i32 %7, label %13 [
i32 1, label %8
i32 0, label %11
]
8: ; preds = %3
%9 = call i32 @update_count(i32 %4, i32 %6)
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %13
11: ; preds = %3
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %3, %11, %8
%14 = phi i32 [ %9, %8 ], [ %4, %11 ], [ %4, %3 ]
%15 = icmp eq i32 %7, -1
br i1 %15, label %16, label %3
16: ; preds = %13
ret i32 0
}