#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 hexToInt(int /*<<< orphan*/);
int /*<<< orphan*/ *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int email_content_iconv(char *args) {
  if (strchr(args, '%') == NULL) {
    return 1;
  }
  char buf[1024 * 128] = {'\0'};
  char *p = args;
  int i = 0;
L1:
  while (*p && (*p != '%'))
    *(buf + i++) = *p++;
  if (!*p)
    goto L2;
  p++;
  *(buf + i++) = (char)(hexToInt(*p++) * 16 + hexToInt(*p++));
  goto L1;
L2:
  *(buf + i) = '\0';
  strcpy(args, buf);
  return 1;
}


x86 assembly (clang, -O0):
<email_content_iconv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20030,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x25,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    1173 <email_content_iconv+0x33>
movl   $0x1,-0x4(%rbp)
jmp    12d5 <email_content_iconv+0x195>
lea    -0x20010(%rbp),%rdi
xor    %esi,%esi
mov    $0x20000,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20018(%rbp)
movl   $0x0,-0x2001c(%rbp)
jmp    11a0 <email_content_iconv+0x60>
mov    -0x20018(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2001d(%rbp)
je     11d1 <email_content_iconv+0x91>
mov    -0x20018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
setne  %al
mov    %al,-0x2001d(%rbp)
mov    -0x2001d(%rbp),%al
test   $0x1,%al
jne    11e4 <email_content_iconv+0xa4>
jmp    121a <email_content_iconv+0xda>
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x2001c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2001c(%rbp)
cltq
mov    %cl,-0x20010(%rbp,%rax,1)
jmp    11a0 <email_content_iconv+0x60>
mov    -0x20018(%rbp),%rax
cmpb   $0x0,(%rax)
jne    122f <email_content_iconv+0xef>
jmp    12af <email_content_iconv+0x16f>
mov    -0x20018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20018(%rbp)
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
movsbl (%rax),%edi
call   1060 <hexToInt@plt>
shl    $0x4,%eax
mov    %eax,-0x20024(%rbp)
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
movsbl (%rax),%edi
call   1060 <hexToInt@plt>
mov    %eax,%ecx
mov    -0x20024(%rbp),%eax
add    %ecx,%eax
mov    %al,%cl
mov    -0x2001c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2001c(%rbp)
cltq
mov    %cl,-0x20010(%rbp,%rax,1)
jmp    119b <email_content_iconv+0x5b>
movslq -0x2001c(%rbp),%rax
movb   $0x0,-0x20010(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
lea    -0x20010(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<email_content_iconv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20008,%rsp
mov    %rdi,%r14
mov    $0x25,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11fa <email_content_iconv+0xba>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x20000,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movabs $0x100000000,%r12
mov    %r14,%rbp
mov    %rbx,%r13
shl    $0x20,%r13
movslq %ebx,%rbx
add    $0x1,%rbx
add    $0x3,%rbp
nopw   0x0(%rax,%rax,1)
movzbl -0x3(%rbp),%eax
test   %al,%al
je     11e6 <email_content_iconv+0xa6>
cmp    $0x25,%al
je     11c0 <email_content_iconv+0x80>
mov    %al,-0x1(%rsp,%rbx,1)
add    %r12,%r13
add    $0x1,%rbx
add    $0x1,%rbp
jmp    11a0 <email_content_iconv+0x60>
nopl   (%rax)
movsbl -0x2(%rbp),%edi
call   1060 <hexToInt@plt>
mov    %eax,%r15d
shl    $0x4,%r15d
movsbl -0x1(%rbp),%edi
call   1060 <hexToInt@plt>
add    %r15d,%eax
sar    $0x20,%r13
mov    %al,(%rsp,%r13,1)
jmp    1185 <email_content_iconv+0x45>
sar    $0x20,%r13
movb   $0x0,(%rsp,%r13,1)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0x20008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @email_content_iconv(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [131072 x i8]
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @strchr(i8* %7, i8 signext 37)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %70
11: ; preds = %1
%12 = bitcast [131072 x i8]* %4 to i8*
%13 = load i8*, i8** %3
store i8* %13, i8** %5
store i32 0, i32* %6
br label %14
14: ; preds = %41, %11
br label %15
15: ; preds = %27, %14
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 37
br label %25
25: ; preds = %20, %15
%26 = phi i1 [ false, %15 ], [ %24, %20 ]
br i1 %26, label %27, label %36
27: ; preds = %25
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
%30 = load i8, i8* %28
%31 = getelementptr inbounds [131072 x i8], [131072 x i8]* %4, i64 0, i64 0
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 %30, i8* %35
br label %15
36: ; preds = %25
%37 = load i8*, i8** %5
%38 = load i8, i8* %37
%39 = icmp ne i8 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %36
br label %62
41: ; preds = %36
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %5
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %5
%46 = load i8, i8* %44
%47 = sext i8 %46 to i32
%48 = call i32 @hexToInt(i32 %47)
%49 = mul nsw i32 %48, 16
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %5
%52 = load i8, i8* %50
%53 = sext i8 %52 to i32
%54 = call i32 @hexToInt(i32 %53)
%55 = add nsw i32 %49, %54
%56 = trunc i32 %55 to i8
%57 = getelementptr inbounds [131072 x i8], [131072 x i8]* %4, i64 0, i64 0
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
store i8 %56, i8* %61
br label %14
62: ; preds = %40
%63 = getelementptr inbounds [131072 x i8], [131072 x i8]* %4, i64 0, i64 0
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8 0, i8* %66
%67 = load i8*, i8** %3
%68 = getelementptr inbounds [131072 x i8], [131072 x i8]* %4, i64 0, i64 0
%69 = call i32 @strcpy(i8* %67, i8* %68)
store i32 1, i32* %2
br label %70
70: ; preds = %62, %10
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
define i32 @email_content_iconv(i8* %0) {
%2 = alloca [131072 x i8]
%3 = tail call i32* @strchr(i8* %0, i8 signext 37)
%4 = icmp eq i32* %3, null
br i1 %4, label %42, label %5
5: ; preds = %1
%6 = getelementptr inbounds [131072 x i8], [131072 x i8]* %2, i64 0, i64 0
br label %7
7: ; preds = %20, %5
%8 = phi i8* [ %0, %5 ], [ %27, %20 ]
%9 = phi i64 [ 0, %5 ], [ %33, %20 ]
%10 = shl i64 %9, 32
%11 = ashr exact i64 %10, 32
br label %12
12: ; preds = %16, %7
%13 = phi i64 [ %18, %16 ], [ %11, %7 ]
%14 = phi i8* [ %17, %16 ], [ %8, %7 ]
%15 = load i8, i8* %14
switch i8 %15, label %16 [
i8 0, label %37
i8 37, label %20
]
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = add i64 %13, 1
%19 = getelementptr inbounds [131072 x i8], [131072 x i8]* %2, i64 0, i64 %13
store i8 %15, i8* %19
br label %12
20: ; preds = %12
%21 = getelementptr inbounds i8, i8* %14, i64 1
%22 = getelementptr inbounds i8, i8* %14, i64 2
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = tail call i32 @hexToInt(i32 %24)
%26 = shl nsw i32 %25, 4
%27 = getelementptr inbounds i8, i8* %14, i64 3
%28 = load i8, i8* %22
%29 = sext i8 %28 to i32
%30 = tail call i32 @hexToInt(i32 %29)
%31 = add nsw i32 %30, %26
%32 = trunc i32 %31 to i8
%33 = add i64 %13, 1
%34 = shl i64 %13, 32
%35 = ashr exact i64 %34, 32
%36 = getelementptr inbounds [131072 x i8], [131072 x i8]* %2, i64 0, i64 %35
store i8 %32, i8* %36
br label %7
37: ; preds = %12
%38 = shl i64 %13, 32
%39 = ashr exact i64 %38, 32
%40 = getelementptr inbounds [131072 x i8], [131072 x i8]* %2, i64 0, i64 %39
store i8 0, i8* %40
%41 = call i32 @strcpy(i8* %0, i8* %6)
br label %42
42: ; preds = %1, %37
ret i32 1
}