#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 */
scalar_t__ chdir(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int main(void) {
  char *destdir;
  system("copy %HOME%\\"
         "AUTO_localhost_8888_-.sct"
         " %TEMP%\\"
         "d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb"
         "\\");
  destdir = getenv("TEMP");
  if (!destdir) {
    fprintf(stderr, "TEMP isn't set\n");
    return 1;
  }
  destdir = malloc(
      strlen(getenv("TEMP")) +
      strlen(
          "\\"
          "d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb") +
      1);
  strcpy(destdir, getenv("TEMP"));
  strcat(destdir,
         "\\"
         "d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb");
  if (chdir(destdir) != 0) {
    fprintf(stderr, "couldn't change to %s\n", destdir);
    return 1;
  }
  system("copy /b "
         "AUTO_localhost_8888_-.sct"
         " +,,");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1070 <system@plt>
lea    0xecd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d9 <main+0x59>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128e <main+0x10e>
lea    0xe8f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe8c(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe4f(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1060 <chdir@plt>
cmp    $0x0,%rax
je     127b <main+0xfb>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128e <main+0x10e>
lea    0xe5b(%rip),%rdi
call   1070 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe78(%rip),%rdi
call   1070 <system@plt>
lea    0xedb(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1201 <main+0x81>
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0x42(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xeb6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
call   1060 <chdir@plt>
test   %rax,%rax
je     121f <main+0x9f>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1218 <main+0x98>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xeb7(%rip),%rdi
call   1070 <system@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [111 x i8] c"copy %HOME%\\AUTO_localhost_8888_-.sct %TEMP%\\d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb\\\00"
@.str.1 = [5 x i8] c"TEMP\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"TEMP isn't set\0A\00"
@.str.3 = [66 x i8] c"\\d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb\00"
@.str.4 = [23 x i8] c"couldn't change to %s\0A\00"
@.str.5 = [38 x i8] c"copy /b AUTO_localhost_8888_-.sct +,,\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 @system(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %31
10: ; preds = %0
%11 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i64 @strlen(i8* %11)
%13 = call i64 @strlen(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0))
%14 = add nsw i64 %12, %13
%15 = add nsw i64 %14, 1
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %2
%17 = load i8*, i8** %2
%18 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %2
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0))
%22 = load i8*, i8** %2
%23 = call i64 @chdir(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %10
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %2
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %27)
store i32 1, i32* %1
br label %31
29: ; preds = %10
%30 = call i32 @system(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %31
31: ; preds = %29, %25, %7
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [111 x i8] c"copy %HOME%\\AUTO_localhost_8888_-.sct %TEMP%\\d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb\\\00"
@.str.1 = [5 x i8] c"TEMP\00"
@stderr = global i32 0
@.str.2 = [16 x i8] c"TEMP isn't set\0A\00"
@.str.3 = [66 x i8] c"\\d9863e419fc90a7faab64952d3d71a389734f82214fb3817cb5c88be81c2f1cb\00"
@.str.4 = [23 x i8] c"couldn't change to %s\0A\00"
@.str.5 = [38 x i8] c"copy /b AUTO_localhost_8888_-.sct +,,\00"
define i32 @main() {
%1 = tail call i32 @system(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %21
7: ; preds = %0
%8 = tail call i64 @strlen(i8* %2)
%9 = add nsw i64 %8, 66
%10 = tail call i8* @malloc(i64 %9)
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @strcpy(i8* %10, i8* %11)
%13 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i64 @chdir(i8* %10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %7
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %10)
br label %21
19: ; preds = %7
%20 = tail call i32 @system(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %21
21: ; preds = %19, %16, %4
%22 = phi i32 [ 1, %16 ], [ 0, %19 ], [ 1, %4 ]
ret i32 %22
}