#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*/ sedb_message(char *, ...);
int sedb_read_line_in(char *, int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ sedb_yes_or_no(char *, int);
void sedb_get_string(char *name, char *buffer) {
  int i;
  int again;
  do {
    again = 0;
    i = sedb_read_line_in(buffer, 0, "%s: ", name);
    if (i == 0) {
      sedb_message("The empty string is not allowed.\n");
      again = 1;
    } else {
      sedb_message("%s = \"%s\"", name, buffer);
      again = (!sedb_yes_or_no(" confirm", 1));
    }
  } while (again);
}


x86 assembly (clang, -O0):
<sedb_get_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
xor    %esi,%esi
lea    0xea8(%rip),%rdx
call   1040 <sedb_read_line_in@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1184 <sedb_get_string+0x54>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <sedb_message@plt>
movl   $0x1,-0x18(%rbp)
jmp    11bb <sedb_get_string+0x8b>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <sedb_message@plt>
lea    0xe90(%rip),%rdi
mov    $0x1,%esi
call   1050 <sedb_yes_or_no@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    11c0 <sedb_get_string+0x90>
cmpl   $0x0,-0x18(%rbp)
jne    1140 <sedb_get_string+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sedb_get_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb8(%rip),%r15
lea    0xeb6(%rip),%r12
lea    0xed1(%rip),%r13
lea    0xed4(%rip),%rbp
jmp    1188 <sedb_get_string+0x58>
nop
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <sedb_message@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
call   1050 <sedb_yes_or_no@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
test   %ecx,%ecx
je     11af <sedb_get_string+0x7f>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <sedb_read_line_in@plt>
test   %eax,%eax
jne    1160 <sedb_get_string+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <sedb_message@plt>
mov    $0x1,%ecx
test   %ecx,%ecx
jne    1188 <sedb_get_string+0x58>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [34 x i8] c"The empty string is not allowed.\0A\00"
@.str.2 = [10 x i8] c"%s = \22%s\22\00"
@.str.3 = [9 x i8] c" confirm\00"
define void @sedb_get_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %24, %2
store i32 0, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @sedb_read_line_in(i8* %8, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 (i8*, ...) @sedb_message(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %23
15: ; preds = %7
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = call i32 (i8*, ...) @sedb_message(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %17)
%19 = call i32 @sedb_yes_or_no(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 1)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
store i32 %22, i32* %6
br label %23
23: ; preds = %15, %13
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 0
br i1 %26, label %7, label %27
27: ; preds = %24
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [34 x i8] c"The empty string is not allowed.\0A\00"
@.str.2 = [10 x i8] c"%s = \22%s\22\00"
@.str.3 = [9 x i8] c" confirm\00"
define void @sedb_get_string(i8* %0, i8* %1) {
br label %3
3: ; preds = %13, %2
%4 = tail call i32 @sedb_read_line_in(i8* %1, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @sedb_message(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %13
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @sedb_message(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%10 = tail call i32 @sedb_yes_or_no(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 1)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %6, %8
%14 = phi i32 [ 1, %6 ], [ %12, %8 ]
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %3
16: ; preds = %13
ret void
}