#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 cc_chk_digit(char *);
int cc_identify(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *get_cc_name();
  int return_val;
  if (argc != 2) {
    fprintf(stderr, "Usage: cc_dvr cc_number\n");
    exit(1);
  }
  if (cc_chk_digit(argv[1]) == 1) {
    if ((return_val = cc_identify(argv[1])) == -1) {
      printf("ERROR: cc_identify failed to identify\n");
    } else {
      printf("%s\n", get_cc_name(return_val));
    }
  } else {
    printf("This is NOT a valid CC number.\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <cc_chk_digit@plt>
cmp    $0x1,%eax
jne    1201 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <cc_identify@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11e1 <main+0x81>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fc <main+0x9c>
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1070 <get_cc_name@plt>
mov    %rax,%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1219 <main+0xb9>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11a3 <main+0x43>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <cc_chk_digit@plt>
cmp    $0x1,%eax
jne    11c2 <main+0x62>
mov    0x8(%rbx),%rdi
call   1030 <cc_identify@plt>
cmp    $0xffffffff,%eax
je     1193 <main+0x33>
mov    %eax,%edi
xor    %eax,%eax
call   1070 <get_cc_name@plt>
mov    %rax,%rdi
jmp    119a <main+0x3a>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: cc_dvr cc_number\0A\00"
@.str.1 = [39 x i8] c"ERROR: cc_identify failed to identify\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [32 x i8] c"This is NOT a valid CC number.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @cc_chk_digit(i8* %16)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %32
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @cc_identify(i8* %22)
store i32 %23, i32* %6
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %31
27: ; preds = %19
%28 = load i32, i32* %6
%29 = call i8* (i32, ...) bitcast (i8* (...)* @get_cc_name to i8* (i32, ...)*)(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %27, %25
br label %35
32: ; preds = %13
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: cc_dvr cc_number\0A\00"
@str = [31 x i8] c"This is NOT a valid CC number.\00"
@str.4 = [38 x i8] c"ERROR: cc_identify failed to identify\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @cc_chk_digit(i8* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 @cc_identify(i8* %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = tail call i8* (i32, ...) bitcast (i8* (...)* @get_cc_name to i8* (i32, ...)*)(i32 %15)
br label %22
19: ; preds = %8
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %13, %17
%23 = phi i8* [ %18, %17 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @str.4, i64 0, i64 0), %13 ]
%24 = tail call i32 @puts(i8* dereferenceable(1) %23)
ret i32 0
}