#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 */
char *extract_substring_after_str(char *, char *);
char *extract_substring_before_str(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ remove_char(char *, char);
int /*<<< orphan*/ setenv(char *, char *, int);
char *strstr(char *, char *);
void set_macros(char *line) {
  char command[1000];
  remove_char(line, ' ');
  char substr[] = "=";
  int num = strstr(line, "=") - line;
  char *variableName = extract_substring_before_str(line, substr);
  char *variableValue = extract_substring_after_str(line, substr);
  setenv(variableName, variableValue, 1);
  free(variableName);
  free(variableValue);
}


x86 assembly (clang, -O0):
<set_macros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1040 <remove_char@plt>
mov    0xe7c(%rip),%ax
mov    %ax,-0x3f2(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <strstr@plt>
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x3f8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x3f2(%rbp),%rsi
call   1060 <extract_substring_before_str@plt>
mov    %rax,-0x400(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x3f2(%rbp),%rsi
call   1070 <extract_substring_after_str@plt>
mov    %rax,-0x408(%rbp)
mov    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%rsi
mov    $0x1,%edx
call   1050 <setenv@plt>
mov    -0x400(%rbp),%rdi
call   1030 <free@plt>
mov    -0x408(%rbp),%rdi
call   1030 <free@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_macros>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    $0x20,%esi
call   1040 <remove_char@plt>
movw   $0x3d,0xe(%rsp)
lea    0xe(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <extract_substring_before_str@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <extract_substring_after_str@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1050 <setenv@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.set_macros.substr = [2 x i8] c"=\00"
@.str = [2 x i8] c"=\00"
define void @set_macros(i8* %0) {
%2 = alloca i8*
%3 = alloca [1000 x i8]
%4 = alloca [2 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @remove_char(i8* %8, i8 signext 32)
%10 = bitcast [2 x i8]* %4 to i8*
%11 = load i8*, i8** %2
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %2
%14 = ptrtoint i8* %12 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
%17 = trunc i64 %16 to i32
store i32 %17, i32* %5
%18 = load i8*, i8** %2
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%20 = call i8* @extract_substring_before_str(i8* %18, i8* %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %2
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%23 = call i8* @extract_substring_after_str(i8* %21, i8* %22)
store i8* %23, i8** %7
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 @setenv(i8* %24, i8* %25, i32 1)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %7
%30 = call i32 @free(i8* %29)
ret void
}

LLVM IR (-O2):
define void @set_macros(i8* %0) {
%2 = alloca i16
%3 = tail call i32 @remove_char(i8* %0, i8 signext 32)
%4 = bitcast i16* %2 to i8*
store i16 61, i16* %2
%5 = call i8* @extract_substring_before_str(i8* %0, i8* %4)
%6 = call i8* @extract_substring_after_str(i8* %0, i8* %4)
%7 = call i32 @setenv(i8* %5, i8* %6, i32 1)
%8 = call i32 @free(i8* %5)
%9 = call i32 @free(i8* %6)
ret void
}