#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 ish_shell_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ setenv(char *, char *, int);
char *strchr(char *, char);
void ish_builtin_export(struct ish_shell_t *shell __attribute__((unused)),
                        char **args) {
  for (int i = 1; args[i]; ++i) {
    char *eq = strchr(args[i], '=');
    if (!eq) {
      continue;
    }
    *eq = '\0';
    setenv(args[i], eq + 1, 1);
  }
}


x86 assembly (clang, -O0):
<ish_builtin_export>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a7 <ish_builtin_export+0x87>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1174 <ish_builtin_export+0x54>
jmp    1199 <ish_builtin_export+0x79>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <ish_builtin_export+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ish_builtin_export>:
push   %rbx
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1175 <ish_builtin_export+0x55>
mov    %rsi,%rbx
add    $0x10,%rbx
jmp    114c <ish_builtin_export+0x2c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1175 <ish_builtin_export+0x55>
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1140 <ish_builtin_export+0x20>
movb   $0x0,(%rax)
mov    -0x8(%rbx),%rdi
add    $0x1,%rax
mov    %rax,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
jmp    1140 <ish_builtin_export+0x20>
pop    %rbx
ret

LLVM IR (-O0):
%struct.ish_shell_t = type { i32 }
define void @ish_builtin_export(%struct.ish_shell_t* %0, i8** %1) {
%3 = alloca %struct.ish_shell_t*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
store %struct.ish_shell_t* %0, %struct.ish_shell_t** %3
store i8** %1, i8*** %4
store i32 1, i32* %5
br label %7
7: ; preds = %34, %2
%8 = load i8**, i8*** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %37
14: ; preds = %7
%15 = load i8**, i8*** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i8* @strchr(i8* %19, i8 signext 61)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %14
br label %34
24: ; preds = %14
%25 = load i8*, i8** %6
store i8 0, i8* %25
%26 = load i8**, i8*** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i32 @setenv(i8* %30, i8* %32, i32 1)
br label %34
34: ; preds = %24, %23
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %7
37: ; preds = %7
ret void
}

LLVM IR (-O2):
%struct.ish_shell_t = type { i32 }
define void @ish_builtin_export(%struct.ish_shell_t* nocapture readnone %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %17, %2
ret void
7: ; preds = %2, %17
%8 = phi i64 [ %18, %17 ], [ 1, %2 ]
%9 = phi i8* [ %20, %17 ], [ %4, %2 ]
%10 = phi i8** [ %19, %17 ], [ %3, %2 ]
%11 = tail call i8* @strchr(i8* %9, i8 signext 61)
%12 = icmp eq i8* %11, null
br i1 %12, label %17, label %13
13: ; preds = %7
store i8 0, i8* %11
%14 = load i8*, i8** %10
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = tail call i32 @setenv(i8* %14, i8* %15, i32 1)
br label %17
17: ; preds = %7, %13
%18 = add nuw i64 %8, 1
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %6, label %7
}