#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*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ open_shell(char *);
scalar_t__ setenv(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, const char **argv) {
  if (setenv("PS1", "\\033[34m\\u@recovery:\\w\\$\\033[0m ", 1) < 0) {
    fprintf(stderr, "Error setting PS1: %s\n", strerror(errno));
  }
  open_shell("/dev/tty1");
  open_shell("/dev/ttyS0");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    0xea0(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
jge    11a4 <main+0x64>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe86(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe91(%rip),%rdi
call   1050 <open_shell@plt>
lea    0xe8f(%rip),%rdi
call   1050 <open_shell@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
test   %rax,%rax
jns    1186 <main+0x46>
mov    0x2e7b(%rip),%rax
mov    (%rax),%ebx
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xea9(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
lea    0xeaf(%rip),%rdi
call   1050 <open_shell@plt>
lea    0xead(%rip),%rdi
call   1050 <open_shell@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"PS1\00"
@.str.1 = [33 x i8] c"\\033[34m\\u@recovery:\\w\\$\\033[0m \00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Error setting PS1: %s\0A\00"
@errno = global i32 0
@.str.3 = [10 x i8] c"/dev/tty1\00"
@.str.4 = [11 x i8] c"/dev/ttyS0\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i64 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %8, %2
%14 = call i32 @open_shell(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @open_shell(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [4 x i8] c"PS1\00"
@.str.1 = [33 x i8] c"\\033[34m\\u@recovery:\\w\\$\\033[0m \00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Error setting PS1: %s\0A\00"
@errno = global i32 0
@.str.3 = [10 x i8] c"/dev/tty1\00"
@.str.4 = [11 x i8] c"/dev/ttyS0\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %5, %2
%11 = tail call i32 @open_shell(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @open_shell(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}