#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ cleartoendofline();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, char *, ...);
char toupper(char);
int main(int argc, const char *argv[]) {
  char c;
  char ch;
  char szIn1[33], szIn2[33], szFilename[32] = "prog1DataFile";
  FILE *pFile;
  short i;
  int exit_flag = 0;
  int valid_choice;
  while (exit_flag == 0) {
    printf("Enter a short greater than zero and a long character string less "
           "than 32 characters:\n\n");
    {
      pFile = fopen(szFilename, "a+");
      if (pFile != NULL) {
        for (i = 1; i < 2; i++) {
          scanf("%s %[^\n]", szIn1, szIn2);
          printf("You entered: %s %s\n\n", szIn1, szIn2);
          fprintf(pFile, "%s %s\n", szIn1, szIn2);
        }
        rewind(pFile);
      }
    }
    valid_choice = 0;
    while (valid_choice == 0) {
      printf("Enter Y to continue with the next entry or N to exit (Y/N):");
      scanf(" %c", &ch);
      ch = toupper(ch);
      if ((ch == 'Y') || (ch == 'N'))
        valid_choice = 1;
      else
        printf("\007Error: Invalid choice\n");
      cleartoendofline();
    }
    if (ch == 'N') {
      printf("\nAll of the below entries have been saved to file "
             "(prog1DataFile).\n\n");
      if ((pFile = fopen("prog1DataFile", "r")) == NULL) {
        perror("Please make sure that prog1DataFile was created.");
        return 0;
      }
      while ((c = fgetc(pFile)) != EOF) {
        putchar(c);
      }
      fclose(pFile);
      return 0;
    }
  }
  printf("User 1: exiting main");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe30(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe2a(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xe24(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe21(%rip),%rax
mov    %rax,-0x78(%rbp)
movl   $0x0,-0xa0(%rbp)
cmpl   $0x0,-0xa0(%rbp)
jne    13fc <main+0x24c>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     12cb <main+0x11b>
movw   $0x1,-0x9a(%rbp)
movswl -0x9a(%rbp),%eax
cmp    $0x2,%eax
jge    12bf <main+0x10f>
lea    -0x40(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   10b0 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x98(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x70(%rbp),%rcx
lea    0xdf5(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x9a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x9a(%rbp)
jmp    1251 <main+0xa1>
mov    -0x98(%rbp),%rdi
call   1070 <rewind@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jne    1351 <main+0x1a1>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xde4(%rip),%rdi
lea    -0x12(%rbp),%rsi
mov    $0x0,%al
call   10b0 <scanf@plt>
movsbl -0x12(%rbp),%edi
call   1040 <toupper@plt>
mov    %al,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
cmp    $0x59,%eax
je     1328 <main+0x178>
movsbl -0x12(%rbp),%eax
cmp    $0x4e,%eax
jne    1337 <main+0x187>
movl   $0x1,-0xa4(%rbp)
jmp    1345 <main+0x195>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <cleartoendofline@plt>
jmp    12d5 <main+0x125>
movsbl -0x12(%rbp),%eax
cmp    $0x4e,%eax
jne    13f7 <main+0x247>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc9(%rip),%rdi
lea    0xdd0(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
jne    13a8 <main+0x1f8>
lea    0xdb5(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    140a <main+0x25a>
jmp    13ad <main+0x1fd>
mov    -0x98(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2c22(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     13df <main+0x22f>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
jmp    13ad <main+0x1fd>
mov    -0x98(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    140a <main+0x25a>
jmp    1205 <main+0x55>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movaps 0xe38(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe1c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe58(%rip),%r13
lea    0xe8d(%rip),%rbx
lea    0xf(%rsp),%rbp
lea    0xf60(%rip),%r14
jmp    1222 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10b0 <cleartoendofline@plt>
cmpb   $0x4e,0xf(%rsp)
je     12e6 <main+0x126>
lea    0xea0(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rdi
lea    0xde6(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12a0 <main+0xe0>
mov    %rax,%r15
lea    0xdd5(%rip),%rdi
lea    0x60(%rsp),%r12
mov    %r12,%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   10c0 <scanf@plt>
lea    0xdc3(%rip),%rdi
mov    %r12,%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
lea    0xdbf(%rip),%rsi
mov    %r12,%rdx
lea    0x30(%rsp),%rcx
call   10a0 <fprintf@plt>
mov    %r15,%rdi
call   1080 <rewind@plt>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10c0 <scanf@plt>
movsbl 0xf(%rsp),%edi
call   1040 <toupper@plt>
mov    %al,0xf(%rsp)
cmp    $0x4e,%al
je     1210 <main+0x50>
cmp    $0x59,%al
je     1210 <main+0x50>
mov    %r14,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10b0 <cleartoendofline@plt>
jmp    12a0 <main+0xe0>
lea    0xe32(%rip),%rdi
call   1050 <puts@plt>
lea    0xd8f(%rip),%rdi
lea    0xd96(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1361 <main+0x1a1>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <fgetc@plt>
mov    0x2ccc(%rip),%rbp
cmp    0x0(%rbp),%al
je     1345 <main+0x185>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1090 <fgetc@plt>
cmp    0x0(%rbp),%al
jne    1330 <main+0x170>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd30(%rip),%rdi
call   10e0 <perror@plt>
jmp    134d <main+0x18d>

LLVM IR (-O0):
@__const.main.szFilename = [32 x i8] c"prog1DataFile\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [87 x i8] c"Enter a short greater than zero and a long character string less than 32 characters:\0A\0A\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [9 x i8] c"%s %[^\0A]\00"
@.str.3 = [21 x i8] c"You entered: %s %s\0A\0A\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
@.str.5 = [60 x i8] c"Enter Y to continue with the next entry or N to exit (Y/N):\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.7 = [24 x i8] c"\07Error: Invalid choice\0A\00"
@.str.8 = [69 x i8] c"\0AAll of the below entries have been saved to file (prog1DataFile).\0A\0A\00"
@.str.9 = [14 x i8] c"prog1DataFile\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [49 x i8] c"Please make sure that prog1DataFile was created.\00"
@EOF = global i8 0
@.str.12 = [21 x i8] c"User 1: exiting main\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca [33 x i8]
%9 = alloca [33 x i8]
%10 = alloca [32 x i8]
%11 = alloca i32*
%12 = alloca i16
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [32 x i8]* %10 to i8*
store i32 0, i32* %13
br label %16
16: ; preds = %92, %2
%17 = load i32, i32* %13
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %93
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %11
%23 = load i32*, i32** %11
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %47
25: ; preds = %19
store i16 1, i16* %12
br label %26
26: ; preds = %41, %25
%27 = load i16, i16* %12
%28 = sext i16 %27 to i32
%29 = icmp slt i32 %28, 2
br i1 %29, label %30, label %44
30: ; preds = %26
%31 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%32 = getelementptr inbounds [33 x i8], [33 x i8]* %9, i64 0, i64 0
%33 = call i32 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
%34 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [33 x i8], [33 x i8]* %9, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %34, i8* %35)
%37 = load i32*, i32** %11
%38 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%39 = getelementptr inbounds [33 x i8], [33 x i8]* %9, i64 0, i64 0
%40 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %38, i8* %39)
br label %41
41: ; preds = %30
%42 = load i16, i16* %12
%43 = add i16 %42, 1
store i16 %43, i16* %12
br label %26
44: ; preds = %26
%45 = load i32*, i32** %11
%46 = call i32 @rewind(i32* %45)
br label %47
47: ; preds = %44, %19
store i32 0, i32* %14
br label %48
48: ; preds = %66, %47
%49 = load i32, i32* %14
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %68
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%53 = call i32 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%54 = load i8, i8* %7
%55 = call signext i8 @toupper(i8 signext %54)
store i8 %55, i8* %7
%56 = load i8, i8* %7
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 89
br i1 %58, label %63, label %59
59: ; preds = %51
%60 = load i8, i8* %7
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 78
br i1 %62, label %63, label %64
63: ; preds = %59, %51
store i32 1, i32* %14
br label %66
64: ; preds = %59
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %64, %63
%67 = call i32 (...) @cleartoendofline()
br label %48
68: ; preds = %48
%69 = load i8, i8* %7
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 78
br i1 %71, label %72, label %92
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.8, i64 0, i64 0))
%74 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %74, i32** %11
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = call i32 @perror(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %3
br label %95
78: ; preds = %72
br label %79
79: ; preds = %86, %78
%80 = load i32*, i32** %11
%81 = call signext i8 @fgetc(i32* %80)
store i8 %81, i8* %6
%82 = sext i8 %81 to i32
%83 = load i8, i8* @EOF
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %82, %84
br i1 %85, label %86, label %89
86: ; preds = %79
%87 = load i8, i8* %6
%88 = call i32 @putchar(i8 signext %87)
br label %79
89: ; preds = %79
%90 = load i32*, i32** %11
%91 = call i32 @fclose(i32* %90)
store i32 0, i32* %3
br label %95
92: ; preds = %68
br label %16
93: ; preds = %16
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
br label %95
95: ; preds = %93, %89, %76
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
@__const.main.szFilename = [32 x i8] c"prog1DataFile\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [9 x i8] c"%s %[^\0A]\00"
@.str.3 = [21 x i8] c"You entered: %s %s\0A\0A\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
@.str.5 = [60 x i8] c"Enter Y to continue with the next entry or N to exit (Y/N):\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.9 = [14 x i8] c"prog1DataFile\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [49 x i8] c"Please make sure that prog1DataFile was created.\00"
@EOF = global i8 0
@str = [86 x i8] c"Enter a short greater than zero and a long character string less than 32 characters:\0A\00"
@str.13 = [68 x i8] c"\0AAll of the below entries have been saved to file (prog1DataFile).\0A\00"
@str.14 = [23 x i8] c"\07Error: Invalid choice\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = alloca [33 x i8]
%5 = alloca [33 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
br label %10
10: ; preds = %28, %2
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str, i64 0, i64 0))
%12 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = call i32 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %8)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %8)
%17 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %7, i8* %8)
%18 = call i32 @rewind(i32* %12)
br label %19
19: ; preds = %14, %10
br label %20
20: ; preds = %19, %25
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%23 = load i8, i8* %3
%24 = call signext i8 @toupper(i8 signext %23)
store i8 %24, i8* %3
switch i8 %24, label %25 [
i8 89, label %28
i8 78, label %28
]
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0))
%27 = call i32 (...) @cleartoendofline()
br label %20
28: ; preds = %20, %20
%29 = call i32 (...) @cleartoendofline()
%30 = load i8, i8* %3
%31 = icmp eq i8 %30, 78
br i1 %31, label %32, label %10
32: ; preds = %28
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.13, i64 0, i64 0))
%34 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = call signext i8 @fgetc(i32* %34)
%38 = load i8, i8* @EOF
%39 = icmp eq i8 %37, %38
br i1 %39, label %48, label %42
40: ; preds = %32
%41 = call i32 @perror(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.11, i64 0, i64 0))
br label %50
42: ; preds = %36, %42
%43 = phi i8 [ %45, %42 ], [ %37, %36 ]
%44 = call i32 @putchar(i8 signext %43)
%45 = call signext i8 @fgetc(i32* %34)
%46 = load i8, i8* @EOF
%47 = icmp eq i8 %45, %46
br i1 %47, label %48, label %42
48: ; preds = %42, %36
%49 = call i32 @fclose(i32* %34)
br label %50
50: ; preds = %48, %40
ret i32 0
}