#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 */
char *FP_strdup(char *);
char *ParseString(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ isalnum(char);
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void HandleString(char *input) {
  char *data, *ptr, *p2;
  if (input == NULL) {
    return;
  }
  data = FP_strdup(input);
  ptr = ParseString(data);
  if (!isalpha(*ptr) && *ptr != '_') {
    free(data);
    return;
  }
  ptr++;
  while (isalnum(*ptr) || *ptr == '_')
    ptr++;
  if (*ptr != '=') {
    free(data);
    return;
  }
  *ptr = '\0';
  p2 = ptr + 1;
  fprintf(stdout, "export FORM_%s=\"", data);
  while (*p2) {
    switch (*p2) {
    case '"':
    case '\\':
    case '`':
    case '$':
      putc('\\', stdout);
    default:
      putc(*p2, stdout);
      break;
    }
    p2++;
  }
  putc('"', stdout);
  putc('\n', stdout);
  *ptr = '=';
  free(data);
}


x86 assembly (clang, -O0):
<HandleString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    118c <HandleString+0x1c>
jmp    1347 <HandleString+0x1d7>
mov    -0x8(%rbp),%rdi
call   1080 <FP_strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ParseString@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isalpha@plt>
cmp    $0x0,%eax
jne    11d9 <HandleString+0x69>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11d9 <HandleString+0x69>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1347 <HandleString+0x1d7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    1213 <HandleString+0xa3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1223 <HandleString+0xb3>
jmp    1234 <HandleString+0xc4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e5 <HandleString+0x75>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     1252 <HandleString+0xe2>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1347 <HandleString+0x1d7>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd87(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1311 <HandleString+0x1a1>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x28(%rbp)
sub    $0x22,%eax
je     12d6 <HandleString+0x166>
jmp    12a3 <HandleString+0x133>
mov    -0x28(%rbp),%eax
sub    $0x24,%eax
je     12d6 <HandleString+0x166>
jmp    12b4 <HandleString+0x144>
mov    -0x28(%rbp),%eax
sub    $0x5c,%eax
je     12d6 <HandleString+0x166>
jmp    12c5 <HandleString+0x155>
mov    -0x28(%rbp),%eax
sub    $0x60,%eax
jne    12e9 <HandleString+0x179>
jmp    12d6 <HandleString+0x166>
mov    0x2d03(%rip),%rax
mov    (%rax),%esi
mov    $0x5c,%edi
call   1060 <putc@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    0x2cea(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1060 <putc@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    127e <HandleString+0x10e>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    $0x22,%edi
call   1060 <putc@plt>
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
mov    -0x18(%rbp),%rax
movb   $0x3d,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HandleString>:
test   %rdi,%rdi
je     125a <HandleString+0xea>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
call   1080 <FP_strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <ParseString@plt>
mov    %rax,%r13
movsbl (%rax),%edi
call   1090 <isalpha@plt>
test   %eax,%eax
jne    11ac <HandleString+0x3c>
cmpb   $0x5f,0x0(%r13)
jne    127a <HandleString+0x10a>
add    $0x3,%r13
jmp    11c4 <HandleString+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13
movsbl -0x2(%r13),%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    11c0 <HandleString+0x50>
movzbl -0x2(%r13),%eax
cmp    $0x5f,%al
je     11c0 <HandleString+0x50>
cmp    $0x3d,%al
jne    127a <HandleString+0x10a>
movb   $0x0,-0x2(%r13)
mov    0x2df0(%rip),%r15
mov    (%r15),%edi
lea    0xe06(%rip),%rsi
mov    %r14,%rdx
call   1070 <fprintf@plt>
mov    -0x1(%r13),%al
test   %al,%al
je     125b <HandleString+0xeb>
movabs $0x4400000000000005,%r12
mov    %r13,%rbx
jmp    1236 <HandleString+0xc6>
nopl   0x0(%rax)
mov    (%r15),%esi
movsbl %al,%edi
call   1060 <putc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     125b <HandleString+0xeb>
movsbl %al,%ecx
add    $0xffffffde,%ecx
cmp    $0x3e,%ecx
ja     1220 <HandleString+0xb0>
bt     %rcx,%r12
jae    1220 <HandleString+0xb0>
mov    (%r15),%esi
mov    $0x5c,%edi
call   1060 <putc@plt>
movzbl -0x1(%rbx),%eax
jmp    1220 <HandleString+0xb0>
ret
mov    (%r15),%esi
mov    $0x22,%edi
call   1060 <putc@plt>
mov    (%r15),%esi
mov    $0xa,%edi
call   1060 <putc@plt>
movb   $0x3d,-0x2(%r13)
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [17 x i8] c"export FORM_%s=\22\00"
define void @HandleString(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
br label %86
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i8* @FP_strdup(i8* %10)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = call i8* @ParseString(i8* %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = call i32 @isalpha(i8 signext %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %26, label %18
18: ; preds = %9
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 95
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @free(i8* %24)
br label %86
26: ; preds = %18, %9
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
br label %29
29: ; preds = %41, %26
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = call i64 @isalnum(i8 signext %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 95
br label %39
39: ; preds = %34, %29
%40 = phi i1 [ true, %29 ], [ %38, %34 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %4
br label %29
44: ; preds = %39
%45 = load i8*, i8** %4
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 61
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i8*, i8** %3
%51 = call i32 @free(i8* %50)
br label %86
52: ; preds = %44
%53 = load i8*, i8** %4
store i8 0, i8* %53
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** %5
%56 = load i32, i32* @stdout
%57 = load i8*, i8** %3
%58 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %75, %52
%60 = load i8*, i8** %5
%61 = load i8, i8* %60
%62 = icmp ne i8 %61, 0
br i1 %62, label %63, label %78
63: ; preds = %59
%64 = load i8*, i8** %5
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
switch i32 %66, label %70 [
i32 34, label %67
i32 92, label %67
i32 96, label %67
i32 36, label %67
]
67: ; preds = %63, %63, %63, %63
%68 = load i32, i32* @stdout
%69 = call i32 @putc(i8 signext 92, i32 %68)
br label %70
70: ; preds = %63, %67
%71 = load i8*, i8** %5
%72 = load i8, i8* %71
%73 = load i32, i32* @stdout
%74 = call i32 @putc(i8 signext %72, i32 %73)
br label %75
75: ; preds = %70
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %5
br label %59
78: ; preds = %59
%79 = load i32, i32* @stdout
%80 = call i32 @putc(i8 signext 34, i32 %79)
%81 = load i32, i32* @stdout
%82 = call i32 @putc(i8 signext 10, i32 %81)
%83 = load i8*, i8** %4
store i8 61, i8* %83
%84 = load i8*, i8** %3
%85 = call i32 @free(i8* %84)
br label %86
86: ; preds = %78, %49, %23, %8
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [17 x i8] c"export FORM_%s=\22\00"
define void @HandleString(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %50, label %3
3: ; preds = %1
%4 = tail call i8* @FP_strdup(i8* %0)
%5 = tail call i8* @ParseString(i8* %4)
%6 = load i8, i8* %5
%7 = tail call i32 @isalpha(i8 signext %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 95
br i1 %11, label %12, label %48
12: ; preds = %9, %3
br label %13
13: ; preds = %21, %12
%14 = phi i8* [ %5, %12 ], [ %15, %21 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = tail call i64 @isalnum(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load i8, i8* %15
switch i8 %20, label %48 [
i8 95, label %21
i8 61, label %22
]
21: ; preds = %19, %13
br label %13
22: ; preds = %19
store i8 0, i8* %15
%23 = load i32, i32* @stdout
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4)
%25 = getelementptr inbounds i8, i8* %14, i64 2
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %43, label %28
28: ; preds = %22, %36
%29 = phi i8 [ %41, %36 ], [ %26, %22 ]
%30 = phi i8* [ %40, %36 ], [ %25, %22 ]
%31 = sext i8 %29 to i32
switch i32 %31, label %36 [
i32 34, label %32
i32 92, label %32
i32 96, label %32
i32 36, label %32
]
32: ; preds = %28, %28, %28, %28
%33 = load i32, i32* @stdout
%34 = tail call i32 @putc(i8 signext 92, i32 %33)
%35 = load i8, i8* %30
br label %36
36: ; preds = %28, %32
%37 = phi i8 [ %29, %28 ], [ %35, %32 ]
%38 = load i32, i32* @stdout
%39 = tail call i32 @putc(i8 signext %37, i32 %38)
%40 = getelementptr inbounds i8, i8* %30, i64 1
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
br i1 %42, label %43, label %28
43: ; preds = %36, %22
%44 = load i32, i32* @stdout
%45 = tail call i32 @putc(i8 signext 34, i32 %44)
%46 = load i32, i32* @stdout
%47 = tail call i32 @putc(i8 signext 10, i32 %46)
store i8 61, i8* %15
br label %48
48: ; preds = %19, %9, %43
%49 = tail call i32 @free(i8* %4)
br label %50
50: ; preds = %48, %1
ret void
}