#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*/ snprintf(char *, int, char *, char);
int strlen(char *);
void urlobfuscator(char *url, char *obf) {
  int i;
  for (i = 0; i < (int)strlen(url); i++)
    snprintf(obf + strlen(obf), sizeof obf, "%02X", url[i]);
  obf[i * 2] = 0;
}


x86 assembly (clang, -O0):
<urlobfuscator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1198 <urlobfuscator+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    $0x8,%esi
lea    0xe7f(%rip),%rdx
movsbl (%rax,%rcx,1),%ecx
call   1040 <snprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <urlobfuscator+0x17>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<urlobfuscator>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
xor    %r13d,%r13d
test   %eax,%eax
jle    1187 <urlobfuscator+0x67>
lea    0xebe(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
movsbl (%r12,%rbx,1),%ecx
mov    $0x8,%esi
mov    %r15,%rdx
call   1040 <snprintf@plt>
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
add    $0x2,%r13
cmp    %rax,%rbx
jl     1150 <urlobfuscator+0x30>
movb   $0x0,(%r14,%r13,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02X\00"
define void @urlobfuscator(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %23, %2
%7 = load i32, i32* %5
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %26
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @snprintf(i8* %16, i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %21)
br label %23
23: ; preds = %11
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %6
26: ; preds = %6
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = mul nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 0, i8* %31
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @urlobfuscator(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2, %5
%6 = phi i64 [ %13, %5 ], [ 0, %2 ]
%7 = tail call i32 @strlen(i8* %1)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = getelementptr inbounds i8, i8* %0, i64 %6
%11 = load i8, i8* %10
%12 = tail call i32 @snprintf(i8* %9, i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%13 = add nuw nsw i64 %6, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %5, label %17
17: ; preds = %5
%18 = shl nuw i64 %13, 1
%19 = and i64 %18, 4294967294
br label %20
20: ; preds = %17, %2
%21 = phi i64 [ 0, %2 ], [ %19, %17 ]
%22 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 0, i8* %22
ret void
}