#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i = 0, itemCount = 0, input = 1, infant = 0, child = 0, teen = 0,
      adult = 0, PeopleTypes[50];
  printf("\nInput a number, 1 - 4. Where 1 represents an infant, 2 a child, 3 "
         "a teen, 4 an adult. (Use a negative number to exit.)\n");
  scanf("%d", &input);
  itemCount++;
  PeopleTypes[i] = input;
  i++;
  for (i = 1; (input > 0) && (input <= 4); i++) {
    printf("\nInput a number, 1 - 4 where 1 represents an infant, 2 a child, 3 "
           "a teen, 4 an adult. (Use a negative number to exit.)\n");
    scanf("%d", &input);
    PeopleTypes[i] = input;
    itemCount++;
    if ((input == 0) || (input > 4)) {
      printf("\nInvalid input! you entered '%d'\nPlease input 1-4 or program "
             "will exit\n",
             PeopleTypes[i]);
      scanf("%d", &input);
      if ((input == 0) || (input > 4)) {
        PeopleTypes[i] = input;
        printf("i = %d\n", i);
        itemCount++;
        i++;
      } else
        ;
    }
  }
  i--;
  itemCount--;
  printf("\n\n***END PROGRAM!***\n");
  printf("You entered the following items:\n");
  for (i = 0; i < itemCount; i++) {
    printf("%d ", PeopleTypes[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0xf1(%rbp)
jle    11c7 <main+0xa7>
cmpl   $0x4,-0x10(%rbp)
setle  %al
mov    %al,-0xf1(%rbp)
mov    -0xf1(%rbp),%al
test   $0x1,%al
jne    11da <main+0xba>
jmp    12b3 <main+0x193>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1223 <main+0x103>
cmpl   $0x4,-0x10(%rbp)
jle    12a0 <main+0x180>
movslq -0x8(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
je     1260 <main+0x140>
cmpl   $0x4,-0x10(%rbp)
jle    1296 <main+0x176>
mov    -0x10(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0x8(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    129b <main+0x17b>
jmp    129b <main+0x17b>
jmp    12a0 <main+0x180>
jmp    12a5 <main+0x185>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a8 <main+0x88>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    131b <main+0x1fb>
movslq -0x8(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12e8 <main+0x1c8>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
movl   $0x1,0xc(%rsp)
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp)
add    $0xffffffff,%eax
mov    $0x1,%r14d
cmp    $0x3,%eax
ja     1232 <main+0x102>
mov    $0x1,%r12d
lea    0xe73(%rip),%r15
lea    0xc(%rsp),%rbx
mov    $0x1,%r13d
jmp    11d4 <main+0xa4>
nopw   0x0(%rax,%rax,1)
mov    %esi,0x10(%rsp,%rbp,4)
lea    0xea0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x2,%r13d
add    $0x1,%ebp
mov    0xc(%rsp),%esi
mov    %r13d,%r14d
mov    %ebp,%r12d
add    $0x1,%r12d
add    $0xffffffff,%esi
mov    %r14d,%r13d
cmp    $0x4,%esi
jae    1232 <main+0x102>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
movslq %r12d,%rbp
mov    %esi,0x10(%rsp,%rbp,4)
lea    0x1(%r13),%r14d
test   %esi,%esi
je     1203 <main+0xd3>
cmp    $0x5,%esi
jl     11c5 <main+0x95>
lea    0xdf9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11a0 <main+0x70>
cmp    $0x5,%esi
jl     11c5 <main+0x95>
jmp    11a0 <main+0x70>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%r14d
jl     1277 <main+0x147>
add    $0xffffffff,%r14d
lea    0xdf8(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    0x10(%rsp,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1260 <main+0x130>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [121 x i8] c"\0AInput a number, 1 - 4. Where 1 represents an infant, 2 a child, 3 a teen, 4 an adult. (Use a negative number to exit.)\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [120 x i8] c"\0AInput a number, 1 - 4 where 1 represents an infant, 2 a child, 3 a teen, 4 an adult. (Use a negative number to exit.)\0A\00"
@.str.3 = [72 x i8] c"\0AInvalid input! you entered '%d'\0APlease input 1-4 or program will exit\0A\00"
@.str.4 = [8 x i8] c"i = %d\0A\00"
@.str.5 = [22 x i8] c"\0A\0A***END PROGRAM!***\0A\00"
@.str.6 = [34 x i8] c"You entered the following items:\0A\00"
@.str.7 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [50 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %16
store i32 %14, i32* %17
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
store i32 1, i32* %2
br label %20
20: ; preds = %68, %0
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp sle i32 %24, 4
br label %26
26: ; preds = %23, %20
%27 = phi i1 [ false, %20 ], [ %25, %23 ]
br i1 %27, label %28, label %71
28: ; preds = %26
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%31 = load i32, i32* %4
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %33
store i32 %31, i32* %34
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %28
%40 = load i32, i32* %4
%41 = icmp sgt i32 %40, 4
br i1 %41, label %42, label %67
42: ; preds = %39, %28
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %42
%52 = load i32, i32* %4
%53 = icmp sgt i32 %52, 4
br i1 %53, label %54, label %65
54: ; preds = %51, %42
%55 = load i32, i32* %4
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %57
store i32 %55, i32* %58
%59 = load i32, i32* %2
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
%63 = load i32, i32* %2
%64 = add nsw i32 %63, 1
store i32 %64, i32* %2
br label %66
65: ; preds = %51
br label %66
66: ; preds = %65, %54
br label %67
67: ; preds = %66, %39
br label %68
68: ; preds = %67
%69 = load i32, i32* %2
%70 = add nsw i32 %69, 1
store i32 %70, i32* %2
br label %20
71: ; preds = %26
%72 = load i32, i32* %2
%73 = add nsw i32 %72, -1
store i32 %73, i32* %2
%74 = load i32, i32* %3
%75 = add nsw i32 %74, -1
store i32 %75, i32* %3
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %2
br label %78
78: ; preds = %88, %71
%79 = load i32, i32* %2
%80 = load i32, i32* %3
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %91
82: ; preds = %78
%83 = load i32, i32* %2
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %82
%89 = load i32, i32* %2
%90 = add nsw i32 %89, 1
store i32 %90, i32* %2
br label %78
91: ; preds = %78
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [72 x i8] c"\0AInvalid input! you entered '%d'\0APlease input 1-4 or program will exit\0A\00"
@.str.4 = [8 x i8] c"i = %d\0A\00"
@.str.7 = [4 x i8] c"%d \00"
@str = [120 x i8] c"\0AInput a number, 1 - 4. Where 1 represents an infant, 2 a child, 3 a teen, 4 an adult. (Use a negative number to exit.)\00"
@str.8 = [21 x i8] c"\0A\0A***END PROGRAM!***\00"
@str.9 = [33 x i8] c"You entered the following items:\00"
@str.10 = [119 x i8] c"\0AInput a number, 1 - 4 where 1 represents an infant, 2 a child, 3 a teen, 4 an adult. (Use a negative number to exit.)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast [50 x i32]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([120 x i8], [120 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32 %7, i32* %8
%9 = add i32 %7, -1
%10 = icmp ult i32 %9, 4
br i1 %10, label %11, label %42
11: ; preds = %0, %35
%12 = phi i32 [ %39, %35 ], [ 1, %0 ]
%13 = phi i32 [ %37, %35 ], [ 1, %0 ]
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([119 x i8], [119 x i8]* @str.10, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = sext i32 %12 to i64
%18 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %17
store i32 %16, i32* %18
%19 = add nsw i32 %13, 1
%20 = icmp eq i32 %16, 0
%21 = icmp sgt i32 %16, 4
%22 = or i1 %20, %21
br i1 %22, label %23, label %35
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 0
%28 = icmp sgt i32 %26, 4
%29 = or i1 %27, %28
br i1 %29, label %30, label %35
30: ; preds = %23
store i32 %26, i32* %18
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%32 = add nsw i32 %13, 2
%33 = add nsw i32 %12, 1
%34 = load i32, i32* %1
br label %35
35: ; preds = %11, %23, %30
%36 = phi i32 [ %34, %30 ], [ %26, %23 ], [ %16, %11 ]
%37 = phi i32 [ %32, %30 ], [ %19, %23 ], [ %19, %11 ]
%38 = phi i32 [ %33, %30 ], [ %12, %23 ], [ %12, %11 ]
%39 = add nsw i32 %38, 1
%40 = add i32 %36, -1
%41 = icmp ult i32 %40, 4
br i1 %41, label %11, label %42
42: ; preds = %35, %0
%43 = phi i32 [ 1, %0 ], [ %37, %35 ]
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0))
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0))
%46 = icmp sgt i32 %43, 1
br i1 %46, label %47, label %57
47: ; preds = %42
%48 = add nsw i32 %43, -1
%49 = zext i32 %48 to i64
br label %50
50: ; preds = %47, %50
%51 = phi i64 [ 0, %47 ], [ %55, %50 ]
%52 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = icmp eq i64 %55, %49
br i1 %56, label %57, label %50
57: ; preds = %50, %42
ret i32 0
}