#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*/ chomp(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ *trim(int /*<<< orphan*/);
char *io_get_string(char *output, int maxlength, const char *use) {
  char *value = NULL;
  strcpy(output, use);
  if (trim(chomp(fgets(output, maxlength, stdin))) != NULL) {
    if (!strcmp(output, ""))
      strcpy(output, use);
    value = output;
  }
  return value;
}


x86 assembly (clang, -O0):
<io_get_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    %eax,%edi
call   1070 <chomp@plt>
mov    %eax,%edi
call   1040 <trim@plt>
cmp    $0x0,%rax
je     11d3 <io_get_string+0x83>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11cb <io_get_string+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_get_string>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rdx,%rsi
call   1030 <strcpy@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <fgets@plt>
mov    %eax,%edi
call   1060 <chomp@plt>
mov    %eax,%edi
call   1040 <trim@plt>
test   %rax,%rax
je     118c <io_get_string+0x4c>
cmpb   $0x0,(%rbx)
jne    118e <io_get_string+0x4e>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    118e <io_get_string+0x4e>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [1 x i8] zeroinitializer
define i8* @io_get_string(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8* null, i8** %7
%8 = load i8*, i8** %4
%9 = load i8*, i8** %6
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %11, i32 %12, i32 %13)
%15 = call i32 @chomp(i32 %14)
%16 = call i32* @trim(i32 %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %28
18: ; preds = %3
%19 = load i8*, i8** %4
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = load i8*, i8** %6
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %26
26: ; preds = %22, %18
%27 = load i8*, i8** %4
store i8* %27, i8** %7
br label %28
28: ; preds = %26, %3
%29 = load i8*, i8** %7
ret i8* %29
}

LLVM IR (-O2):
@stdin = global i32 0
define i8* @io_get_string(i8* %0, i32 %1, i8* %2) {
%4 = tail call i32 @strcpy(i8* %0, i8* %2)
%5 = load i32, i32* @stdin
%6 = tail call i32 @fgets(i8* %0, i32 %1, i32 %5)
%7 = tail call i32 @chomp(i32 %6)
%8 = tail call i32* @trim(i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @strcpy(i8* %0, i8* %2)
br label %15
15: ; preds = %10, %13, %3
%16 = phi i8* [ null, %3 ], [ %0, %13 ], [ %0, %10 ]
ret i8* %16
}