#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 */
char *InputHandler();
int /*<<< orphan*/ checkNullity(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printf(char *);
char *getCreditCard(void) {
  printf("Credit Card: ");
  char *card = InputHandler();
  checkNullity(card);
  int length = 20;
  for (int i = 0; i < length; i++) {
    if (i == 4 || i == 9 || i == 14) {
      if (card[i] != '-') {
        printf("Your credit card information is not in the correct format.\n");
        printf("Example: 1234-1234-1234-1234\n");
        free(card);
        exit(3);
      }
    } else {
      if (!isdigit(card[i])) {
        if (!(i == length - 1 && card[i] == '\n')) {
          printf("Your credit card contains invalid digits.\n");
          printf("Example: 1234-1234-1234-1234\n");
          free(card);
          exit(4);
        }
      }
    }
  }
  return card;
}


x86 assembly (clang, -O0):
<getCreditCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <InputHandler@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <checkNullity@plt>
movl   $0x14,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128d <getCreditCard+0x12d>
cmpl   $0x4,-0x10(%rbp)
je     11c0 <getCreditCard+0x60>
cmpl   $0x9,-0x10(%rbp)
je     11c0 <getCreditCard+0x60>
cmpl   $0xe,-0x10(%rbp)
jne    1205 <getCreditCard+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     1200 <getCreditCard+0xa0>
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
lea    0xe62(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x3,%edi
call   1070 <exit@plt>
jmp    127a <getCreditCard+0x11a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    1275 <getCreditCard+0x115>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1245 <getCreditCard+0xe5>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1270 <getCreditCard+0x110>
lea    0xe1c(%rip),%rdi
call   1050 <printf@plt>
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x4,%edi
call   1070 <exit@plt>
jmp    1275 <getCreditCard+0x115>
jmp    127a <getCreditCard+0x11a>
jmp    127f <getCreditCard+0x11f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1196 <getCreditCard+0x36>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCreditCard>:
push   %rbp
push   %r14
push   %rbx
lea    0xe85(%rip),%rdi
call   1060 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <InputHandler@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <checkNullity@plt>
mov    $0x4210,%ebp
jmp    11b8 <getCreditCard+0x48>
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
je     11f3 <getCreditCard+0x83>
add    $0x1,%rbx
cmp    $0x14,%rbx
je     1200 <getCreditCard+0x90>
cmp    $0xe,%ebx
ja     11a0 <getCreditCard+0x30>
bt     %ebx,%ebp
jae    11a0 <getCreditCard+0x30>
cmpb   $0x2d,(%r14,%rbx,1)
je     11ae <getCreditCard+0x3e>
lea    0xe68(%rip),%rdi
call   1050 <puts@plt>
lea    0xe97(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x3,%edi
call   1080 <exit@plt>
cmp    $0x13,%rbx
jne    1208 <getCreditCard+0x98>
cmpb   $0xa,(%r14,%rbx,1)
jne    1208 <getCreditCard+0x98>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdff(%rip),%rdi
call   1050 <puts@plt>
lea    0xe58(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x4,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Credit Card: \00"
@.str.1 = [60 x i8] c"Your credit card information is not in the correct format.\0A\00"
@.str.2 = [30 x i8] c"Example: 1234-1234-1234-1234\0A\00"
@.str.3 = [43 x i8] c"Your credit card contains invalid digits.\0A\00"
define i8* @getCreditCard() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i8* (...) @InputHandler()
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = call i32 @checkNullity(i8* %6)
store i32 20, i32* %2
store i32 0, i32* %3
br label %8
8: ; preds = %66, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %69
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 4
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 9
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 14
br i1 %20, label %21, label %36
21: ; preds = %18, %15, %12
%22 = load i8*, i8** %1
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 45
br i1 %28, label %29, label %35
29: ; preds = %21
%30 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%32 = load i8*, i8** %1
%33 = call i32 @free(i8* %32)
%34 = call i32 @exit(i32 3)
unreachable
35: ; preds = %21
br label %65
36: ; preds = %18
%37 = load i8*, i8** %1
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = call i32 @isdigit(i8 signext %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %64, label %44
44: ; preds = %36
%45 = load i32, i32* %3
%46 = load i32, i32* %2
%47 = sub nsw i32 %46, 1
%48 = icmp eq i32 %45, %47
br i1 %48, label %49, label %57
49: ; preds = %44
%50 = load i8*, i8** %1
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 10
br i1 %56, label %63, label %57
57: ; preds = %49, %44
%58 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%59 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%60 = load i8*, i8** %1
%61 = call i32 @free(i8* %60)
%62 = call i32 @exit(i32 4)
unreachable
63: ; preds = %49
br label %64
64: ; preds = %63, %36
br label %65
65: ; preds = %64, %35
br label %66
66: ; preds = %65
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %8
69: ; preds = %8
%70 = load i8*, i8** %1
ret i8* %70
}

LLVM IR (-O2):
@.str = [14 x i8] c"Credit Card: \00"
@str = [42 x i8] c"Your credit card contains invalid digits.\00"
@str.5 = [59 x i8] c"Your credit card information is not in the correct format.\00"
@str.6 = [29 x i8] c"Example: 1234-1234-1234-1234\00"
define i8* @getCreditCard() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* (...) @InputHandler()
%3 = tail call i32 @checkNullity(i8* %2)
br label %5
4: ; preds = %33, %24
ret i8* %2
5: ; preds = %0, %33
%6 = phi i64 [ 0, %0 ], [ %34, %33 ]
%7 = trunc i64 %6 to i32
switch i32 %7, label %17 [
i32 14, label %8
i32 9, label %8
i32 4, label %8
]
8: ; preds = %5, %5, %5
%9 = getelementptr inbounds i8, i8* %2, i64 %6
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 45
br i1 %11, label %33, label %12
12: ; preds = %8
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.5, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%15 = tail call i32 @free(i8* %2)
%16 = tail call i32 @exit(i32 3)
unreachable
17: ; preds = %5
%18 = getelementptr inbounds i8, i8* %2, i64 %6
%19 = load i8, i8* %18
%20 = tail call i32 @isdigit(i8 signext %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %17
%23 = icmp eq i64 %6, 19
br i1 %23, label %24, label %28
24: ; preds = %22
%25 = getelementptr inbounds i8, i8* %2, i64 %6
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 10
br i1 %27, label %4, label %28
28: ; preds = %24, %22
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%31 = tail call i32 @free(i8* %2)
%32 = tail call i32 @exit(i32 4)
unreachable
33: ; preds = %8, %17
%34 = add nuw nsw i64 %6, 1
%35 = icmp eq i64 %34, 20
br i1 %35, label %4, label %5
}