#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");
  while (fgets(userInput, 20, stdin) != NULL) {
    if (userInput[0] == '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");
    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    -0x90(%rbp),%rdi
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13e4 <main+0x254>
movsbl -0x90(%rbp),%eax
cmp    $0x4e,%eax
jne    1292 <main+0x102>
movsbl -0x8f(%rbp),%eax
cmp    $0x6f,%eax
jne    1292 <main+0x102>
jmp    13e4 <main+0x254>
jmp    1297 <main+0x107>
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     12cf <main+0x13f>
cmpl   $0x14,-0x98(%rbp)
setb   %al
mov    %al,-0x9d(%rbp)
mov    -0x9d(%rbp),%al
test   $0x1,%al
jne    12e2 <main+0x152>
jmp    130d <main+0x17d>
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    1297 <main+0x107>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    -0x90(%rbp,%rax,1),%al
mov    %al,-0x51(%rbp)
cmpl   $0x2,-0x98(%rbp)
jb     1341 <main+0x1b1>
movsbl -0x51(%rbp),%edi
call   10a0 <isAlphaNum@plt>
cmp    $0x0,%eax
jne    1354 <main+0x1c4>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    139b <main+0x20b>
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    13c7 <main+0x237>
mov    -0x9c(%rbp),%eax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    139b <main+0x20b>
movb   $0x0,-0x51(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
jmp    1249 <main+0xb9>
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>
mov    0x2dd0(%rip),%r15
mov    (%r15),%edx
lea    0x20(%rsp),%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1344 <main+0x1b4>
lea    0xe77(%rip),%r14
lea    0x20(%rsp),%r12
jmp    1280 <main+0xf0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    (%r15),%edx
mov    %r12,%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1344 <main+0x1b4>
mov    0x20(%rsp),%al
cmp    $0x4e,%al
jne    1293 <main+0x103>
cmpb   $0x6f,0x21(%rsp)
je     1344 <main+0x1b4>
movsbl %al,%edi
call   10b0 <isUpperAlpha@plt>
test   %rax,%rax
je     1250 <main+0xc0>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x20(%rsp,%rbp,1),%eax
mov    %al,(%rsp,%rbp,1)
lea    0x1(%rbp),%rbx
movsbl 0x21(%rsp,%rbp,1),%edi
call   10b0 <isUpperAlpha@plt>
test   %rax,%rax
je     12d4 <main+0x144>
cmp    $0x13,%rbp
mov    %rbx,%rbp
jb     12b0 <main+0x120>
test   $0xfffffffe,%ebx
je     1250 <main+0xc0>
movsbl 0x21(%rsp,%rbx,1),%r13d
mov    %r13d,%edi
call   10a0 <isAlphaNum@plt>
test   %eax,%eax
je     1250 <main+0xc0>
lea    0xd13(%rip),%rdi
lea    0x60(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd0a(%rip),%rdi
mov    %rsp,%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd03(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
call   1050 <strfilter@plt>
jmp    1258 <main+0xc8>
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"
@stdin = global i32 0
@.str.1 = [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.2 = [13 x i8] c"s1 = {\22%s\22}\0A\00"
@.str.3 = [13 x i8] c"s2 = {\22%s\22}\0A\00"
@.str.4 = [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 = %23, %0
%16 = load i32, i32* %6
%17 = icmp ult i32 %16, 40
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = call signext i8 (...) @randUpperChar()
%20 = load i32, i32* %6
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 %21
store i8 %19, i8* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %6
%25 = add i32 %24, 1
store i32 %25, i32* %6
br label %15
26: ; preds = %15
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %105, %26
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%30 = load i32, i32* @stdin
%31 = call i32* @fgets(i8* %29, i32 20, i32 %30)
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %106
33: ; preds = %28
%34 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 78
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 111
br i1 %42, label %43, label %44
43: ; preds = %38
br label %106
44: ; preds = %38, %33
br label %45
45: ; preds = %57, %44
%46 = load i32, i32* %7
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = call i64 @isUpperAlpha(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %45
%53 = load i32, i32* %7
%54 = icmp ult i32 %53, 20
br label %55
55: ; preds = %52, %45
%56 = phi i1 [ false, %45 ], [ %54, %52 ]
br i1 %56, label %57, label %67
57: ; preds = %55
%58 = load i32, i32* %7
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = load i32, i32* %7
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %63
store i8 %61, i8* %64
%65 = load i32, i32* %7
%66 = add i32 %65, 1
store i32 %66, i32* %7
br label %45
67: ; preds = %55
%68 = load i32, i32* %7
%69 = add i32 %68, 1
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %70
%72 = load i8, i8* %71
store i8 %72, i8* %4
%73 = load i32, i32* %7
%74 = icmp ult i32 %73, 2
br i1 %74, label %79, label %75
75: ; preds = %67
%76 = load i8, i8* %4
%77 = call i32 @isAlphaNum(i8 signext %76)
%78 = icmp ne i32 %77, 0
br i1 %78, label %81, label %79
79: ; preds = %75, %67
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str.1, i64 0, i64 0))
br label %93
81: ; preds = %75
%82 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %82)
%84 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %84)
%86 = load i8, i8* %4
%87 = sext i8 %86 to i32
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%90 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%91 = load i8, i8* %4
%92 = call i32 @strfilter(i8* %89, i8* %90, i8 signext %91)
br label %93
93: ; preds = %81, %79
%94 = load i32, i32* %8
br label %95
95: ; preds = %102, %93
%96 = load i32, i32* %8
%97 = icmp ult i32 %96, 20
br i1 %97, label %98, label %105
98: ; preds = %95
%99 = load i32, i32* %8
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %100
store i8 0, i8* %101
br label %102
102: ; preds = %98
%103 = load i32, i32* %8
%104 = add i32 %103, 1
store i32 %104, i32* %8
br label %95
105: ; preds = %95
store i8 0, i8* %4
store i32 0, i32* %7
store i32 0, i32* %8
br label %28
106: ; preds = %43, %28
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.2 = [13 x i8] c"s1 = {\22%s\22}\0A\00"
@.str.3 = [13 x i8] c"s2 = {\22%s\22}\0A\00"
@.str.4 = [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.5 = [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"
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 = load i32, i32* @stdin
%19 = call i32* @fgets(i8* %7, i32 20, i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %66, label %21
21: ; preds = %16
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 1
br label %23
23: ; preds = %21, %62
%24 = load i8, i8* %7
%25 = icmp eq i8 %24, 78
%26 = load i8, i8* %22
%27 = icmp eq i8 %26, 111
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %66, label %29
29: ; preds = %23
%30 = call i64 @isUpperAlpha(i8 signext %24)
%31 = icmp eq i64 %30, 0
br i1 %31, label %54, label %32
32: ; preds = %29, %32
%33 = phi i64 [ %37, %32 ], [ 0, %29 ]
%34 = phi i8* [ %38, %32 ], [ %7, %29 ]
%35 = load i8, i8* %34
%36 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %33
store i8 %35, i8* %36
%37 = add nuw nsw i64 %33, 1
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = call i64 @isUpperAlpha(i8 signext %39)
%41 = icmp ne i64 %40, 0
%42 = icmp ult i64 %33, 19
%43 = select i1 %41, i1 %42, i1 false
br i1 %43, label %32, label %44
44: ; preds = %32
%45 = add nuw i64 %33, 2
%46 = and i64 %45, 4294967295
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = and i64 %37, 4294967294
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %44
%52 = call i32 @isAlphaNum(i8 signext %48)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %29, %51, %44
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([112 x i8], [112 x i8]* @str.5, i64 0, i64 0))
br label %62
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%59 = sext i8 %48 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %59)
%61 = call i32 @strfilter(i8* %5, i8* %6, i8 signext %48)
br label %62
62: ; preds = %56, %54
%63 = load i32, i32* @stdin
%64 = call i32* @fgets(i8* %7, i32 20, i32 %63)
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %23
66: ; preds = %62, %23, %16
ret i32 0
}