#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 const *,
                           char const *, int);
int /*<<< orphan*/ perror(char *);
int setenv(char const *, char const *, int);
int /*<<< orphan*/ stderr;
int mysetenv(const char *name, const char *value, int overwrite) {
  int rc;
  if ((rc = setenv(name, value, overwrite)) != 0) {
    fprintf(stderr, "ERROR: setenv(\"%s\", \"%s\", %d): ", name, value,
            overwrite);
    perror("");
    exit(1);
  }
  return (rc);
}


x86 assembly (clang, -O0):
<mysetenv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <setenv@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     11a6 <mysetenv+0x66>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe88(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysetenv>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <setenv@plt>
test   %eax,%eax
jne    115d <mysetenv+0x1d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1040 <fprintf@plt>
lea    0xe9d(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"ERROR: setenv(\22%s\22, \22%s\22, %d): \00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @mysetenv(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 @setenv(i8* %8, i8* %9, i32 %10)
store i32 %11, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = load i32, i32* %6
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16, i32 %17)
%19 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %3
%22 = load i32, i32* %7
ret i32 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"ERROR: setenv(\22%s\22, \22%s\22, %d): \00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @mysetenv(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @setenv(i8* %0, i8* %1, i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i32 %2)
%9 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
ret i32 0
}