#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 ecma_encode_uri_component(char **, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *dest;
  int status = 0;
  if (argc > 1) {
    size_t count = 0;
    while (argc > ++count) {
      status |= ecma_encode_uri_component(&dest, argv[count]);
      if (status != 0) {
        fprintf(stderr, "%s: error: %d: %s: \n", "encode-uri-component", status,
                argv[count]);
        return status;
      }
      printf("%s\n", dest);
    }
  } else {
    fprintf(stderr, "%s string...\n", "encode-uri-component");
    return 1;
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11ef <main+0xbf>
movq   $0x0,-0x28(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmp    %rcx,%rax
jbe    11ea <main+0xba>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0x18(%rbp),%rdi
call   1050 <ecma_encode_uri_component@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d5 <main+0xa5>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rdx
mov    (%rax,%rdx,8),%r8
lea    0xe44(%rip),%rsi
lea    0xe52(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121f <main+0xef>
mov    -0x18(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
jmp    115f <main+0x2f>
jmp    1219 <main+0xe9>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
lea    0xe0f(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121f <main+0xef>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1189 <main+0x59>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%ebx
mov    %rsp,%r14
lea    0xed5(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbx,8),%rsi
mov    %r14,%rdi
call   1050 <ecma_encode_uri_component@plt>
test   %eax,%eax
jne    11ae <main+0x7e>
mov    (%rsp),%rsi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <main+0x30>
xor    %ebp,%ebp
jmp    11d4 <main+0xa4>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
lea    0xe75(%rip),%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebp
jmp    11d4 <main+0xa4>
mov    %eax,%ebp
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%rbx,8),%r8
lea    0xe3c(%rip),%rsi
lea    0xe4a(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"%s: error: %d: %s: \0A\00"
@.str.1 = [21 x i8] c"encode-uri-component\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [14 x i8] c"%s string...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %41
11: ; preds = %2
store i64 0, i64* %8
br label %12
12: ; preds = %37, %11
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = load i64, i64* %8
%16 = add i64 %15, 1
store i64 %16, i64* %8
%17 = icmp ugt i64 %14, %16
br i1 %17, label %18, label %40
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = load i64, i64* %8
%21 = getelementptr inbounds i8*, i8** %19, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @ecma_encode_uri_component(i8** %6, i8* %22)
%24 = load i32, i32* %7
%25 = or i32 %24, %23
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %18
%29 = load i32, i32* @stderr
%30 = load i32, i32* %7
%31 = load i8**, i8*** %5
%32 = load i64, i64* %8
%33 = getelementptr inbounds i8*, i8** %31, i64 %32
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %34)
%36 = load i32, i32* %7
store i32 %36, i32* %3
br label %46
37: ; preds = %18
%38 = load i8*, i8** %6
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %12
40: ; preds = %12
br label %44
41: ; preds = %2
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %46
44: ; preds = %40
%45 = load i32, i32* %7
store i32 %45, i32* %3
br label %46
46: ; preds = %44, %41, %28
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"%s: error: %d: %s: \0A\00"
@.str.1 = [21 x i8] c"encode-uri-component\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [14 x i8] c"%s string...\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %19
%9 = phi i64 [ %22, %19 ], [ 1, %6 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = call i32 @ecma_encode_uri_component(i8** %3, i8* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %8
%15 = getelementptr inbounds i8*, i8** %1, i64 %9
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %15
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %17)
br label %27
19: ; preds = %8
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = add nuw i64 %9, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %27, label %8
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %19, %14, %24
%28 = phi i32 [ 1, %24 ], [ %12, %14 ], [ 0, %19 ]
ret i32 %28
}