#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*/ chat;

/* Variables and functions */
int /*<<< orphan*/ decode(char *);
char *getenv(char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ unsetenv(char *);
int main() {
  char ch[] = "123%E6%88%91567";
  char chat[20];
  int i = 0, j = 0, n = 0;
  memset(chat, '\0', sizeof(chat));
  decode(ch);
  printf("decode: %s", ch);
  setenv("XY_KK", "zhwen许", 1);
  char *kk = getenv("XY_KK");
  printf("kk: %s \n", kk);
  unsetenv("XY_KK");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
lea    -0x20(%rbp),%rdi
call   1070 <decode@plt>
lea    -0x20(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
lea    0xe51(%rip),%rdi
lea    0xe50(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xe39(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
lea    0xe19(%rip),%rdi
call   1080 <unsetenv@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <decode@plt>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xe79(%rip),%rbx
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %rbx,%rdi
call   1030 <getenv@plt>
lea    0xe65(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <unsetenv@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.ch = [16 x i8] c"123%E6%88%91567\00"
@.str = [11 x i8] c"decode: %s\00"
@.str.1 = [6 x i8] c"XY_KK\00"
@.str.2 = [9 x i8] c"zhwen\E8\AE\B8\00"
@.str.3 = [9 x i8] c"kk: %s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %1
%8 = bitcast [16 x i8]* %2 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 20)
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%12 = call i32 @decode(i8* %11)
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @setenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 1)
%16 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = call i32 @unsetenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.ch = [16 x i8] c"123%E6%88%91567\00"
@.str = [11 x i8] c"decode: %s\00"
@.str.1 = [6 x i8] c"XY_KK\00"
@.str.2 = [9 x i8] c"zhwen\E8\AE\B8\00"
@.str.3 = [9 x i8] c"kk: %s \0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i8 signext 0, i32 20)
%6 = call i32 @decode(i8* %3)
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i32 @setenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 1)
%9 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = call i32 @unsetenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}