#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 */
scalar_t__ get_user_input(char *, size_t, char const **);
int /*<<< orphan*/ printf(char *, char const *);
void display_user_prompt(const char *prompt_msg, char *buffer, size_t len) {
  const char *err_msg = NULL;
  do {
    if (err_msg != NULL) {
      printf("Error: %s\n", err_msg);
      err_msg = NULL;
    }
    printf("%s", prompt_msg);
  } while (get_user_input(buffer, len, &err_msg) == 0 || err_msg != NULL);
}


x86 assembly (clang, -O0):
<display_user_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     115f <display_user_prompt+0x3f>
mov    -0x20(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <get_user_input@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     119d <display_user_prompt+0x7d>
cmpq   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    113c <display_user_prompt+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_user_prompt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movq   $0x0,(%rsp)
xor    %esi,%esi
lea    0xec6(%rip),%r12
mov    %rsp,%r13
lea    0xeb1(%rip),%rbp
nop
test   %rsi,%rsi
je     1165 <display_user_prompt+0x45>
mov    %rbp,%rdi
call   1040 <printf@plt>
movq   $0x0,(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1030 <get_user_input@plt>
mov    (%rsp),%rsi
test   %rax,%rax
je     1150 <display_user_prompt+0x30>
test   %rsi,%rsi
jne    1150 <display_user_prompt+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Error: %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define void @display_user_prompt(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i8* null, i8** %7
br label %8
8: ; preds = %25, %3
%9 = load i8*, i8** %7
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i8*, i8** %7
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12)
store i8* null, i8** %7
br label %14
14: ; preds = %11, %8
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = load i64, i64* %6
%20 = call i64 @get_user_input(i8* %18, i64 %19, i8** %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = icmp ne i8* %23, null
br label %25
25: ; preds = %22, %17
%26 = phi i1 [ true, %17 ], [ %24, %22 ]
br i1 %26, label %8, label %27
27: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Error: %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define void @display_user_prompt(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
br label %6
6: ; preds = %11, %3
%7 = phi i8* [ %15, %11 ], [ null, %3 ]
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %7)
store i8* null, i8** %4
br label %11
11: ; preds = %9, %6
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = call i64 @get_user_input(i8* %1, i64 %2, i8** %4)
%14 = icmp eq i64 %13, 0
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %6, label %18
18: ; preds = %11
ret void
}