#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ isAlphaNum(char);
scalar_t__ isUpperAlpha(char);
int /*<<< orphan*/ printf(char *, ...);
char randUpperChar();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strfilter(char *, char *, char);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char s1[41] = "\0";
  char s2[21] = "\0";
  char c = '\0';
  char userInput[50] = "\0";
  unsigned int i = 0;
  unsigned int j = 0;
  unsigned int k = 0;
  srand(time(NULL));
  for (i; i < 40; i++) {
    *(s1 + i) = randUpperChar();
  }
  printf("Let's reset some letters!\nPlease input at least 2 upper case "
         "letters to reset followed by a space and a \"reset\" character.\n");
  printf("Or type \"No\" to quit.\n");
  while (fgets(userInput, 20, stdin) != NULL) {
    if (*userInput == 'N' && *(userInput + 1) == 'o')
      break;
    while (isUpperAlpha(*(userInput + j)) && j < 20) {
      *(s2 + j) = *(userInput + j);
      j++;
    }
    c = *(userInput + j + 1);
    if (j < 2 || !isAlphaNum(c)) {
      printf("Invalid input.\nPlease input at least 2 upper case letters to "
             "reset followed by a space and a \"reset\" character.\n");
      printf("Or type \"No\" to quit.\n");
    } else {
      printf("s1 = {\"%s\"}\n", s1);
      printf("s2 = {\"%s\"}\n", s2);
      printf("c = {\"%c\"}\n", c);
      strfilter(s1, s2, c);
    }
    for (k; k < 20; k++)
      *(s2 + k) = '\0';
    c = '\0';
    j = 0;
    k = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x29,%edx
call   1060 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1060 <memset@plt>
movb   $0x0,-0x51(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmpl   $0x28,-0x94(%rbp)
jae    123b <main+0xab>
mov    $0x0,%al
call   1030 <randUpperChar@plt>
mov    %al,%cl
mov    -0x94(%rbp),%eax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1207 <main+0x77>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2d83(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13fb <main+0x26b>
movsbl -0x90(%rbp),%eax
cmp    $0x4e,%eax
jne    12a0 <main+0x110>
movsbl -0x8f(%rbp),%eax
cmp    $0x6f,%eax
jne    12a0 <main+0x110>
jmp    13fb <main+0x26b>
jmp    12a5 <main+0x115>
mov    -0x98(%rbp),%eax
movsbl -0x90(%rbp,%rax,1),%edi
ff
call   10b0 <isUpperAlpha@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x9d(%rbp)
je     12dd <main+0x14d>
cmpl   $0x14,-0x98(%rbp)
setb   %al
mov    %al,-0x9d(%rbp)
mov    -0x9d(%rbp),%al
test   $0x1,%al
jne    12f0 <main+0x160>
jmp    131b <main+0x18b>
mov    -0x98(%rbp),%eax
mov    -0x90(%rbp,%rax,1),%cl
mov    -0x98(%rbp),%eax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    12a5 <main+0x115>
mov    -0x98(%rbp),%eax
mov    -0x8f(%rbp,%rax,1),%al
mov    %al,-0x51(%rbp)
cmpl   $0x2,-0x98(%rbp)
jb     134a <main+0x1ba>
movsbl -0x51(%rbp),%edi
call   10a0 <isAlphaNum@plt>
cmp    $0x0,%eax
jne    136b <main+0x1db>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13b2 <main+0x222>
lea    -0x30(%rbp),%rsi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x51(%rbp),%esi
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
movsbl -0x51(%rbp),%edx
call   1040 <strfilter@plt>
cmpl   $0x14,-0x9c(%rbp)
jae    13de <main+0x24e>
mov    -0x9c(%rbp),%eax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    13b2 <main+0x222>
movb   $0x0,-0x51(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
jmp    1257 <main+0xc7>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x79(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xd(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x50(%rsp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <randUpperChar@plt>
mov    %al,0x60(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x28,%rbx
jne    11f0 <main+0x60>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf09(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dc4(%rip),%r13
mov    0x0(%r13),%edx
lea    0x20(%rsp),%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1350 <main+0x1c0>
lea    0xe6a(%rip),%r15
lea    0x20(%rsp),%r14
jmp    128d <main+0xfd>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1350 <main+0x1c0>
mov    0x20(%rsp),%al
cmp    $0x4e,%al
jne    12a0 <main+0x110>
cmpb   $0x6f,0x21(%rsp)
je     1350 <main+0x1c0>
movsbl %al,%edi
call   10b0 <isUpperAlpha@plt>
test   %rax,%rax
je     1250 <main+0xc0>
xor    %ebp,%ebp
nop
movzbl 0x20(%rsp,%rbp,1),%eax
mov    %al,(%rsp,%rbp,1)
lea    0x1(%rbp),%r12
movsbl 0x21(%rsp,%rbp,1),%edi
call   10b0 <isUpperAlpha@plt>
test   %rax,%rax
je     12d4 <main+0x144>
cmp    $0x13,%rbp
mov    %r12,%rbp
jb     12b0 <main+0x120>
test   $0xfffffffe,%r12d
je     1250 <main+0xc0>
movsbl 0x21(%rsp,%r12,1),%ebp
mov    %ebp,%edi
call   10a0 <isAlphaNum@plt>
test   %eax,%eax
je     1250 <main+0xc0>
lea    0xd13(%rip),%rdi
mov    %r15,%r12
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd0a(%rip),%rdi
mov    %r14,%rbx
mov    %r13,%r14
mov    %rsp,%r13
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcfd(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x60(%rsp),%rdi
mov    %r13,%rsi
mov    %r14,%r13
mov    %rbx,%r14
mov    %ebp,%edx
call   1050 <strfilter@plt>
jmp    1264 <main+0xd4>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [124 x i8] c"Let's reset some letters!\0APlease input at least 2 upper case letters to reset followed by a space and a \22reset\22 character.\0A\00"
@.str.1 = [23 x i8] c"Or type \22No\22 to quit.\0A\00"
@stdin = global i32 0
@.str.2 = [113 x i8] c"Invalid input.\0APlease input at least 2 upper case letters to reset followed by a space and a \22reset\22 character.\0A\00"
@.str.3 = [13 x i8] c"s1 = {\22%s\22}\0A\00"
@.str.4 = [13 x i8] c"s2 = {\22%s\22}\0A\00"
@.str.5 = [12 x i8] c"c = {\22%c\22}\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [41 x i8]
%3 = alloca [21 x i8]
%4 = alloca i8
%5 = alloca [50 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [41 x i8]* %2 to i8*
%10 = bitcast [21 x i8]* %3 to i8*
store i8 0, i8* %4
%11 = bitcast [50 x i8]* %5 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
%14 = load i32, i32* %6
br label %15
15: ; preds = %24, %0
%16 = load i32, i32* %6
%17 = icmp ult i32 %16, 40
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = call signext i8 (...) @randUpperChar()
%20 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %18
%25 = load i32, i32* %6
%26 = add i32 %25, 1
store i32 %26, i32* %6
br label %15
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %114, %27
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%32 = load i32, i32* @stdin
%33 = call i32* @fgets(i8* %31, i32 20, i32 %32)
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %115
35: ; preds = %30
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 78
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 111
br i1 %45, label %46, label %47
46: ; preds = %40
br label %115
47: ; preds = %40, %35
br label %48
48: ; preds = %61, %47
%49 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%50 = load i32, i32* %7
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = call i64 @isUpperAlpha(i8 signext %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %48
%57 = load i32, i32* %7
%58 = icmp ult i32 %57, 20
br label %59
59: ; preds = %56, %48
%60 = phi i1 [ false, %48 ], [ %58, %56 ]
br i1 %60, label %61, label %73
61: ; preds = %59
%62 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%63 = load i32, i32* %7
%64 = zext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%68 = load i32, i32* %7
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
store i8 %66, i8* %70
%71 = load i32, i32* %7
%72 = add i32 %71, 1
store i32 %72, i32* %7
br label %48
73: ; preds = %59
%74 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%75 = load i32, i32* %7
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = load i8, i8* %78
store i8 %79, i8* %4
%80 = load i32, i32* %7
%81 = icmp ult i32 %80, 2
br i1 %81, label %86, label %82
82: ; preds = %73
%83 = load i8, i8* %4
%84 = call i32 @isAlphaNum(i8 signext %83)
%85 = icmp ne i32 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %82, %73
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str.2, i64 0, i64 0))
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %101
89: ; preds = %82
%90 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %90)
%92 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %92)
%94 = load i8, i8* %4
%95 = sext i8 %94 to i32
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %95)
%97 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%98 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%99 = load i8, i8* %4
%100 = call i32 @strfilter(i8* %97, i8* %98, i8 signext %99)
br label %101
101: ; preds = %89, %86
%102 = load i32, i32* %8
br label %103
103: ; preds = %111, %101
%104 = load i32, i32* %8
%105 = icmp ult i32 %104, 20
br i1 %105, label %106, label %114
106: ; preds = %103
%107 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%108 = load i32, i32* %8
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %107, i64 %109
store i8 0, i8* %110
br label %111
111: ; preds = %106
%112 = load i32, i32* %8
%113 = add i32 %112, 1
store i32 %113, i32* %8
br label %103
114: ; preds = %103
store i8 0, i8* %4
store i32 0, i32* %7
store i32 0, i32* %8
br label %30
115: ; preds = %46, %30
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.3 = [13 x i8] c"s1 = {\22%s\22}\0A\00"
@.str.4 = [13 x i8] c"s2 = {\22%s\22}\0A\00"
@.str.5 = [12 x i8] c"c = {\22%c\22}\0A\00"
@str = [123 x i8] c"Let's reset some letters!\0APlease input at least 2 upper case letters to reset followed by a space and a \22reset\22 character.\00"
@str.7 = [112 x i8] c"Invalid input.\0APlease input at least 2 upper case letters to reset followed by a space and a \22reset\22 character.\00"
@str.8 = [22 x i8] c"Or type \22No\22 to quit.\00"
define i32 @main() {
%1 = alloca [41 x i8]
%2 = alloca [21 x i8]
%3 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [41 x i8], [41 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
br label %10
10: ; preds = %0, %10
%11 = phi i64 [ 0, %0 ], [ %14, %10 ]
%12 = tail call signext i8 (...) @randUpperChar()
%13 = getelementptr inbounds [41 x i8], [41 x i8]* %1, i64 0, i64 %11
store i8 %12, i8* %13
%14 = add nuw nsw i64 %11, 1
%15 = icmp eq i64 %14, 40
br i1 %15, label %16, label %10
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([123 x i8], [123 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i32* @fgets(i8* %7, i32 20, i32 %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %67, label %22
22: ; preds = %16
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 1
br label %24
24: ; preds = %22, %63
%25 = load i8, i8* %7
%26 = icmp eq i8 %25, 78
%27 = load i8, i8* %23
%28 = icmp eq i8 %27, 111
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %67, label %30
30: ; preds = %24
%31 = call i64 @isUpperAlpha(i8 signext %25)
%32 = icmp eq i64 %31, 0
br i1 %32, label %54, label %33
33: ; preds = %30, %33
%34 = phi i64 [ %38, %33 ], [ 0, %30 ]
%35 = phi i8* [ %39, %33 ], [ %7, %30 ]
%36 = load i8, i8* %35
%37 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %34
store i8 %36, i8* %37
%38 = add nuw nsw i64 %34, 1
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = call i64 @isUpperAlpha(i8 signext %40)
%42 = icmp ne i64 %41, 0
%43 = icmp ult i64 %34, 19
%44 = select i1 %42, i1 %43, i1 false
br i1 %44, label %33, label %45
45: ; preds = %33
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %38
%47 = getelementptr inbounds i8, i8* %46, i64 1
%48 = load i8, i8* %47
%49 = and i64 %38, 4294967294
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %45
%52 = call i32 @isAlphaNum(i8 signext %48)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %30, %51, %45
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([112 x i8], [112 x i8]* @str.7, i64 0, i64 0))
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
br label %63
57: ; preds = %51
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%60 = sext i8 %48 to i32
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%62 = call i32 @strfilter(i8* %5, i8* %6, i8 signext %48)
br label %63
63: ; preds = %57, %54
%64 = load i32, i32* @stdin
%65 = call i32* @fgets(i8* %7, i32 20, i32 %64)
%66 = icmp eq i32* %65, null
br i1 %66, label %67, label %24
67: ; preds = %63, %24, %16
ret i32 0
}