int sgetc(s)
char *s;
{
  char *s1;
  int ch;
  (void)refresh();
  for (;;) {
    ch = toupper(getch());
    if (ch == 3)
      uninitgame();
    for (s1 = s; *s1 && ch != *s1; ++s1)
      continue;
    if (*s1) {
      (void)addch((char)ch);
      (void)refresh();
      return (ch);
    }
  }
}


x86 assembly (clang, -O0):
<sgetc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <refresh@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jne    1185 <sgetc+0x35>
mov    $0x0,%al
call   1040 <uninitgame@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     11b4 <sgetc+0x64>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11c4 <sgetc+0x74>
jmp    11da <sgetc+0x8a>
jmp    11c9 <sgetc+0x79>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118d <sgetc+0x3d>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1204 <sgetc+0xb4>
mov    -0x14(%rbp),%eax
movsbl %al,%edi
mov    $0x0,%al
call   1050 <addch@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    1163 <sgetc+0x13>

x86 assembly (clang, -O2):
<sgetc>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <refresh@plt>
jmp    1164 <sgetc+0x14>
nop
test   %cl,%cl
jne    11a1 <sgetc+0x51>
xor    %eax,%eax
call   1070 <getch@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
cmp    $0x3,%eax
jne    1180 <sgetc+0x30>
xor    %eax,%eax
call   1040 <uninitgame@plt>
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rax),%ecx
test   %ecx,%ecx
je     1160 <sgetc+0x10>
add    $0x1,%rax
cmp    %ecx,%ebp
jne    1190 <sgetc+0x40>
jmp    1160 <sgetc+0x10>
movsbl %bpl,%edi
xor    %eax,%eax
call   1050 <addch@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sgetc(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 (...) @refresh()
br label %6
6: ; preds = %43, %1
%7 = call i32 (...) @getch()
%8 = call i32 @toupper(i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 (...) @uninitgame()
br label %13
13: ; preds = %11, %6
%14 = load i8*, i8** %2
store i8* %14, i8** %3
br label %15
15: ; preds = %29, %13
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i32, i32* %4
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %21, %24
br label %26
26: ; preds = %20, %15
%27 = phi i1 [ false, %15 ], [ %25, %20 ]
br i1 %27, label %28, label %32
28: ; preds = %26
br label %29
29: ; preds = %28
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
br label %15
32: ; preds = %26
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = icmp ne i8 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32, i32* %4
%38 = trunc i32 %37 to i8
%39 = sext i8 %38 to i32
%40 = call i32 (i32, ...) bitcast (i32 (...)* @addch to i32 (i32, ...)*)(i32 %39)
%41 = call i32 (...) @refresh()
%42 = load i32, i32* %4
ret i32 %42
43: ; preds = %32
br label %6
}

LLVM IR (-O2):
define i32 @sgetc(i8* nocapture %0) {
%2 = tail call i32 (...) @refresh()
br label %3
3: ; preds = %18, %1
%4 = tail call i32 (...) @getch()
%5 = tail call i32 @toupper(i32 %4)
%6 = icmp eq i32 %5, 3
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (...) @uninitgame()
br label %9
9: ; preds = %7, %3
br label %10
10: ; preds = %9, %10
%11 = phi i8* [ %17, %10 ], [ %0, %9 ]
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = sext i8 %12 to i32
%15 = icmp eq i32 %5, %14
%16 = select i1 %13, i1 true, i1 %15
%17 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %16, label %18, label %10
18: ; preds = %10
br i1 %13, label %3, label %19
19: ; preds = %18
%20 = shl i32 %5, 24
%21 = ashr exact i32 %20, 24
%22 = tail call i32 (i32, ...) bitcast (i32 (...)* @addch to i32 (i32, ...)*)(i32 %21)
%23 = tail call i32 (...) @refresh()
ret i32 %5
}