#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 numPlaces(unsigned long long);
int /*<<< orphan*/ printf(char *, ...);
int sumevens(unsigned long long);
int sumodds(unsigned long long);
int main(void) {
  unsigned long long int number = 391447635398431;
  printf("The credit card number is %llu\n", number);
  int esum = sumevens(number);
  int osum = sumodds(number);
  int checksum = (esum + osum) % 10;
  if (checksum == 0) {
    if ((numPlaces(number) == 16) && (number / 1000000000000000 == 4)) {
      printf("Valid credit card: Visa\n");
    } else if ((numPlaces(number) == 16) && (number / 1000000000000000 == 5) &&
               ((number / 100000000000000) % 10 < 6)) {
      printf("Valid credit card: MasterCard\n");
    } else if ((numPlaces(number) == 15) && (number / 100000000000000 == 3) &&
               (((number / 10000000000000) % 10 == 4) ||
                ((number / 10000000000000) % 10 == 7))) {
      printf("Valid credit card: American Express\n");
    } else {
      printf("Valid credit card: Unknown bank\n");
    }
  } else {
    printf("Invalid credit card\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x1640501418f1f,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <sumevens@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sumodds@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12fa <main+0x1ba>
mov    -0x10(%rbp),%rdi
call   1050 <numPlaces@plt>
cmp    $0x10,%eax
jne    11e4 <main+0xa4>
mov    -0x10(%rbp),%rax
movabs $0x38d7ea4c68000,%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x4,%rax
jne    11e4 <main+0xa4>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f5 <main+0x1b5>
mov    -0x10(%rbp),%rdi
call   1050 <numPlaces@plt>
cmp    $0x10,%eax
jne    124d <main+0x10d>
mov    -0x10(%rbp),%rax
movabs $0x38d7ea4c68000,%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x5,%rax
jne    124d <main+0x10d>
mov    -0x10(%rbp),%rax
movabs $0x5af3107a4000,%rcx
xor    %edx,%edx
div    %rcx
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x6,%rdx
jae    124d <main+0x10d>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f0 <main+0x1b0>
mov    -0x10(%rbp),%rdi
call   1050 <numPlaces@plt>
cmp    $0xf,%eax
jne    12dd <main+0x19d>
mov    -0x10(%rbp),%rax
movabs $0x5af3107a4000,%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x3,%rax
jne    12dd <main+0x19d>
mov    -0x10(%rbp),%rax
movabs $0x9184e72a000,%rcx
xor    %edx,%edx
div    %rcx
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x4,%rdx
je     12ca <main+0x18a>
mov    -0x10(%rbp),%rax
movabs $0x9184e72a000,%rcx
xor    %edx,%edx
div    %rcx
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x7,%rdx
jne    12dd <main+0x19d>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12eb <main+0x1ab>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f0 <main+0x1b0>
jmp    12f5 <main+0x1b5>
jmp    1308 <main+0x1c8>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
movabs $0x1640501418f1f,%rbx
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <sumevens@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <sumodds@plt>
add    %ebp,%eax
imul   $0xcccccccd,%eax,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
jbe    119f <main+0x4f>
lea    0xe83(%rip),%rdi
jmp    11be <main+0x6e>
mov    %rbx,%rdi
call   1060 <numPlaces@plt>
mov    %rbx,%rdi
call   1060 <numPlaces@plt>
mov    %rbx,%rdi
call   1060 <numPlaces@plt>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"The credit card number is %llu\0A\00"
@.str.1 = [25 x i8] c"Valid credit card: Visa\0A\00"
@.str.2 = [31 x i8] c"Valid credit card: MasterCard\0A\00"
@.str.3 = [37 x i8] c"Valid credit card: American Express\0A\00"
@.str.4 = [33 x i8] c"Valid credit card: Unknown bank\0A\00"
@.str.5 = [21 x i8] c"Invalid credit card\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i64 391447635398431, i64* %2
%6 = load i64, i64* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = load i64, i64* %2
%9 = call i32 @sumevens(i64 %8)
store i32 %9, i32* %3
%10 = load i64, i64* %2
%11 = call i32 @sumodds(i64 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = add nsw i32 %12, %13
%15 = srem i32 %14, 10
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %68
18: ; preds = %0
%19 = load i64, i64* %2
%20 = call i32 @numPlaces(i64 %19)
%21 = icmp eq i32 %20, 16
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i64, i64* %2
%24 = udiv i64 %23, 1000000000000000
%25 = icmp eq i64 %24, 4
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %67
28: ; preds = %22, %18
%29 = load i64, i64* %2
%30 = call i32 @numPlaces(i64 %29)
%31 = icmp eq i32 %30, 16
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = load i64, i64* %2
%34 = udiv i64 %33, 1000000000000000
%35 = icmp eq i64 %34, 5
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i64, i64* %2
%38 = udiv i64 %37, 100000000000000
%39 = urem i64 %38, 10
%40 = icmp ult i64 %39, 6
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %66
43: ; preds = %36, %32, %28
%44 = load i64, i64* %2
%45 = call i32 @numPlaces(i64 %44)
%46 = icmp eq i32 %45, 15
br i1 %46, label %47, label %63
47: ; preds = %43
%48 = load i64, i64* %2
%49 = udiv i64 %48, 100000000000000
%50 = icmp eq i64 %49, 3
br i1 %50, label %51, label %63
51: ; preds = %47
%52 = load i64, i64* %2
%53 = udiv i64 %52, 10000000000000
%54 = urem i64 %53, 10
%55 = icmp eq i64 %54, 4
br i1 %55, label %61, label %56
56: ; preds = %51
%57 = load i64, i64* %2
%58 = udiv i64 %57, 10000000000000
%59 = urem i64 %58, 10
%60 = icmp eq i64 %59, 7
br i1 %60, label %61, label %63
61: ; preds = %56, %51
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %65
63: ; preds = %56, %47, %43
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
br label %66
66: ; preds = %65, %41
br label %67
67: ; preds = %66, %26
br label %70
68: ; preds = %0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %68, %67
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"The credit card number is %llu\0A\00"
@str = [20 x i8] c"Invalid credit card\00"
@str.6 = [32 x i8] c"Valid credit card: Unknown bank\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 391447635398431)
%2 = tail call i32 @sumevens(i64 391447635398431)
%3 = tail call i32 @sumodds(i64 391447635398431)
%4 = add nsw i32 %3, %2
%5 = srem i32 %4, 10
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = tail call i32 @numPlaces(i64 391447635398431)
%9 = tail call i32 @numPlaces(i64 391447635398431)
%10 = tail call i32 @numPlaces(i64 391447635398431)
br label %11
11: ; preds = %0, %7
%12 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0), %0 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
ret i32 0
}