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

/* Variables and functions */
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int system(char *);
int GET_FILE(char *addr) {
  char com[5012];
  printf("Changing Directory...\n");
  chdir("Downloads");
  printf("DOWNLOADING!!! DO NOT HALT THE PROGRAM NOW!\n");
  snprintf(com, sizeof(com), "wget %s", addr);
  if (system(com) == -1) {
    printf("Error!\n");
  } else {
    printf("Download Successful! Check the Downloads Directory!\n");
  }
}


x86 assembly (clang, -O0):
<GET_FILE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13b0,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <chdir@plt>
lea    0xeb3(%rip),%rdi
call   1050 <printf@plt>
lea    -0x13b0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1394,%esi
lea    0xec4(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x13b0(%rbp),%rdi
call   1040 <system@plt>
cmp    $0xffffffff,%eax
jne    11b5 <GET_FILE+0x75>
lea    0xeab(%rip),%rdi
call   1050 <printf@plt>
jmp    11c1 <GET_FILE+0x81>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x13b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GET_FILE>:
push   %r14
push   %rbx
sub    $0x1398,%rsp
mov    %rdi,%r14
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdi
call   1040 <chdir@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1394,%esi
mov    %r14,%rcx
call   1060 <snprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
cmp    $0xffffffff,%eax
lea    0xeeb(%rip),%rax
lea    0xeb0(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0x1398,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Changing Directory...\0A\00"
@.str.1 = [10 x i8] c"Downloads\00"
@.str.2 = [45 x i8] c"DOWNLOADING!!! DO NOT HALT THE PROGRAM NOW!\0A\00"
@.str.3 = [8 x i8] c"wget %s\00"
@.str.4 = [8 x i8] c"Error!\0A\00"
@.str.5 = [53 x i8] c"Download Successful! Check the Downloads Directory!\0A\00"
define i32 @GET_FILE(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [5012 x i8]
store i8* %0, i8** %3
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @chdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [5012 x i8], [5012 x i8]* %4, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = call i32 @snprintf(i8* %8, i32 5012, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [5012 x i8], [5012 x i8]* %4, i64 0, i64 0
%12 = call i32 @system(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %18
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"Downloads\00"
@.str.3 = [8 x i8] c"wget %s\00"
@str = [22 x i8] c"Changing Directory...\00"
@str.6 = [44 x i8] c"DOWNLOADING!!! DO NOT HALT THE PROGRAM NOW!\00"
@str.7 = [52 x i8] c"Download Successful! Check the Downloads Directory!\00"
@str.8 = [7 x i8] c"Error!\00"
define i32 @GET_FILE(i8* %0) {
%2 = alloca [5012 x i8]
%3 = getelementptr inbounds [5012 x i8], [5012 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @chdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0))
%7 = call i32 @snprintf(i8* %3, i32 5012, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%8 = call i32 @system(i8* %3)
%9 = icmp eq i32 %8, -1
%10 = select i1 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @str.7, i64 0, i64 0)
%11 = call i32 @puts(i8* dereferenceable(1) %10)
ret i32 undef
}