#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*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *url_encode(char *);
int test_url_encode(char *url, char *ref_url) {
  char *res_url;
  int ret;
  res_url = url_encode(url);
  if (strcmp(ref_url, res_url)) {
    fprintf(stderr, "FAILURE: url_encode(%s) returns %s instead of %s\n", url,
            res_url, ref_url);
    ret = 0;
  } else {
    ret = 1;
  }
  free(res_url);
  return ret;
}


x86 assembly (clang, -O0):
<test_url_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <url_encode@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11a1 <test_url_encode+0x61>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe70(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11a8 <test_url_encode+0x68>
movl   $0x1,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_url_encode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <url_encode@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1187 <test_url_encode+0x47>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1050 <fprintf@plt>
xor    %ebp,%ebp
jmp    118c <test_url_encode+0x4c>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"FAILURE: url_encode(%s) returns %s instead of %s\0A\00"
define i32 @test_url_encode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @url_encode(i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i64 @strcmp(i8* %9, i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = load i8*, i8** %5
%17 = load i8*, i8** %4
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16, i8* %17)
store i32 0, i32* %6
br label %20
19: ; preds = %2
store i32 1, i32* %6
br label %20
20: ; preds = %19, %13
%21 = load i8*, i8** %5
%22 = call i32 @free(i8* %21)
%23 = load i32, i32* %6
ret i32 %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"FAILURE: url_encode(%s) returns %s instead of %s\0A\00"
define i32 @test_url_encode(i8* %0, i8* %1) {
%3 = tail call i8* @url_encode(i8* %0)
%4 = tail call i64 @strcmp(i8* %1, i8* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %3, i8* %1)
br label %9
9: ; preds = %2, %6
%10 = phi i32 [ 0, %6 ], [ 1, %2 ]
%11 = tail call i32 @free(i8* %3)
ret i32 %10
}