#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 */
char *cpy_str2(char *, char *);
char *my_getenv(char **, char *);
char *my_prompt(char **env) {
  char *str;
  if (env[0] == NULL)
    return ("$> ");
  if ((str = my_getenv(env, "USER")) != NULL) {
    str = cpy_str2(str, "--> ");
    return (str);
  } else
    return ("$> ");
  return ("$> ");
}


x86 assembly (clang, -O0):
<my_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    114a <my_prompt+0x2a>
lea    0xebf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1194 <my_prompt+0x74>
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <my_getenv@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1189 <my_prompt+0x69>
mov    -0x18(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <cpy_str2@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1194 <my_prompt+0x74>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_prompt>:
push   %rax
cmpq   $0x0,(%rdi)
je     1148 <my_prompt+0x28>
lea    0xed6(%rip),%rsi
call   1030 <my_getenv@plt>
test   %rax,%rax
je     1148 <my_prompt+0x28>
lea    0xeca(%rip),%rsi
mov    %rax,%rdi
pop    %rax
jmp    1040 <cpy_str2@plt>
lea    0xeb1(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"$> \00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [5 x i8] c"--> \00"
define i8* @my_prompt(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
%5 = load i8**, i8*** %3
%6 = getelementptr inbounds i8*, i8** %5, i64 0
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
10: ; preds = %1
%11 = load i8**, i8*** %3
%12 = call i8* @my_getenv(i8** %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i8* @cpy_str2(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %16, i8** %4
%17 = load i8*, i8** %4
store i8* %17, i8** %2
br label %19
18: ; preds = %10
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %18, %14, %9
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [4 x i8] c"$> \00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [5 x i8] c"--> \00"
define i8* @my_prompt(i8** %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i8* @my_getenv(i8** %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i8* @cpy_str2(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %4, %1, %7
%10 = phi i8* [ %8, %7 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %4 ]
ret i8* %10
}