#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*/ time_t;
struct chirp_client {
  int dummy;
};
typedef int /*<<< orphan*/ safeoldpath;
typedef int /*<<< orphan*/ safenewpath;
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ cctools_debug(long long, char *, char *, char *);
int /*<<< orphan*/ simple_command(struct chirp_client *, int /*<<< orphan*/,
                                  char *, char *, char *);
int /*<<< orphan*/ url_encode(char const *, char *, int);
int64_t chirp_client_symlink(struct chirp_client *c, const char *oldpath,
                             const char *newpath, time_t stoptime) {
  char safeoldpath[1024];
  char safenewpath[1024];
  url_encode(oldpath, safeoldpath, sizeof(safeoldpath));
  url_encode(newpath, safenewpath, sizeof(safenewpath));
  cctools_debug((1LL << 19), "symlink %s %s", safeoldpath, safenewpath);
  return simple_command(c, stoptime, "symlink %s %s\n", safeoldpath,
                        safenewpath);
}


x86 assembly (clang, -O0):
<chirp_client_symlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <url_encode@plt>
mov    -0x18(%rbp),%rdi
lea    -0x820(%rbp),%rsi
mov    $0x400,%edx
call   1050 <url_encode@plt>
lea    -0x420(%rbp),%rdx
lea    -0x820(%rbp),%rcx
mov    $0x80000,%edi
lea    0xe72(%rip),%rsi
call   1040 <cctools_debug@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x420(%rbp),%rcx
lea    -0x820(%rbp),%r8
lea    0xe5f(%rip),%rdx
call   1030 <simple_command@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chirp_client_symlink>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rdi,%r12
lea    0x400(%rsp),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
mov    $0x400,%edx
call   1050 <url_encode@plt>
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1050 <url_encode@plt>
lea    0xe86(%rip),%rsi
mov    $0x80000,%edi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1040 <cctools_debug@plt>
lea    0xe7d(%rip),%rdx
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15,%rcx
mov    %rbp,%r8
call   1030 <simple_command@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.chirp_client = type { i32 }
@.str = [14 x i8] c"symlink %s %s\00"
@.str.1 = [15 x i8] c"symlink %s %s\0A\00"
define i32 @chirp_client_symlink(%struct.chirp_client* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.chirp_client*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
store %struct.chirp_client* %0, %struct.chirp_client** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%13 = call i32 @url_encode(i8* %11, i8* %12, i32 1024)
%14 = load i8*, i8** %7
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%16 = call i32 @url_encode(i8* %14, i8* %15, i32 1024)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%19 = call i32 @cctools_debug(i64 524288, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = load %struct.chirp_client*, %struct.chirp_client** %5
%21 = load i32, i32* %8
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%24 = call i32 @simple_command(%struct.chirp_client* %20, i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %23)
ret i32 %24
}

LLVM IR (-O2):
%struct.chirp_client = type { i32 }
@.str = [14 x i8] c"symlink %s %s\00"
@.str.1 = [15 x i8] c"symlink %s %s\0A\00"
define i32 @chirp_client_symlink(%struct.chirp_client* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = call i32 @url_encode(i8* %1, i8* %7, i32 1024)
%10 = call i32 @url_encode(i8* %2, i8* %8, i32 1024)
%11 = call i32 @cctools_debug(i64 524288, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%12 = call i32 @simple_command(%struct.chirp_client* %0, i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %8)
ret i32 %12
}