#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*/ append_command(char, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
void set_prompt(char *prompt) {
  if (!prompt) {
    printf("No prompt chosen\n");
    exit(1);
  }
  if (strlen(prompt) > 10) {
    printf("Prompt too long\n");
    exit(1);
  }
  printf("Login prompt set to: %10s\n", prompt);
  append_command('p', prompt);
  exit(0);
}


x86 assembly (clang, -O0):
<set_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116f <set_prompt+0x2f>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
jle    1199 <set_prompt+0x59>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x70,%edi
call   1050 <append_command@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<set_prompt>:
push   %rbx
test   %rdi,%rdi
jne    115f <set_prompt+0xf>
lea    0xebe(%rip),%rdi
jmp    1173 <set_prompt+0x23>
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0xb,%eax
jl     1182 <set_prompt+0x32>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe77(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x70,%edi
mov    %rbx,%rsi
call   1060 <append_command@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"No prompt chosen\0A\00"
@.str.1 = [17 x i8] c"Prompt too long\0A\00"
@.str.2 = [27 x i8] c"Login prompt set to: %10s\0A\00"
define void @set_prompt(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = icmp sgt i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = load i8*, i8** %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %2
%19 = call i32 @append_command(i8 signext 112, i8* %18)
%20 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.2 = [27 x i8] c"Login prompt set to: %10s\0A\00"
@str = [17 x i8] c"No prompt chosen\00"
@str.3 = [16 x i8] c"Prompt too long\00"
define void @set_prompt(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 10
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%14 = tail call i32 @append_command(i8 signext 112, i8* %0)
%15 = tail call i32 @exit(i32 0)
unreachable
}