#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 *, int, char *, int,
                           char *);
char *getenv(char *);
int getpid();
int /*<<< orphan*/ stderr;
void resolve(char **v, char *varname, char **p, char *buffer, size_t size) {
  char *value = 0;
  **v = 0;
  if ((value = getenv(varname))) {
    char *pp = *p;
    while (pp - buffer < size && *value)
      *pp++ = *value++;
    *p = pp;
  } else {
    fprintf(stderr,
            "kickstart[%d]: %s[%d]: "
            "ERROR: Variable $%s does not exist\n",
            getpid(),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/"
            "src/tools/pegasus-kickstart/parse.c",
            95, varname);
    exit(1);
  }
  *v = varname;
}


x86 assembly (clang, -O0):
<resolve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1201 <resolve+0xc1>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rax,%rcx
xor    %eax,%eax
cmp    -0x28(%rbp),%rcx
mov    %al,-0x39(%rbp)
jae    11ba <resolve+0x7a>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11ca <resolve+0x8a>
jmp    11f1 <resolve+0xb1>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%cl
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
mov    %cl,(%rax)
jmp    1190 <resolve+0x50>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1240 <resolve+0x100>
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x40(%rbp),%edi
mov    %eax,%edx
mov    -0x10(%rbp),%r9
lea    0xddc(%rip),%rsi
lea    0xe10(%rip),%rcx
mov    $0x5f,%r8d
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resolve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbp
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rdi),%rax
movb   $0x0,(%rax)
mov    %rsi,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b0 <resolve+0x70>
mov    (%r15),%rcx
mov    %rcx,%rdx
sub    %r13,%rdx
cmp    %rbp,%rdx
jae    119a <resolve+0x5a>
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ebx
test   %bl,%bl
je     119a <resolve+0x5a>
add    $0x1,%rax
mov    %bl,(%rcx)
add    $0x1,%rcx
add    $0x1,%rdx
cmp    %rbp,%rdx
jb     1180 <resolve+0x40>
mov    %rcx,(%r15)
mov    %r14,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e29(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe39(%rip),%rsi
lea    0xe6d(%rip),%rcx
mov    %ebx,%edi
mov    %eax,%edx
mov    $0x5f,%r8d
mov    %r14,%r9
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"kickstart[%d]: %s[%d]: ERROR: Variable $%s does not exist\0A\00"
@.str.1 = [164 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/src/tools/pegasus-kickstart/parse.c\00"
define void @resolve(i8** %0, i8* %1, i8** %2, i8* %3, i64 %4) {
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
store i8** %0, i8*** %6
store i8* %1, i8** %7
store i8** %2, i8*** %8
store i8* %3, i8** %9
store i64 %4, i64* %10
store i8* null, i8** %11
%13 = load i8**, i8*** %6
%14 = load i8*, i8** %13
store i8 0, i8* %14
%15 = load i8*, i8** %7
%16 = call i8* @getenv(i8* %15)
store i8* %16, i8** %11
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %45
18: ; preds = %5
%19 = load i8**, i8*** %8
%20 = load i8*, i8** %19
store i8* %20, i8** %12
br label %21
21: ; preds = %36, %18
%22 = load i8*, i8** %12
%23 = load i8*, i8** %9
%24 = ptrtoint i8* %22 to i64
%25 = ptrtoint i8* %23 to i64
%26 = sub i64 %24, %25
%27 = load i64, i64* %10
%28 = icmp ult i64 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %21
%30 = load i8*, i8** %11
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %29, %21
%35 = phi i1 [ false, %21 ], [ %33, %29 ]
br i1 %35, label %36, label %42
36: ; preds = %34
%37 = load i8*, i8** %11
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %11
%39 = load i8, i8* %37
%40 = load i8*, i8** %12
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %12
store i8 %39, i8* %40
br label %21
42: ; preds = %34
%43 = load i8*, i8** %12
%44 = load i8**, i8*** %8
store i8* %43, i8** %44
br label %51
45: ; preds = %5
%46 = load i32, i32* @stderr
%47 = call i32 (...) @getpid()
%48 = load i8*, i8** %7
%49 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %47, i8* getelementptr inbounds ([164 x i8], [164 x i8]* @.str.1, i64 0, i64 0), i32 95, i8* %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %42
%52 = load i8*, i8** %7
%53 = load i8**, i8*** %6
store i8* %52, i8** %53
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"kickstart[%d]: %s[%d]: ERROR: Variable $%s does not exist\0A\00"
@.str.1 = [164 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pegasus-isi/pegasus/refs/heads/master/src/tools/pegasus-kickstart/parse.c\00"
define void @resolve(i8** nocapture %0, i8* %1, i8** nocapture %2, i8* %3, i64 %4) {
%6 = load i8*, i8** %0
store i8 0, i8* %6
%7 = tail call i8* @getenv(i8* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %28, label %9
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = ptrtoint i8* %3 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %12, %11
%14 = icmp ult i64 %13, %4
br i1 %14, label %15, label %26
15: ; preds = %9, %20
%16 = phi i8* [ %22, %20 ], [ %10, %9 ]
%17 = phi i8* [ %21, %20 ], [ %7, %9 ]
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %15
%21 = getelementptr inbounds i8, i8* %17, i64 1
%22 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %18, i8* %16
%23 = ptrtoint i8* %22 to i64
%24 = sub i64 %23, %11
%25 = icmp ult i64 %24, %4
br i1 %25, label %15, label %26
26: ; preds = %15, %20, %9
%27 = phi i8* [ %10, %9 ], [ %22, %20 ], [ %16, %15 ]
store i8* %27, i8** %2
store i8* %1, i8** %0
ret void
28: ; preds = %5
%29 = load i32, i32* @stderr
%30 = tail call i32 (...) @getpid()
%31 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %30, i8* getelementptr inbounds ([164 x i8], [164 x i8]* @.str.1, i64 0, i64 0), i32 95, i8* %1)
%32 = tail call i32 @exit(i32 1)
unreachable
}