#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 uint32_t;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ punycode_decode(char *, int /*<<< orphan*/, int *, size_t *);
int /*<<< orphan*/ punycode_encode(int *, int, char *, size_t *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int *utf8_to_unicode(char *);
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s (-e | -d) string", argv[0]);
  }
  if (strcmp(argv[1], "-e") == 0) {
    uint32_t *test = utf8_to_unicode(argv[2]);
    for (int i = 0; test[i]; i++)
      printf("%d ", test[i]);
    puts("");
    int len = 0;
    while (test[len++])
      ;
    len--;
    printf("len: %d\n", len);
    char buf[1024];
    size_t dst_len = 1024;
    punycode_encode(test, len, buf, &dst_len);
    printf("%s\n%ld\n", buf, dst_len);
  } else if (strcmp(argv[1], "-d") == 0) {
    uint32_t test[1024];
    size_t len = 1024;
    punycode_decode(argv[2], strlen(argv[2]), test, &len);
    for (int i = 0; test[i]; i++)
      printf("%d ", test[i]);
    puts("");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11bf <main+0x3f>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe46(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12c2 <main+0x142>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <utf8_to_unicode@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     122e <main+0xae>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f5 <main+0x75>
lea    0xdf5(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1262 <main+0xe2>
jmp    1241 <main+0xc1>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movq   $0x400,-0x428(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    -0x420(%rbp),%rdx
lea    -0x428(%rbp),%rcx
call   1030 <punycode_encode@plt>
lea    -0x420(%rbp),%rsi
mov    -0x428(%rbp),%rdx
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1383 <main+0x203>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd62(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    137e <main+0x1fe>
movq   $0x400,-0x1438(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x1448(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <strlen@plt>
mov    -0x1448(%rbp),%rdi
mov    %eax,%esi
lea    -0x1430(%rbp),%rdx
lea    -0x1438(%rbp),%rcx
call   1070 <punycode_decode@plt>
movl   $0x0,-0x143c(%rbp)
movslq -0x143c(%rbp),%rax
cmpl   $0x0,-0x1430(%rbp,%rax,4)
je     1372 <main+0x1f2>
movslq -0x143c(%rbp),%rax
mov    -0x1430(%rbp,%rax,4),%esi
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x143c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x143c(%rbp)
jmp    132d <main+0x1ad>
lea    0xcb1(%rip),%rdi
call   1040 <puts@plt>
jmp    1383 <main+0x203>
mov    0x2c4e(%rip),%rax
mov    (%rax),%eax
add    $0x1450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1010,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     11ac <main+0x2c>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe59(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x8(%rbx),%rdi
lea    0xe64(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1243 <main+0xc3>
mov    0x8(%rbx),%rdi
lea    0xe63(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12d4 <main+0x154>
movq   $0x400,0x8(%rsp)
mov    0x10(%rbx),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <punycode_decode@plt>
mov    0x10(%rsp),%esi
test   %esi,%esi
je     1234 <main+0xb4>
lea    0x14(%rsp),%rbx
lea    0xe03(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%esi
add    $0x4,%rbx
test   %esi,%esi
jne    1220 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12d4 <main+0x154>
mov    0x10(%rbx),%rdi
call   10a0 <utf8_to_unicode@plt>
mov    %rax,%r14
mov    (%rax),%esi
test   %esi,%esi
je     1274 <main+0xf4>
lea    0x4(%r14),%rbx
lea    0xdbe(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%esi
add    $0x4,%rbx
test   %esi,%esi
jne    1260 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
cmpl   $0x0,(%r14,%rbx,4)
lea    0x1(%rbx),%rbx
jne    1280 <main+0x100>
add    $0xffffffff,%ebx
lea    0xd8d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movq   $0x400,0x8(%rsp)
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1040 <punycode_encode@plt>
mov    0x8(%rsp),%rdx
lea    0xd61(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s (-e | -d) string\00"
@.str.1 = [3 x i8] c"-e\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [9 x i8] c"len: %d\0A\00"
@.str.5 = [8 x i8] c"%s\0A%ld\0A\00"
@.str.6 = [3 x i8] c"-d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i64
%11 = alloca [1024 x i32]
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %16, %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %73
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32* @utf8_to_unicode(i8* %31)
store i32* %32, i32** %6
store i32 0, i32* %7
br label %33
33: ; preds = %47, %28
%34 = load i32*, i32** %6
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %33
%41 = load i32*, i32** %6
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %40
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %33
50: ; preds = %33
%51 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %8
br label %52
52: ; preds = %60, %50
%53 = load i32*, i32** %6
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds i32, i32* %53, i64 %56
%58 = load i32, i32* %57
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %52
br label %52
61: ; preds = %52
%62 = load i32, i32* %8
%63 = add nsw i32 %62, -1
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %64)
store i64 1024, i64* %10
%66 = load i32*, i32** %6
%67 = load i32, i32* %8
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%69 = call i32 @punycode_encode(i32* %66, i32 %67, i8* %68, i64* %10)
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%71 = load i64, i64* %10
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %70, i64 %71)
br label %107
73: ; preds = %22
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %106
79: ; preds = %73
store i64 1024, i64* %12
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 2
%82 = load i8*, i8** %81
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 2
%85 = load i8*, i8** %84
%86 = call i32 @strlen(i8* %85)
%87 = getelementptr inbounds [1024 x i32], [1024 x i32]* %11, i64 0, i64 0
%88 = call i32 @punycode_decode(i8* %82, i32 %86, i32* %87, i64* %12)
store i32 0, i32* %13
br label %89
89: ; preds = %101, %79
%90 = load i32, i32* %13
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [1024 x i32], [1024 x i32]* %11, i64 0, i64 %91
%93 = load i32, i32* %92
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %104
95: ; preds = %89
%96 = load i32, i32* %13
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [1024 x i32], [1024 x i32]* %11, i64 0, i64 %97
%99 = load i32, i32* %98
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %99)
br label %101
101: ; preds = %95
%102 = load i32, i32* %13
%103 = add nsw i32 %102, 1
store i32 %103, i32* %13
br label %89
104: ; preds = %89
%105 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %106
106: ; preds = %104, %73
br label %107
107: ; preds = %106, %61
%108 = load i32, i32* @EXIT_SUCCESS
ret i32 %108
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s (-e | -d) string\00"
@.str.1 = [3 x i8] c"-e\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.4 = [9 x i8] c"len: %d\0A\00"
@.str.5 = [8 x i8] c"%s\0A%ld\0A\00"
@.str.6 = [3 x i8] c"-d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca i64
%5 = alloca [1024 x i32]
%6 = alloca i64
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %8, %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %47
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @utf8_to_unicode(i8* %19)
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %25, %17
%24 = tail call i32 @putchar(i32 10)
br label %33
25: ; preds = %17, %25
%26 = phi i64 [ %29, %25 ], [ 0, %17 ]
%27 = phi i32 [ %31, %25 ], [ %21, %17 ]
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = add nuw i64 %26, 1
%30 = getelementptr inbounds i32, i32* %20, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %23, label %25
33: ; preds = %33, %23
%34 = phi i64 [ %35, %33 ], [ 0, %23 ]
%35 = add nuw i64 %34, 1
%36 = getelementptr inbounds i32, i32* %20, i64 %34
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %33
39: ; preds = %33
%40 = trunc i64 %34 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%43 = bitcast i64* %4 to i8*
store i64 1024, i64* %4
%44 = call i32 @punycode_encode(i32* %20, i32 %40, i8* %42, i64* %4)
%45 = load i64, i64* %4
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %42, i64 %45)
br label %71
47: ; preds = %12
%48 = load i8*, i8** %13
%49 = tail call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %71
51: ; preds = %47
%52 = bitcast [1024 x i32]* %5 to i8*
%53 = bitcast i64* %6 to i8*
store i64 1024, i64* %6
%54 = getelementptr inbounds i8*, i8** %1, i64 2
%55 = load i8*, i8** %54
%56 = tail call i32 @strlen(i8* %55)
%57 = getelementptr inbounds [1024 x i32], [1024 x i32]* %5, i64 0, i64 0
%58 = call i32 @punycode_decode(i8* %55, i32 %56, i32* %57, i64* %6)
%59 = load i32, i32* %57
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %63, %51
%62 = call i32 @putchar(i32 10)
br label %71
63: ; preds = %51, %63
%64 = phi i64 [ %67, %63 ], [ 0, %51 ]
%65 = phi i32 [ %69, %63 ], [ %59, %51 ]
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %65)
%67 = add nuw i64 %64, 1
%68 = getelementptr inbounds [1024 x i32], [1024 x i32]* %5, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, 0
br i1 %70, label %61, label %63
71: ; preds = %47, %61, %39
%72 = load i32, i32* @EXIT_SUCCESS
ret i32 %72
}