#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *getInput();
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
unsigned int strlen(char *);
char *getZip(void) {
  printf("Zip Code: ");
  char *zip = getInput();
  if (zip == NULL) {
    printf("You have entered an invalid zipcode.\n");
    exit(12);
  }
  unsigned int len = strlen(zip);
  if (len != 11 && len != 6) {
    printf("Your zip code is an invalid length ERR1\n", len);
    printf("Please use the format 12345 or 12345-6789.\n");
    free(zip);
    exit(13);
  }
  for (unsigned int i = 0; i < len; i++) {
    if (i != 6) {
      if ((!(isdigit(zip[i])) && zip[i] != '\n')) {
        printf("Your zip code is invalid\n");
        printf("Please use the format 12345 or 12345-678. ERR2\n");
        free(zip);
        exit(14);
      }
    } else if (zip[i] != '-') {
      printf("Your zip code is an invalid length.\n");
      printf("Please use the format 12345 or 12345-678.\n");
      free(zip);
      exit(15);
    }
  }
  return zip;
}


x86 assembly (clang, -O0):
<getZip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <getInput@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a4 <getZip+0x44>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xc,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xb,-0xc(%rbp)
je     11f6 <getZip+0x96>
cmpl   $0x6,-0xc(%rbp)
je     11f6 <getZip+0x96>
mov    -0xc(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0xd,%edi
call   1080 <exit@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    12cf <getZip+0x16f>
cmpl   $0x6,-0x10(%rbp)
je     1274 <getZip+0x114>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    126f <getZip+0x10f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     126f <getZip+0x10f>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0xe,%edi
call   1080 <exit@plt>
jmp    12bc <getZip+0x15c>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     12b7 <getZip+0x157>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0xf,%edi
call   1080 <exit@plt>
jmp    12bc <getZip+0x15c>
jmp    12c1 <getZip+0x161>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fd <getZip+0x9d>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getZip>:
push   %rbp
push   %r14
push   %rbx
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1080 <getInput@plt>
test   %rax,%rax
je     12a8 <getZip+0x138>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
cmp    $0x6,%eax
je     11ad <getZip+0x3d>
cmp    $0xb,%ebp
jne    12be <getZip+0x14e>
movsbl (%r14),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    11c4 <getZip+0x54>
cmpb   $0xa,(%r14)
jne    127e <getZip+0x10e>
movsbl 0x1(%r14),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    11dd <getZip+0x6d>
cmpb   $0xa,0x1(%r14)
jne    127e <getZip+0x10e>
movsbl 0x2(%r14),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    11f6 <getZip+0x86>
cmpb   $0xa,0x2(%r14)
jne    127e <getZip+0x10e>
movsbl 0x3(%r14),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    120b <getZip+0x9b>
cmpb   $0xa,0x3(%r14)
jne    127e <getZip+0x10e>
movsbl 0x4(%r14),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1220 <getZip+0xb0>
cmpb   $0xa,0x4(%r14)
jne    127e <getZip+0x10e>
movsbl 0x5(%r14),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1235 <getZip+0xc5>
cmpb   $0xa,0x5(%r14)
jne    127e <getZip+0x10e>
cmp    $0x6,%ebp
je     124a <getZip+0xda>
cmpb   $0x2d,0x6(%r14)
jne    12e8 <getZip+0x178>
cmp    $0x7,%ebp
jne    1252 <getZip+0xe2>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebp,%ebp
mov    $0x7,%ebx
jmp    1269 <getZip+0xf9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     124a <getZip+0xda>
movsbl (%r14,%rbx,1),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1260 <getZip+0xf0>
cmpb   $0xa,(%r14,%rbx,1)
je     1260 <getZip+0xf0>
lea    0xdd4(%rip),%rdi
call   1050 <puts@plt>
lea    0xde1(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0xe,%edi
call   1090 <exit@plt>
lea    0xe45(%rip),%rdi
call   1050 <puts@plt>
mov    $0xc,%edi
call   1090 <exit@plt>
lea    0xddc(%rip),%rdi
call   1050 <puts@plt>
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0xd,%edi
call   1090 <exit@plt>
lea    0xd1c(%rip),%rdi
call   1050 <puts@plt>
lea    0xd34(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0xf,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Zip Code: \00"
@.str.1 = [38 x i8] c"You have entered an invalid zipcode.\0A\00"
@.str.2 = [41 x i8] c"Your zip code is an invalid length ERR1\0A\00"
@.str.3 = [44 x i8] c"Please use the format 12345 or 12345-6789.\0A\00"
@.str.4 = [26 x i8] c"Your zip code is invalid\0A\00"
@.str.5 = [48 x i8] c"Please use the format 12345 or 12345-678. ERR2\0A\00"
@.str.6 = [37 x i8] c"Your zip code is an invalid length.\0A\00"
@.str.7 = [43 x i8] c"Please use the format 12345 or 12345-678.\0A\00"
define i8* @getZip() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = call i8* (...) @getInput()
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 12)
unreachable
11: ; preds = %0
%12 = load i8*, i8** %1
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 11
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 6
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%23 = load i8*, i8** %1
%24 = call i32 @free(i8* %23)
%25 = call i32 @exit(i32 13)
unreachable
26: ; preds = %16, %11
store i32 0, i32* %3
br label %27
27: ; preds = %73, %26
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp ult i32 %28, %29
br i1 %30, label %31, label %76
31: ; preds = %27
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 6
br i1 %33, label %34, label %57
34: ; preds = %31
%35 = load i8*, i8** %1
%36 = load i32, i32* %3
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @isdigit(i8 signext %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %56, label %42
42: ; preds = %34
%43 = load i8*, i8** %1
%44 = load i32, i32* %3
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 10
br i1 %49, label %50, label %56
50: ; preds = %42
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%53 = load i8*, i8** %1
%54 = call i32 @free(i8* %53)
%55 = call i32 @exit(i32 14)
unreachable
56: ; preds = %42, %34
br label %72
57: ; preds = %31
%58 = load i8*, i8** %1
%59 = load i32, i32* %3
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 45
br i1 %64, label %65, label %71
65: ; preds = %57
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0))
%68 = load i8*, i8** %1
%69 = call i32 @free(i8* %68)
%70 = call i32 @exit(i32 15)
unreachable
71: ; preds = %57
br label %72
72: ; preds = %71, %56
br label %73
73: ; preds = %72
%74 = load i32, i32* %3
%75 = add i32 %74, 1
store i32 %75, i32* %3
br label %27
76: ; preds = %27
%77 = load i8*, i8** %1
ret i8* %77
}

