#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 */
scalar_t__ EINVAL;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int setenv(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int internal_setenv(char *str) {
  int ret;
  char *p = strchr(str, '=');
  assert(p != NULL);
  *p = '\0';
  ret = setenv(str, p + 1, 1);
  if (errno == EINVAL)
    fprintf(stderr, "Philsh: '%s' ne doit pas contenir de caractère '='", str);
  return ret;
}


x86 assembly (clang, -O0):
<internal_setenv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
jne    11c3 <internal_setenv+0x83>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_setenv>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,%rbp
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
movb   $0x0,0x0(%rbp)
add    $0x1,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    %eax,%ebp
mov    0x2e56(%rip),%rax
mov    (%rax),%rax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%rax
jne    11a9 <internal_setenv+0x69>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str = [52 x i8] c"Philsh: '%s' ne doit pas contenir de caract\C3\A8re '='\00"
define i32 @internal_setenv(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strchr(i8* %5, i8 signext 61)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %4
store i8 0, i8* %11
%12 = load i8*, i8** %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = call i32 @setenv(i8* %12, i8* %14, i32 1)
store i32 %15, i32* %3
%16 = load i64, i64* @errno
%17 = load i64, i64* @EINVAL
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %1
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %2
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %1
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str = [52 x i8] c"Philsh: '%s' ne doit pas contenir de caract\C3\A8re '='\00"
define i32 @internal_setenv(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%3 = icmp ne i8* %2, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
store i8 0, i8* %2
%6 = getelementptr inbounds i8, i8* %2, i64 1
%7 = tail call i32 @setenv(i8* %0, i8* %6, i32 1)
%8 = load i64, i64* @errno
%9 = load i64, i64* @EINVAL
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %11, %1
ret i32 %7
}