#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int main(int argc, char **argv) {
  char buf[1024];
  char *newnam, *oldnam, *oldval, *p;
  while (fgets(buf, sizeof(buf), stdin)) {
    p = strchr(buf, '\n');
    if (p)
      *p = '\0';
    newnam = buf;
    oldnam = strchr(buf, '=');
    if (!oldnam)
      continue;
    *oldnam = '\0';
    oldnam++;
    oldval = getenv(oldnam);
    if (oldval) {
      printf("%s=\"", newnam);
      for (p = oldval; (*p); p++) {
        if (*p == '"')
          printf("\\\"");
        else
          printf("%c", *p);
      }
      printf("\"\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12c3 <main+0x183>
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
je     11ad <main+0x6d>
mov    -0x430(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    11e6 <main+0xa6>
jmp    1159 <main+0x19>
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x420(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     12be <main+0x17e>
mov    -0x418(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x428(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rax
cmpb   $0x0,(%rax)
je     12b0 <main+0x170>
mov    -0x430(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    127c <main+0x13c>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1294 <main+0x154>
mov    -0x430(%rbp),%rax
movsbl (%rax),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1299 <main+0x159>
mov    -0x430(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
jmp    1246 <main+0x106>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    0x2e70(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     124a <main+0xea>
mov    %rsp,%r15
lea    0xe65(%rip),%r14
lea    0xe63(%rip),%r13
lea    0xe5a(%rip),%r12
jmp    11cd <main+0x6d>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <puts@plt>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    $0x400,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     124a <main+0xea>
mov    %r15,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11e2 <main+0x82>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11b8 <main+0x58>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b8 <main+0x58>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    122e <main+0xce>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
movsbl (%rbx),%edi
cmp    $0x22,%edi
je     1220 <main+0xc0>
test   %dil,%dil
je     11b0 <main+0x50>
call   1040 <putchar@plt>
add    $0x1,%rbx
jmp    122e <main+0xce>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%s=\22\00"
@.str.1 = [3 x i8] c"\\\22\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %11
11: ; preds = %64, %29, %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %12, i32 1024, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %65
16: ; preds = %11
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i8* @strchr(i8* %17, i8 signext 10)
store i8* %18, i8** %10
%19 = load i8*, i8** %10
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i8*, i8** %10
store i8 0, i8* %22
br label %23
23: ; preds = %21, %16
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
store i8* %24, i8** %7
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i8* @strchr(i8* %25, i8 signext 61)
store i8* %26, i8** %8
%27 = load i8*, i8** %8
%28 = icmp ne i8* %27, null
br i1 %28, label %30, label %29
29: ; preds = %23
br label %11
30: ; preds = %23
%31 = load i8*, i8** %8
store i8 0, i8* %31
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %8
%34 = load i8*, i8** %8
%35 = call i8* @getenv(i8* %34)
store i8* %35, i8** %9
%36 = load i8*, i8** %9
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %64
38: ; preds = %30
%39 = load i8*, i8** %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %9
store i8* %41, i8** %10
br label %42
42: ; preds = %59, %38
%43 = load i8*, i8** %10
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %62
46: ; preds = %42
%47 = load i8*, i8** %10
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 34
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %58
53: ; preds = %46
%54 = load i8*, i8** %10
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %53, %51
br label %59
59: ; preds = %58
%60 = load i8*, i8** %10
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %10
br label %42
62: ; preds = %42
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %62, %30
br label %11
65: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%s=\22\00"
@.str.1 = [3 x i8] c"\\\22\00"
@str = [2 x i8] c"\22\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 1024, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %37, label %8
8: ; preds = %2, %33
%9 = call i8* @strchr(i8* %4, i8 signext 10)
%10 = icmp eq i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %8
store i8 0, i8* %9
br label %12
12: ; preds = %11, %8
%13 = call i8* @strchr(i8* %4, i8 signext 61)
%14 = icmp eq i8* %13, null
br i1 %14, label %33, label %15
15: ; preds = %12
store i8 0, i8* %13
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = call i8* @getenv(i8* %16)
%18 = icmp eq i8* %17, null
br i1 %18, label %33, label %19
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %21
21: ; preds = %29, %19
%22 = phi i8* [ %17, %19 ], [ %30, %29 ]
%23 = load i8, i8* %22
switch i8 %23, label %26 [
i8 0, label %31
i8 34, label %24
]
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
26: ; preds = %21
%27 = sext i8 %23 to i32
%28 = call i32 @putchar(i32 %27)
br label %29
29: ; preds = %24, %26
%30 = getelementptr inbounds i8, i8* %22, i64 1
br label %21
31: ; preds = %21
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %15, %31, %12
%34 = load i32, i32* @stdin
%35 = call i64 @fgets(i8* %4, i32 1024, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %8
37: ; preds = %33, %2
ret i32 0
}