#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 */
typedef char *strtok_r;

/* Variables and functions */
int /*<<< orphan*/ crash();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ setenv(char *, char *, int);
void handleEnv(char **saveptr) {
  char *var, *val;
  do {
    (var) = (strtok_r)(NULL, " ", saveptr);
    if ((var) == (NULL)) {
      perror("strtok_r"
             "(NULL, \" \", saveptr)");
      crash();
    }
  } while (0);
  do {
    (val) = (strtok_r)(NULL, "\n", saveptr);
    if ((val) == (NULL)) {
      perror("strtok_r"
             "(NULL, \"\\n\", saveptr)");
      crash();
    }
  } while (0);
  setenv(var, val, 1);
}


x86 assembly (clang, -O0):
<handleEnv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1162 <handleEnv+0x32>
lea    0xeac(%rip),%rdi
call   1050 <perror@plt>
mov    $0x0,%al
call   1030 <crash@plt>
jmp    1167 <handleEnv+0x37>
jmp    116c <handleEnv+0x3c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1192 <handleEnv+0x62>
lea    0xe9b(%rip),%rdi
call   1050 <perror@plt>
mov    $0x0,%al
call   1030 <crash@plt>
jmp    1197 <handleEnv+0x67>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleEnv>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     114a <handleEnv+0x1a>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
pop    %rbx
jmp    1040 <setenv@plt>
lea    0xeaf(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
call   1030 <crash@plt>
lea    0xeb9(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
call   1030 <crash@plt>
jmp    1139 <handleEnv+0x9>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [29 x i8] c"strtok_r(NULL, \22 \22, saveptr)\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [30 x i8] c"strtok_r(NULL, \22\\n\22, saveptr)\00"
define void @handleEnv(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8*
store i8** %0, i8*** %2
br label %5
5: ; preds = %1
%6 = load i8**, i8*** %2
%7 = bitcast i8** %6 to i8*
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @crash()
br label %13
13: ; preds = %10, %5
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
%16 = load i8**, i8*** %2
%17 = bitcast i8** %16 to i8*
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (...) @crash()
br label %23
23: ; preds = %20, %15
br label %24
24: ; preds = %23
%25 = load i8*, i8** %3
%26 = load i8*, i8** %4
%27 = call i32 @setenv(i8* %25, i8* %26, i32 1)
ret void
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"strtok_r(NULL, \22 \22, saveptr)\00"
@.str.3 = [30 x i8] c"strtok_r(NULL, \22\\n\22, saveptr)\00"
define void @handleEnv(i8** %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (...) @crash()
%6 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 (...) @crash()
br label %8
8: ; preds = %1, %3
%9 = bitcast i8** %0 to i8*
%10 = tail call i32 @setenv(i8* %9, i8* %9, i32 1)
ret void
}