#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ getenv(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, scalar_t__, int);
void make_table(char *name, char *table) {
  int nc;
  char local_name[256];
  strcpy(local_name, name);
  if (getenv(local_name))
    strncpy(table, getenv(local_name), 256);
  else {
    fprintf(stderr, "Error: %s environment variable not defined\n", name);
    exit(1);
  }
  nc = strlen(table);
  if (table[nc - 1] == '/')
    table[nc - 1] = '\0';
  strcat(table, "/P_tt_JB");
}


x86 assembly (clang, -O0):
<make_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0x120(%rbp),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11d9 <make_table+0x69>
mov    -0x10(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
call   1030 <getenv@plt>
mov    -0x128(%rbp),%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
jmp    11fc <make_table+0x8c>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe13(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1233 <make_table+0xc3>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1080 <strcat@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_table>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %r15,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11df <make_table+0x6f>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    11c3 <make_table+0x53>
movb   $0x0,-0x1(%rbx,%rax,1)
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
mov    %r14,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"Error: %s environment variable not defined\0A\00"
@.str.1 = [9 x i8] c"/P_tt_JB\00"
define void @make_table(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [256 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i64 @getenv(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = call i64 @getenv(i8* %15)
%17 = call i32 @strncpy(i8* %14, i64 %16, i32 256)
br label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %3
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %13
%24 = load i8*, i8** %4
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %5
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 47
br i1 %33, label %34, label %40
34: ; preds = %23
%35 = load i8*, i8** %4
%36 = load i32, i32* %5
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %34, %23
%41 = load i8*, i8** %4
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"Error: %s environment variable not defined\0A\00"
@.str.1 = [9 x i8] c"/P_tt_JB\00"
define void @make_table(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = call i64 @getenv(i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %2
%9 = call i32 @strncpy(i8* %1, i64 %6, i32 256)
%10 = call i32 @strlen(i8* %1)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 47
br i1 %15, label %20, label %21
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %0)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %8
store i8 0, i8* %13
br label %21
21: ; preds = %20, %8
%22 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret void
}