#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*/ assert(int);
int /*<<< orphan*/ getenv(char *);
int putenv(char *);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int main() {
  static char foo[] = "Hello=World";
  assert(putenv("foo=bar") != -1);
  assert(!strcmp(getenv("foo"), "bar"));
  assert(putenv("foo=baz") != -1);
  assert(!strcmp(getenv("foo"), "baz"));
  putenv(foo);
  assert(!strcmp(getenv("Hello"), "World"));
  foo[6] = 'M';
  assert(!strcmp(getenv("Hello"), "Morld"));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <putenv@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe96(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xe84(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe6e(%rip),%rdi
call   1040 <putenv@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe4e(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xe48(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0x2e5a(%rip),%rdi
call   1040 <putenv@plt>
lea    0xe22(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xe1a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movb   $0x4d,0x2e28(%rip)
lea    0xdef(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xded(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1040 <putenv@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1060 <assert@plt>
lea    0xea6(%rip),%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
lea    0xe93(%rip),%rsi
mov    %eax,%edi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe80(%rip),%rdi
call   1040 <putenv@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1030 <getenv@plt>
lea    0xe62(%rip),%rsi
mov    %eax,%edi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0x2e77(%rip),%rdi
call   1040 <putenv@plt>
lea    0xe3f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
lea    0xe36(%rip),%rsi
mov    %eax,%edi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
movb   $0x4d,0x2e47(%rip)
mov    %rbx,%rdi
call   1030 <getenv@plt>
lea    0xe12(%rip),%rsi
mov    %eax,%edi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.foo = internal global [12 x i8] c"Hello=World\00"
@.str = [8 x i8] c"foo=bar\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [4 x i8] c"bar\00"
@.str.3 = [8 x i8] c"foo=baz\00"
@.str.4 = [4 x i8] c"baz\00"
@.str.5 = [6 x i8] c"Hello\00"
@.str.6 = [6 x i8] c"World\00"
@.str.7 = [6 x i8] c"Morld\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @putenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i32 %2, -1
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = call i32 @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @strcmp(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @putenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp ne i32 %12, -1
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @strcmp(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @putenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.foo, i64 0, i64 0))
%23 = call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @strcmp(i32 %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
store i8 77, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.foo, i64 0, i64 6)
%29 = call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @strcmp(i32 %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@main.foo = internal global [12 x i8] c"Hello=World\00"
@.str = [8 x i8] c"foo=bar\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [4 x i8] c"bar\00"
@.str.3 = [8 x i8] c"foo=baz\00"
@.str.4 = [4 x i8] c"baz\00"
@.str.5 = [6 x i8] c"Hello\00"
@.str.6 = [6 x i8] c"World\00"
@.str.7 = [6 x i8] c"Morld\00"
define i32 @main() {
%1 = tail call i32 @putenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = icmp ne i32 %1, -1
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @strcmp(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @putenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp ne i32 %10, -1
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @strcmp(i32 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i32 @putenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.foo, i64 0, i64 0))
%20 = tail call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%21 = tail call i32 @strcmp(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
store i8 77, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @main.foo, i64 0, i64 6)
%25 = tail call i32 @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%26 = tail call i32 @strcmp(i32 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
ret i32 0
}