#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*/ assert(char const *);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int prompts(char const *, char const *, char *, size_t);
int /*<<< orphan*/ strcpy(char *, char *);
int s_prompts(const char *prompt, const char *def, char *s, size_t size) {
  assert(prompt);
  assert(def);
  assert(s);
  if (def != s) {
    return (prompts(prompt, def, s, size));
  }
  int rc = -1;
  char *buf;
  if (!(buf = malloc(size))) {
    return (rc);
  }
  if (!(rc = prompts(prompt, def, buf, size))) {
    strcpy(s, buf);
  }
  free(buf);
  return (rc);
}


x86 assembly (clang, -O0):
<s_prompts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11ae <s_prompts+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <prompts@plt>
mov    %eax,-0x4(%rbp)
jmp    1214 <s_prompts+0xc4>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11d7 <s_prompts+0x87>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <s_prompts+0xc4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <prompts@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jne    1205 <s_prompts+0xb5>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_prompts>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r15
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1060 <assert@plt>
mov    %rbp,%rdi
call   1060 <assert@plt>
cmp    %rbp,%rbx
je     1197 <s_prompts+0x47>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <prompts@plt>
mov    %r14,%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     11d3 <s_prompts+0x83>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
mov    %r14,%rcx
call   1050 <prompts@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11c9 <s_prompts+0x79>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
call   1030 <free@plt>
jmp    11d8 <s_prompts+0x88>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @s_prompts(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%12 = load i8*, i8** %6
%13 = call i32 @assert(i8* %12)
%14 = load i8*, i8** %7
%15 = call i32 @assert(i8* %14)
%16 = load i8*, i8** %8
%17 = call i32 @assert(i8* %16)
%18 = load i8*, i8** %7
%19 = load i8*, i8** %8
%20 = icmp ne i8* %18, %19
br i1 %20, label %21, label %27
21: ; preds = %4
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i64, i64* %9
%26 = call i32 @prompts(i8* %22, i8* %23, i8* %24, i64 %25)
store i32 %26, i32* %5
br label %48
27: ; preds = %4
store i32 -1, i32* %10
%28 = load i64, i64* %9
%29 = call i8* @malloc(i64 %28)
store i8* %29, i8** %11
%30 = icmp ne i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = load i32, i32* %10
store i32 %32, i32* %5
br label %48
33: ; preds = %27
%34 = load i8*, i8** %6
%35 = load i8*, i8** %7
%36 = load i8*, i8** %11
%37 = load i64, i64* %9
%38 = call i32 @prompts(i8* %34, i8* %35, i8* %36, i64 %37)
store i32 %38, i32* %10
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %33
%41 = load i8*, i8** %8
%42 = load i8*, i8** %11
%43 = call i32 @strcpy(i8* %41, i8* %42)
br label %44
44: ; preds = %40, %33
%45 = load i8*, i8** %11
%46 = call i32 @free(i8* %45)
%47 = load i32, i32* %10
store i32 %47, i32* %5
br label %48
48: ; preds = %44, %31, %21
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
define i32 @s_prompts(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = tail call i32 @assert(i8* %0)
%6 = tail call i32 @assert(i8* %1)
%7 = tail call i32 @assert(i8* %2)
%8 = icmp eq i8* %1, %2
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @prompts(i8* %0, i8* %1, i8* %2, i64 %3)
br label %21
11: ; preds = %4
%12 = tail call i8* @malloc(i64 %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i32 @prompts(i8* %0, i8* %1, i8* %12, i64 %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @strcpy(i8* %1, i8* %12)
br label %19
19: ; preds = %17, %14
%20 = tail call i32 @free(i8* %12)
br label %21
21: ; preds = %19, %11, %9
%22 = phi i32 [ %10, %9 ], [ %15, %19 ], [ -1, %11 ]
ret i32 %22
}