#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 */
struct string {
  int dummy;
};
struct dict {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ dict_set(struct dict *, struct string *, struct string *);
char *strchr(char const *, char);
int /*<<< orphan*/ string_destroy(struct string *);
struct string *string_init(char const *);
struct string *string_init_data(char const *, size_t);
void add_variable_from_environment(struct dict *macros, const char *str) {
  const char *at = strchr(str, '=');
  struct string *name;
  struct string *value;
  assert(at != NULL);
  name = string_init_data(str, (size_t)(at - str));
  value = string_init(at + 1);
  dict_set(macros, name, value);
  string_destroy(value);
  string_destroy(name);
}


x86 assembly (clang, -O0):
<add_variable_from_environment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rax
sub    %rax,%rsi
call   1080 <string_init_data@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1030 <string_init@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <dict_set@plt>
mov    -0x28(%rbp),%rdi
call   1040 <string_destroy@plt>
mov    -0x20(%rbp),%rdi
call   1040 <string_destroy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_variable_from_environment>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    %rbx,%rsi
sub    %r15,%rsi
mov    %r15,%rdi
call   1080 <string_init_data@plt>
mov    %rax,%r15
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <string_init@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1070 <dict_set@plt>
mov    %rbx,%rdi
call   1040 <string_destroy@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <string_destroy@plt>

LLVM IR (-O0):
%struct.dict = type { i32 }
%struct.string = type { i32 }
define void @add_variable_from_environment(%struct.dict* %0, i8* %1) {
%3 = alloca %struct.dict*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.string*
%7 = alloca %struct.string*
store %struct.dict* %0, %struct.dict** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @strchr(i8* %8, i8 signext 61)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = load i8*, i8** %4
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = call %struct.string* @string_init_data(i8* %14, i64 %19)
store %struct.string* %20, %struct.string** %6
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call %struct.string* @string_init(i8* %22)
store %struct.string* %23, %struct.string** %7
%24 = load %struct.dict*, %struct.dict** %3
%25 = load %struct.string*, %struct.string** %6
%26 = load %struct.string*, %struct.string** %7
%27 = call i32 @dict_set(%struct.dict* %24, %struct.string* %25, %struct.string* %26)
%28 = load %struct.string*, %struct.string** %7
%29 = call i32 @string_destroy(%struct.string* %28)
%30 = load %struct.string*, %struct.string** %6
%31 = call i32 @string_destroy(%struct.string* %30)
ret void
}

LLVM IR (-O2):
%struct.dict = type { i32 }
%struct.string = type { i32 }
define void @add_variable_from_environment(%struct.dict* %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 61)
%4 = icmp ne i8* %3, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = ptrtoint i8* %3 to i64
%8 = ptrtoint i8* %1 to i64
%9 = sub i64 %7, %8
%10 = tail call %struct.string* @string_init_data(i8* %1, i64 %9)
%11 = getelementptr inbounds i8, i8* %3, i64 1
%12 = tail call %struct.string* @string_init(i8* %11)
%13 = tail call i32 @dict_set(%struct.dict* %0, %struct.string* %10, %struct.string* %12)
%14 = tail call i32 @string_destroy(%struct.string* %12)
%15 = tail call i32 @string_destroy(%struct.string* %10)
ret void
}