char testgetch(void) {
  char word[80];
  int len;
  scanf("%s", word);
  len = strlen(word);
  if (len == 1) {
    if (isgraph(word)) {
      return getch_(0);
    } else {
      return getch_(1);
    }
  } else {
    return word;
  }
}


x86 assembly (clang, -O0):
<testgetch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x60(%rbp),%rsi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x1,-0x64(%rbp)
jne    11a9 <testgetch+0x69>
lea    -0x60(%rbp),%rax
mov    %eax,%edi
call   1060 <isgraph@plt>
cmp    $0x0,%eax
je     1195 <testgetch+0x55>
xor    %edi,%edi
mov    $0x0,%al
call   1040 <getch_@plt>
mov    %al,-0x1(%rbp)
jmp    11b0 <testgetch+0x70>
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <getch_@plt>
mov    %al,-0x1(%rbp)
jmp    11b0 <testgetch+0x70>
lea    -0x60(%rbp),%rax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testgetch>:
push   %rbx
sub    $0x50,%rsp
lea    0xeb4(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1176 <testgetch+0x36>
mov    %rsp,%rdi
call   1060 <isgraph@plt>
test   %eax,%eax
je     117b <testgetch+0x3b>
xor    %edi,%edi
jmp    1180 <testgetch+0x40>
mov    %rsp,%rax
jmp    1187 <testgetch+0x47>
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <getch_@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define signext i8 @testgetch() {
%1 = alloca i8
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%7 = call i64 @strlen(i8* %6)
%8 = trunc i64 %7 to i32
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %22
11: ; preds = %0
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%13 = ptrtoint i8* %12 to i32
%14 = call i32 @isgraph(i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = call i32 (i32, ...) bitcast (i32 (...)* @getch_ to i32 (i32, ...)*)(i32 0)
%18 = trunc i32 %17 to i8
store i8 %18, i8* %1
br label %25
19: ; preds = %11
%20 = call i32 (i32, ...) bitcast (i32 (...)* @getch_ to i32 (i32, ...)*)(i32 1)
%21 = trunc i32 %20 to i8
store i8 %21, i8* %1
br label %25
22: ; preds = %0
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%24 = ptrtoint i8* %23 to i8
store i8 %24, i8* %1
br label %25
25: ; preds = %22, %19, %16
%26 = load i8, i8* %1
ret i8 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define signext i8 @testgetch() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i64 @strlen(i8* %2)
%5 = trunc i64 %4 to i32
%6 = icmp eq i32 %5, 1
%7 = ptrtoint [80 x i8]* %1 to i64
br i1 %6, label %8, label %18
8: ; preds = %0
%9 = trunc i64 %7 to i32
%10 = call i32 @isgraph(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = call i32 (i32, ...) bitcast (i32 (...)* @getch_ to i32 (i32, ...)*)(i32 0)
%14 = trunc i32 %13 to i8
br label %20
15: ; preds = %8
%16 = call i32 (i32, ...) bitcast (i32 (...)* @getch_ to i32 (i32, ...)*)(i32 1)
%17 = trunc i32 %16 to i8
br label %20
18: ; preds = %0
%19 = trunc i64 %7 to i8
br label %20
20: ; preds = %18, %15, %12
%21 = phi i8 [ %14, %12 ], [ %17, %15 ], [ %19, %18 ]
ret i8 %21
}