#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ putenv(char *);
scalar_t__ strdup(char *);
char *strstr(char *, char *);
int main(int argc, char **argv, char *envp[]) {
  char **env;
  char *this_env;
  char *v;
  for (env = envp; *env != 0; env++) {
    this_env = (char *)strdup(*env);
    v = strstr(this_env, "=");
    if (v != NULL) {
      *v = '\0';
      v += 1;
      printf("%s=%s\n", this_env, v);
    }
    if (this_env != NULL) {
      free(this_env);
    }
  }
  putenv("SomeVariable=SomeValue");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1200 <main+0xb0>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11d6 <main+0x86>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     11ea <main+0x9a>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    11ef <main+0x9f>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1172 <main+0x22>
lea    0xe02(%rip),%rdi
call   1050 <putenv@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    (%rdx),%rdi
test   %rdi,%rdi
je     11ba <main+0x6a>
mov    %rdx,%rbx
add    $0x8,%rbx
lea    0xe95(%rip),%r14
jmp    117c <main+0x2c>
nopl   (%rax)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     11ba <main+0x6a>
call   1070 <strdup@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ab <main+0x5b>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
test   %r15,%r15
je     1170 <main+0x20>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    1170 <main+0x20>
lea    0xe46(%rip),%rdi
call   1060 <putenv@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@.str.1 = [7 x i8] c"%s=%s\0A\00"
@.str.2 = [23 x i8] c"SomeVariable=SomeValue\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i8**, i8*** %7
store i8** %11, i8*** %8
br label %12
12: ; preds = %39, %3
%13 = load i8**, i8*** %8
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %42
16: ; preds = %12
%17 = load i8**, i8*** %8
%18 = load i8*, i8** %17
%19 = call i64 @strdup(i8* %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = call i8* @strstr(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %10
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %32
25: ; preds = %16
%26 = load i8*, i8** %10
store i8 0, i8* %26
%27 = load i8*, i8** %10
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %10
%29 = load i8*, i8** %9
%30 = load i8*, i8** %10
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
br label %32
32: ; preds = %25, %16
%33 = load i8*, i8** %9
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %9
%37 = call i32 @free(i8* %36)
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38
%40 = load i8**, i8*** %8
%41 = getelementptr inbounds i8*, i8** %40, i32 1
store i8** %41, i8*** %8
br label %12
42: ; preds = %12
%43 = call i32 @putenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%s=%s\0A\00"
@.str.2 = [23 x i8] c"SomeVariable=SomeValue\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture %2) {
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %24, label %6
6: ; preds = %3, %20
%7 = phi i8* [ %22, %20 ], [ %4, %3 ]
%8 = phi i8** [ %21, %20 ], [ %2, %3 ]
%9 = tail call i64 @strdup(i8* %7)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i8* @strchr(i8* dereferenceable(1) %10, i32 61)
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %6
store i8 0, i8* %11
%14 = getelementptr inbounds i8, i8* %11, i64 1
%15 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %14)
br label %16
16: ; preds = %13, %6
%17 = icmp eq i64 %9, 0
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = tail call i32 @free(i8* %10)
br label %20
20: ; preds = %16, %18
%21 = getelementptr inbounds i8*, i8** %8, i64 1
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %6
24: ; preds = %20, %3
%25 = tail call i32 @putenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}