#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*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
char *sbfile(char fulname[], char name[]) {
  char *cptr;
  if ((cptr = getenv("BOITHOHOME")) == NULL) {
    fprintf(stderr, "Error: Can't get environment value \"BOITHOHOME\"\n");
    return NULL;
  } else if (name[0] == '/') {
    fprintf(stderr,
            "Error: name starts with a /. Yoy must use virtual adressing\n");
    return NULL;
  }
  sprintf(fulname, "%s/%s", cptr, name);
  return fulname;
}


x86 assembly (clang, -O0):
<sbfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117c <sbfile+0x4c>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d3 <sbfile+0xa3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11ae <sbfile+0x7e>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d3 <sbfile+0xa3>
jmp    11b3 <sbfile+0x83>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeb3(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sbfile>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1163 <sbfile+0x33>
cmpb   $0x2f,(%r14)
jne    117c <sbfile+0x4c>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xedb(%rip),%rsi
jmp    1173 <sbfile+0x43>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
jmp    1191 <sbfile+0x61>
lea    0xef6(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"BOITHOHOME\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"Error: Can't get environment value \22BOITHOHOME\22\0A\00"
@.str.2 = [61 x i8] c"Error: name starts with a /. Yoy must use virtual adressing\0A\00"
@.str.3 = [6 x i8] c"%s/%s\00"
define i8* @sbfile(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %3
br label %28
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %3
br label %28
21: ; preds = %12
br label %22
22: ; preds = %21
%23 = load i8*, i8** %4
%24 = load i8*, i8** %6
%25 = load i8*, i8** %5
%26 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %25)
%27 = load i8*, i8** %4
store i8* %27, i8** %3
br label %28
28: ; preds = %22, %18, %9
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@.str = [11 x i8] c"BOITHOHOME\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"Error: Can't get environment value \22BOITHOHOME\22\0A\00"
@.str.2 = [61 x i8] c"Error: name starts with a /. Yoy must use virtual adressing\0A\00"
@.str.3 = [6 x i8] c"%s/%s\00"
define i8* @sbfile(i8* writeonly %0, i8* %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %16
8: ; preds = %2
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 47
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %8
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %1)
br label %16
16: ; preds = %14, %11, %5
%17 = phi i8* [ null, %5 ], [ null, %11 ], [ %0, %14 ]
ret i8* %17
}