#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*/ puts(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void c_prompt(char *arg[], int argc) {
  extern char Prompt[1000];
  if (argc > 1000 - 1)
    puts("error: prompt is too long.");
  else if (argc != 1) {
    if (!strcmp(arg[1], "null")) {
      strcpy(Prompt, "");
      return;
    }
    strncpy(Prompt, "", 1000);
    strcpy(Prompt, arg[1]);
    Prompt[strlen(Prompt)] = ' ';
  }
}


x86 assembly (clang, -O0):
<c_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x3e7,-0xc(%rbp)
jle    117d <c_prompt+0x2d>
lea    0xe8d(%rip),%rdi
call   1050 <puts@plt>
jmp    1207 <c_prompt+0xb7>
cmpl   $0x1,-0xc(%rbp)
je     1202 <c_prompt+0xb2>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe85(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11bc <c_prompt+0x6c>
mov    0x2e3d(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1207 <c_prompt+0xb7>
mov    0x2e25(%rip),%rdi
lea    0xe50(%rip),%rsi
mov    $0x3e8,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x2e05(%rip),%rdi
call   1040 <strcpy@plt>
mov    0x2df9(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    0x2dea(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
jmp    1207 <c_prompt+0xb7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_prompt>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3e8,%esi
jl     116f <c_prompt+0x1f>
lea    0xe9d(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <puts@plt>
cmp    $0x1,%esi
je     11bf <c_prompt+0x6f>
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
lea    0xe99(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11c7 <c_prompt+0x77>
mov    0x2e56(%rip),%r14
lea    0xe81(%rip),%rsi
mov    %r14,%rdi
mov    $0x3e8,%edx
call   1030 <strncpy@plt>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
movb   $0x20,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e1a(%rip),%rdi
lea    0xe45(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcpy@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"error: prompt is too long.\00"
@.str.1 = [5 x i8] c"null\00"
@Prompt = external global [1000 x i8]
@.str.2 = [1 x i8] zeroinitializer
define void @c_prompt(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, 999
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %29
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i8**, i8*** %3
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = call i32 @strcpy(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %29
20: ; preds = %12
%21 = call i32 @strncpy(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i32 1000)
%22 = load i8**, i8*** %3
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0), i8* %24)
%26 = call i64 @strlen(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0))
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 %26
store i8 32, i8* %27
br label %28
28: ; preds = %20, %9
br label %29
29: ; preds = %18, %28, %7
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"error: prompt is too long.\00"
@.str.1 = [5 x i8] c"null\00"
@Prompt = external global [1000 x i8]
@.str.2 = [1 x i8] zeroinitializer
define void @c_prompt(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 999
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %21
6: ; preds = %2
%7 = icmp eq i32 %1, 1
br i1 %7, label %21, label %8
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %0, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @strcpy(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %21
15: ; preds = %8
%16 = tail call i32 @strncpy(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i32 1000)
%17 = load i8*, i8** %9
%18 = tail call i32 @strcpy(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0), i8* %17)
%19 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 0))
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* @Prompt, i64 0, i64 %19
store i8 32, i8* %20
br label %21
21: ; preds = %6, %15, %13, %4
ret void
}