#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ getstr(char *, char const *, char *, int);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char *);
const char *GetString(const char *prompt, const char *deflt, const char *help) {
  static char s[200];
  while (1) {
    sprintf(s, "\n%s%s", prompt, (*help) ? " (Type ? for Help)" : "");
    getstr(s, deflt, s, sizeof(s));
    if (*s == '?' && *help)
      printf("%s", help);
    else
      return (s);
  }
}


x86 assembly (clang, -O0):
<GetString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xec2(%rip),%rcx
lea    0xea9(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0x2ee5(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0x2ece(%rip),%rdx
mov    $0xc8,%ecx
mov    %rdx,%rdi
call   1040 <getstr@plt>
movsbl 0x2eba(%rip),%eax
cmp    $0x3f,%eax
jne    11c4 <GetString+0x94>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c4 <GetString+0x94>
mov    -0x18(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
jmp    11d1 <GetString+0xa1>
lea    0x2e85(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret
jmp    1144 <GetString+0x14>

x86 assembly (clang, -O2):
<GetString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
cmpb   $0x0,(%rdx)
lea    0xeca(%rip),%rax
lea    0xeb1(%rip),%rcx
cmove  %rax,%rcx
lea    0x2ef0(%rip),%rbp
lea    0xe99(%rip),%rsi
mov    %rbp,%rdi
mov    %r15,%rdx
call   1050 <sprintf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    $0xc8,%ecx
call   1040 <getstr@plt>
cmpb   $0x3f,0x2ec4(%rip)
jne    11ff <GetString+0xcf>
lea    0xe6e(%rip),%r12
lea    0x2eb4(%rip),%r13
lea    0xe5d(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,(%rbx)
je     11ff <GetString+0xcf>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
cmpb   $0x0,(%rbx)
lea    0xe3c(%rip),%rcx
lea    0xe47(%rip),%rax
cmove  %rax,%rcx
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1050 <sprintf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    $0xc8,%ecx
call   1040 <getstr@plt>
cmpb   $0x3f,0x2e53(%rip)
je     11b0 <GetString+0x80>
lea    0x2e4a(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GetString.s = internal global [200 x i8] zeroinitializer
@.str = [6 x i8] c"\0A%s%s\00"
@.str.1 = [19 x i8] c" (Type ? for Help)\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%s\00"
define i8* @GetString(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
br label %7
7: ; preds = %3, %30
%8 = load i8*, i8** %4
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%15 = call i32 @sprintf(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %14)
%16 = load i8*, i8** %5
%17 = call i32 @getstr(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i32 200)
%18 = load i8, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0)
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 63
br i1 %20, label %21, label %29
21: ; preds = %7
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i8*, i8** %6
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %30
29: ; preds = %21, %7
ret i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0)
30: ; preds = %26
br label %7
}

LLVM IR (-O2):
@GetString.s = internal global [200 x i8] zeroinitializer
@.str = [6 x i8] c"\0A%s%s\00"
@.str.1 = [19 x i8] c" (Type ? for Help)\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%s\00"
define i8* @GetString(i8* %0, i8* %1, i8* %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0)
%7 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %6)
%8 = tail call i32 @getstr(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i32 200)
%9 = load i8, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0)
%10 = icmp eq i8 %9, 63
br i1 %10, label %11, label %23
11: ; preds = %3, %14
%12 = load i8, i8* %2
%13 = icmp eq i8 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%16 = load i8, i8* %2
%17 = icmp eq i8 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0)
%19 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %18)
%20 = tail call i32 @getstr(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0), i32 200)
%21 = load i8, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0)
%22 = icmp eq i8 %21, 63
br i1 %22, label %11, label %23
23: ; preds = %14, %11, %3
ret i8* getelementptr inbounds ([200 x i8], [200 x i8]* @GetString.s, i64 0, i64 0)
}