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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ isascii(int);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void http_print(FILE *fp, const char *str) {
  int c;
  while ((c = (unsigned char)*str++) != '\0') {
    if (c == ' ')
      putc('+', fp);
    else if (c < ' ' || !isascii(c) || c == '=' || c == '&' || c == '?')
      fprintf(fp, "%%%02X", c);
    else
      putc(c, fp);
  }
}


x86 assembly (clang, -O0):
<http_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11e2 <http_print+0xb2>
cmpl   $0x20,-0x14(%rbp)
jne    117b <http_print+0x4b>
mov    -0x8(%rbp),%rsi
mov    $0x2b,%edi
call   1030 <putc@plt>
jmp    11dd <http_print+0xad>
cmpl   $0x20,-0x14(%rbp)
jl     11b4 <http_print+0x84>
mov    -0x14(%rbp),%edi
call   1050 <isascii@plt>
cmp    $0x0,%eax
je     11b4 <http_print+0x84>
cmpl   $0x3d,-0x14(%rbp)
je     11b4 <http_print+0x84>
cmpl   $0x26,-0x14(%rbp)
je     11b4 <http_print+0x84>
cmpl   $0x3f,-0x14(%rbp)
jne    11cc <http_print+0x9c>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe3e(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11d8 <http_print+0xa8>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
jmp    11dd <http_print+0xad>
jmp    1140 <http_print+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xecb(%rip),%r15
movabs $0xa000004000000000,%r12
jmp    115b <http_print+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
movzbl (%rbx),%edx
add    $0x1,%rbx
cmp    $0x20,%edx
je     1190 <http_print+0x70>
test   %dl,%dl
je     119f <http_print+0x7f>
cmp    $0x20,%dl
jl     1150 <http_print+0x30>
cmp    $0x3f,%dl
ja     117d <http_print+0x5d>
mov    %edx,%eax
bt     %rax,%r12
jb     1150 <http_print+0x30>
mov    %edx,%edi
jmp    1195 <http_print+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2b,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
jmp    115b <http_print+0x3b>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%%%02X\00"
define void @http_print(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %43, %2
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %4
%9 = load i8, i8* %7
%10 = zext i8 %9 to i32
store i32 %10, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %44
12: ; preds = %6
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32*, i32** %3
%17 = call i32 @putc(i32 43, i32* %16)
br label %43
18: ; preds = %12
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 32
br i1 %20, label %34, label %21
21: ; preds = %18
%22 = load i32, i32* %5
%23 = call i32 @isascii(i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 61
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 38
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 63
br i1 %33, label %34, label %38
34: ; preds = %31, %28, %25, %21, %18
%35 = load i32*, i32** %3
%36 = load i32, i32* %5
%37 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %42
38: ; preds = %31
%39 = load i32, i32* %5
%40 = load i32*, i32** %3
%41 = call i32 @putc(i32 %39, i32* %40)
br label %42
42: ; preds = %38, %34
br label %43
43: ; preds = %42, %15
br label %6
44: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%%%02X\00"
define void @http_print(i32* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %15, %2
%4 = phi i8* [ %1, %2 ], [ %5, %15 ]
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
switch i8 %6, label %10 [
i8 0, label %18
i8 32, label %8
]
8: ; preds = %3
%9 = tail call i32 @putc(i32 43, i32* %0)
br label %15
10: ; preds = %3
%11 = icmp slt i8 %6, 32
br i1 %11, label %13, label %12
12: ; preds = %10
switch i8 %6, label %16 [
i8 63, label %13
i8 61, label %13
i8 38, label %13
]
13: ; preds = %12, %12, %12, %10
%14 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %15
15: ; preds = %13, %16, %8
br label %3
16: ; preds = %12
%17 = tail call i32 @putc(i32 %7, i32* %0)
br label %15
18: ; preds = %3
ret void
}