#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 */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ hexdigest(char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *, char *);
char *urlencode(char *);
int main(int argc, char *argv[]) {
  if (1) {
    char script[] = "function(a){ pizza }";
    char *x = urlencode(script);
    printf("Encoded result: '%s'\n", x);
    char hebrew[] = "[סֶאבױ]";
    char *y = urlencode(hebrew);
    printf("Encoded result: '%s'\n", y);
    free(x);
    free(y);
  }
  if (1) {
    char md5_result[33] = {0};
    unsigned char md5_binary[16] = {94,  182, 59, 187, 224, 30, 238, 208,
                                    147, 203, 34, 187, 143, 90, 205, 195};
    hexdigest(md5_result, md5_binary, 16);
    printf("MD5 hexdigest: %s\n", md5_result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xe86(%rip),%al
mov    %al,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
call   1070 <urlencode@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
mov    0xe76(%rip),%rax
mov    %rax,-0x45(%rbp)
mov    0xe74(%rip),%eax
mov    %eax,-0x3d(%rbp)
mov    0xe6f(%rip),%al
mov    %al,-0x39(%rbp)
lea    -0x45(%rbp),%rdi
call   1070 <urlencode@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1060 <memset@plt>
mov    0xe3f(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe39(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x10,%edx
call   1030 <hexdigest@plt>
lea    -0x80(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x7d20617a7a6970,%rax
mov    %rax,0x1d(%rsp)
lea    0x10(%rsp),%rdi
call   1060 <urlencode@plt>
mov    %rax,%r15
lea    0xe9d(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
movabs $0x5db1d791d790d7,%rax
mov    %rax,0x5(%rsp)
movabs $0xd790d7b6d6a1d75b,%rax
d7 90 d7
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1060 <urlencode@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x30(%rsp)
movaps 0xe71(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1030 <hexdigest@plt>
lea    0xe39(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.script = [21 x i8] c"function(a){ pizza }\00"
@.str = [22 x i8] c"Encoded result: '%s'\0A\00"
@__const.main.hebrew = [13 x i8] c"[\D7\A1\D6\B6\D7\90\D7\91\D7\B1]\00"
@__const.main.md5_binary = [16 x i8] c"^\B6;\BB\E0\1E\EE\D0\93\CB\22\BB\8FZ\CD\C3"
@.str.1 = [19 x i8] c"MD5 hexdigest: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [21 x i8]
%7 = alloca i8*
%8 = alloca [13 x i8]
%9 = alloca i8*
%10 = alloca [33 x i8]
%11 = alloca [16 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [21 x i8]* %6 to i8*
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%14 = call i8* @urlencode(i8* %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = bitcast [13 x i8]* %8 to i8*
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%19 = call i8* @urlencode(i8* %18)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %7
%23 = call i32 @free(i8* %22)
%24 = load i8*, i8** %9
%25 = call i32 @free(i8* %24)
%26 = bitcast [33 x i8]* %10 to i8*
%27 = bitcast [16 x i8]* %11 to i8*
%28 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%30 = call i32 @hexdigest(i8* %28, i8* %29, i32 16)
%31 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@__const.main.script = [21 x i8] c"function(a){ pizza }\00"
@.str = [22 x i8] c"Encoded result: '%s'\0A\00"
@__const.main.hebrew = [13 x i8] c"[\D7\A1\D6\B6\D7\90\D7\91\D7\B1]\00"
@__const.main.md5_binary = [16 x i8] c"^\B6;\BB\E0\1E\EE\D0\93\CB\22\BB\8FZ\CD\C3"
@.str.1 = [19 x i8] c"MD5 hexdigest: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [21 x i8]
%4 = alloca [13 x i8]
%5 = alloca [33 x i8]
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%8 = call i8* @urlencode(i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%11 = call i8* @urlencode(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @free(i8* %8)
%14 = call i32 @free(i8* %11)
%15 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%17 = call i32 @hexdigest(i8* %15, i8* %16, i32 16)
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %15)
ret i32 0
}