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

/* Variables and functions */
int /*<<< orphan*/ base64_decode(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void parse_thunder(char const *argv, char *url) {
  int p = 10;
  char src[2048], dest[1024];
  memset(src, 0, sizeof(src));
  strncpy(src, argv + p, strlen(argv) - p);
  base64_decode(src, dest);
  strncpy(url, dest + 2, strlen(dest) - 4);
  url[strlen(dest) - 4] = '\0';
}


x86 assembly (clang, -O0):
<parse_thunder>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    -0x820(%rbp),%rax
mov    %rax,-0xc48(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0xc40(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc48(%rbp),%rdi
mov    -0xc40(%rbp),%rsi
mov    %eax,%edx
sub    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x820(%rbp),%rdi
lea    -0xc20(%rbp),%rsi
call   1060 <base64_decode@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0xc38(%rbp)
lea    -0xc20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0xc30(%rbp)
lea    -0xc20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc38(%rbp),%rdi
mov    -0xc30(%rbp),%rsi
mov    %eax,%edx
sub    $0x4,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0xc28(%rbp)
lea    -0xc20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xc28(%rbp),%rax
sub    $0x4,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0xc50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_thunder>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc08,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x400(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    0xa(%rbx),%r12
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0xa(%rax),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strncpy@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <base64_decode@plt>
lea    0x2(%rsp),%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x4(%rax),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x4(%rax,%r14,1)
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @parse_thunder(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [2048 x i8]
%7 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 10, i32* %5
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 2048)
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
%19 = call i32 @strncpy(i8* %10, i8* %14, i32 %18)
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%22 = call i32 @base64_decode(i8* %20, i8* %21)
%23 = load i8*, i8** %4
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 4
%29 = call i32 @strncpy(i8* %23, i8* %25, i32 %28)
%30 = load i8*, i8** %4
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 0, i8* %35
ret void
}

LLVM IR (-O2):
define void @parse_thunder(i8* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i32 0, i32 2048)
%8 = getelementptr inbounds i8, i8* %0, i64 10
%9 = call i32 @strlen(i8* %0)
%10 = add nsw i32 %9, -10
%11 = call i32 @strncpy(i8* %5, i8* %8, i32 %10)
%12 = call i32 @base64_decode(i8* %5, i8* %6)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 2
%14 = call i32 @strlen(i8* %6)
%15 = add nsw i32 %14, -4
%16 = call i32 @strncpy(i8* %1, i8* %13, i32 %15)
%17 = call i32 @strlen(i8* %6)
%18 = add nsw i32 %17, -4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %19
store i8 0, i8* %20
ret void
}