#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*/ setenv(char const *, char *, int);
char *strchr(char *, char);
char *string_envformat(char const *);
char *string_trim(char *);
scalar_t__ strlen(char *);
int config_parse_line(char *line) {
  char *comments = strchr(line, '#');
  if (comments)
    *comments = 0;
  if (strlen(string_trim(line)) == 0)
    return 0;
  char *eq = strchr(line, '=');
  if (!eq)
    return 1;
  *eq = 0;
  const char *key = string_trim(line);
  const char *val = string_trim(eq + 1);
  char *final_val = string_envformat(val);
  setenv(key, final_val, 1);
  free(final_val);
  return 0;
}


x86 assembly (clang, -O0):
<config_parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x23,%esi
call   1070 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1190 <config_parse_line+0x30>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1080 <string_trim@plt>
mov    %rax,%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jne    11b7 <config_parse_line+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1234 <config_parse_line+0xd4>
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e0 <config_parse_line+0x80>
movl   $0x1,-0x4(%rbp)
jmp    1234 <config_parse_line+0xd4>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1080 <string_trim@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1080 <string_trim@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <string_envformat@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_parse_line>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x23,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1169 <config_parse_line+0x19>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1070 <string_trim@plt>
xor    %r14d,%r14d
cmpb   $0x0,(%rax)
je     11d3 <config_parse_line+0x83>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11cd <config_parse_line+0x7d>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1070 <string_trim@plt>
mov    %rax,%rbx
add    $0x1,%rbp
mov    %rbp,%rdi
call   1070 <string_trim@plt>
mov    %rax,%rdi
call   1050 <string_envformat@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    11d3 <config_parse_line+0x83>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @config_parse_line(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i8* @strchr(i8* %9, i8 signext 35)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load i8*, i8** %4
store i8 0, i8* %14
br label %15
15: ; preds = %13, %1
%16 = load i8*, i8** %3
%17 = call i8* @string_trim(i8* %16)
%18 = call i64 @strlen(i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 0, i32* %2
br label %41
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i8* @strchr(i8* %22, i8 signext 61)
store i8* %23, i8** %5
%24 = load i8*, i8** %5
%25 = icmp ne i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 1, i32* %2
br label %41
27: ; preds = %21
%28 = load i8*, i8** %5
store i8 0, i8* %28
%29 = load i8*, i8** %3
%30 = call i8* @string_trim(i8* %29)
store i8* %30, i8** %6
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i8* @string_trim(i8* %32)
store i8* %33, i8** %7
%34 = load i8*, i8** %7
%35 = call i8* @string_envformat(i8* %34)
store i8* %35, i8** %8
%36 = load i8*, i8** %6
%37 = load i8*, i8** %8
%38 = call i32 @setenv(i8* %36, i8* %37, i32 1)
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
store i32 0, i32* %2
br label %41
41: ; preds = %27, %26, %20
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
define i32 @config_parse_line(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 35)
%3 = icmp eq i8* %2, null
br i1 %3, label %5, label %4
4: ; preds = %1
store i8 0, i8* %2
br label %5
5: ; preds = %4, %1
%6 = tail call i8* @string_trim(i8* %0)
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %5
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%11 = icmp eq i8* %10, null
br i1 %11, label %19, label %12
12: ; preds = %9
store i8 0, i8* %10
%13 = tail call i8* @string_trim(i8* %0)
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = tail call i8* @string_trim(i8* %14)
%16 = tail call i8* @string_envformat(i8* %15)
%17 = tail call i32 @setenv(i8* %13, i8* %16, i32 1)
%18 = tail call i32 @free(i8* %16)
br label %19
19: ; preds = %12, %9, %5
%20 = phi i32 [ 0, %5 ], [ 0, %12 ], [ 1, %9 ]
ret i32 %20
}