#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 */
char CHAR_MAX;
int /*<<< orphan*/ free(char *);
char *getString(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, char *, char *);
char getChar(void) {
  while (true) {
    char c1, c2;
    char *line = getString(0);
    if (line == NULL)
      return CHAR_MAX;
    if (1 == sscanf(line, " %c %c", &c1, &c2)) {
      free(line);
      return c1;
    } else {
      free(line);
      printf("Retry: ");
    }
  }
}


x86 assembly (clang, -O0):
<getChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1030 <getString@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116f <getChar+0x2f>
mov    0x2e83(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11c4 <getChar+0x84>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    -0x2(%rbp),%rdx
lea    -0x3(%rbp),%rcx
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    11aa <getChar+0x6a>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11c4 <getChar+0x84>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
jmp    1148 <getChar+0x8>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getChar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <getString@plt>
mov    0x2e8f(%rip),%r15
test   %rax,%rax
je     11be <getChar+0x7e>
mov    %rax,%rbx
lea    0xe98(%rip),%r14
lea    0x7(%rsp),%r15
lea    0x6(%rsp),%r13
lea    0xe8e(%rip),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <free@plt>
cmp    $0x1,%ebp
je     11be <getChar+0x7e>
mov    %r12,%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <getString@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <getChar+0x40>
mov    0x2e2a(%rip),%r15
mov    (%r15),%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CHAR_MAX = global i8 0
@.str = [7 x i8] c" %c %c\00"
@.str.1 = [8 x i8] c"Retry: \00"
define signext i8 @getChar() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8*
br label %5
5: ; preds = %0, %23
%6 = call i8* @getString(i32 0)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = load i8, i8* @CHAR_MAX
store i8 %10, i8* %1
br label %24
11: ; preds = %5
%12 = load i8*, i8** %4
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3)
%14 = icmp eq i32 1, %13
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = load i8, i8* %2
store i8 %18, i8* %1
br label %24
19: ; preds = %11
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %19
br label %5
24: ; preds = %15, %9
%25 = load i8, i8* %1
ret i8 %25
}

LLVM IR (-O2):
@CHAR_MAX = global i8 0
@.str = [7 x i8] c" %c %c\00"
@.str.1 = [8 x i8] c"Retry: \00"
define signext i8 @getChar() {
%1 = alloca i8
%2 = alloca i8
%3 = call i8* @getString(i32 0)
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %0, %10
%6 = phi i8* [ %12, %10 ], [ %3, %0 ]
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%8 = icmp eq i32 %7, 1
%9 = call i32 @free(i8* %6)
br i1 %8, label %14, label %10
10: ; preds = %5
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = call i8* @getString(i32 0)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %5
14: ; preds = %10, %5, %0
%15 = phi i8* [ @CHAR_MAX, %0 ], [ @CHAR_MAX, %10 ], [ %1, %5 ]
%16 = load i8, i8* %15
ret i8 %16
}