LLVM IR (-O2):
@.str = [11 x i8] c"Zip Code: \00"
@str = [36 x i8] c"Your zip code is an invalid length.\00"
@str.8 = [42 x i8] c"Please use the format 12345 or 12345-678.\00"
@str.9 = [25 x i8] c"Your zip code is invalid\00"
@str.10 = [47 x i8] c"Please use the format 12345 or 12345-678. ERR2\00"
@str.11 = [40 x i8] c"Your zip code is an invalid length ERR1\00"
@str.12 = [43 x i8] c"Please use the format 12345 or 12345-6789.\00"
@str.13 = [37 x i8] c"You have entered an invalid zipcode.\00"
define i8* @getZip() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* (...) @getInput()
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.13, i64 0, i64 0))
%6 = tail call i32 @exit(i32 12)
unreachable
7: ; preds = %0
%8 = tail call i32 @strlen(i8* %2)
switch i32 %8, label %9 [
i32 11, label %14
i32 6, label %14
]
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.11, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.12, i64 0, i64 0))
%12 = tail call i32 @free(i8* %2)
%13 = tail call i32 @exit(i32 13)
unreachable
14: ; preds = %7, %7
%15 = getelementptr inbounds i8, i8* %2, i64 6
%16 = zext i32 %8 to i64
%17 = load i8, i8* %2
%18 = tail call i32 @isdigit(i8 signext %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8, i8* %2
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %80
23: ; preds = %20, %14
%24 = getelementptr inbounds i8, i8* %2, i64 1
%25 = load i8, i8* %24
%26 = tail call i32 @isdigit(i8 signext %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i8, i8* %24
%30 = icmp eq i8 %29, 10
br i1 %30, label %31, label %80
31: ; preds = %28, %23
%32 = getelementptr inbounds i8, i8* %2, i64 2
%33 = load i8, i8* %32
%34 = tail call i32 @isdigit(i8 signext %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i8, i8* %32
%38 = icmp eq i8 %37, 10
br i1 %38, label %39, label %80
39: ; preds = %36, %31
%40 = getelementptr inbounds i8, i8* %2, i64 3
%41 = load i8, i8* %40
%42 = tail call i32 @isdigit(i8 signext %41)
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i8, i8* %40
%46 = icmp eq i8 %45, 10
br i1 %46, label %47, label %80
47: ; preds = %44, %39
%48 = getelementptr inbounds i8, i8* %2, i64 4
%49 = load i8, i8* %48
%50 = tail call i32 @isdigit(i8 signext %49)
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = load i8, i8* %48
%54 = icmp eq i8 %53, 10
br i1 %54, label %55, label %80
55: ; preds = %52, %47
%56 = getelementptr inbounds i8, i8* %2, i64 5
%57 = load i8, i8* %56
%58 = tail call i32 @isdigit(i8 signext %57)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = load i8, i8* %56
%62 = icmp eq i8 %61, 10
br i1 %62, label %63, label %80
63: ; preds = %60, %55
%64 = icmp eq i32 %8, 6
br i1 %64, label %70, label %65
65: ; preds = %63
%66 = load i8, i8* %15
%67 = icmp eq i8 %66, 45
br i1 %67, label %68, label %85
68: ; preds = %65
%69 = icmp eq i32 %8, 7
br i1 %69, label %70, label %71
70: ; preds = %90, %63, %68
ret i8* %2
71: ; preds = %68, %90
%72 = phi i64 [ %91, %90 ], [ 7, %68 ]
%73 = getelementptr inbounds i8, i8* %2, i64 %72
%74 = load i8, i8* %73
%75 = tail call i32 @isdigit(i8 signext %74)
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %90
77: ; preds = %71
%78 = load i8, i8* %73
%79 = icmp eq i8 %78, 10
br i1 %79, label %90, label %80
80: ; preds = %77, %60, %52, %44, %36, %28, %20
%81 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.10, i64 0, i64 0))
%83 = tail call i32 @free(i8* %2)
%84 = tail call i32 @exit(i32 14)
unreachable
85: ; preds = %65
%86 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
%88 = tail call i32 @free(i8* %2)
%89 = tail call i32 @exit(i32 15)
unreachable
90: ; preds = %77, %71
%91 = add nuw nsw i64 %72, 1
%92 = icmp eq i64 %91, %16
br i1 %92, label %70, label %71
}