#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 /*<<< orphan*/ fputc(char const, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ isprint(char const);
scalar_t__ isspace(char const);
int /*<<< orphan*/ printf(char *, unsigned char, ...);
int /*<<< orphan*/ stdout;
void output(int netno, const char *var, const char *val) {
  const char *p;
  int f = 0;
  for (p = val; *p != '\0'; p++)
    if (!isprint(*p) || isspace(*p) || *p == '\'' || *p == '"' || *p == '$' ||
        *p == '*' || *p == '?') {
      f = 1;
      break;
    }
  if (!f) {
    printf("NET_%d_%s=%s\n", netno, var, val);
    return;
  }
  printf("NET_%d_%s=", netno, var);
  fputc('\'', stdout);
  for (p = val; *p != '\0'; p++) {
    switch (*p) {
    case '\'':
      fputs("'\\''", stdout);
      break;
    default:
      if (isprint(*p) || *p == ' ')
        fputc(*p, stdout);
      else
        printf("%%%02x", (unsigned char)*p);
      break;
    }
  }
  fputc('\'', stdout);
  fputc('\n', stdout);
}


x86 assembly (clang, -O0):
<output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1220 <output+0xd0>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isprint@plt>
cmp    $0x0,%rax
je     11fe <output+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
jne    11fe <output+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     11fe <output+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     11fe <output+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
je     11fe <output+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     11fe <output+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    120a <output+0xba>
movl   $0x1,-0x24(%rbp)
jmp    1220 <output+0xd0>
jmp    120f <output+0xbf>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1172 <output+0x22>
cmpl   $0x0,-0x24(%rbp)
jne    124b <output+0xfb>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdc4(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1353 <output+0x203>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%rdx
lea    0xdb5(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
mov    $0x27,%edi
call   1060 <fputc@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     132d <output+0x1dd>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
sub    $0x27,%al
jne    12bb <output+0x16b>
jmp    12a1 <output+0x151>
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
lea    0xd68(%rip),%rdi
call   1040 <fputs@plt>
jmp    1317 <output+0x1c7>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isprint@plt>
cmp    $0x0,%rax
jne    12e1 <output+0x191>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    12fd <output+0x1ad>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    0x2cf2(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
jmp    1312 <output+0x1c2>
mov    -0x20(%rbp),%rax
lea    0xd16(%rip),%rdi
movzbl (%rax),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1317 <output+0x1c7>
jmp    131c <output+0x1cc>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    127e <output+0x12e>
mov    0x2cac(%rip),%rax
mov    (%rax),%esi
mov    $0x27,%edi
call   1060 <fputc@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <fputc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r12d
mov    (%rdx),%al
test   %al,%al
je     127b <output+0x12b>
movabs $0x8000049400000000,%r15
mov    %rbx,%rbp
jmp    1190 <output+0x40>
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     127b <output+0x12b>
movsbl %al,%edi
call   1070 <isprint@plt>
test   %rax,%rax
je     11bb <output+0x6b>
movsbl 0x0(%rbp),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    11bb <output+0x6b>
movzbl 0x0(%rbp),%eax
cmp    $0x3f,%rax
ja     1180 <output+0x30>
bt     %rax,%r15
jae    1180 <output+0x30>
movzbl %r12b,%esi
lea    0xe48(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e09(%rip),%rbp
mov    0x0(%rbp),%esi
mov    $0x27,%edi
call   1060 <fputc@plt>
lea    0xe2e(%rip),%r14
lea    0xe2c(%rip),%r15
jmp    120f <output+0xbf>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%rbp),%esi
mov    %r14,%rdi
call   1040 <fputs@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x27,%al
je     1200 <output+0xb0>
test   %al,%al
je     1259 <output+0x109>
movsbl %al,%edi
call   1070 <isprint@plt>
movzbl (%rbx),%ecx
test   %rax,%rax
je     122e <output+0xde>
mov    %ecx,%eax
jmp    1235 <output+0xe5>
mov    $0x20,%al
cmp    $0x20,%cl
jne    1246 <output+0xf6>
mov    0x0(%rbp),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
add    $0x1,%rbx
jmp    120f <output+0xbf>
movzbl %cl,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
jmp    120f <output+0xbf>
mov    0x0(%rbp),%esi
mov    $0x27,%edi
call   1060 <fputc@plt>
mov    0x0(%rbp),%esi
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fputc@plt>
movzbl %r12b,%esi
lea    0xd7a(%rip),%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"NET_%d_%s=%s\0A\00"
@.str.1 = [11 x i8] c"NET_%d_%s=\00"
@stdout = global i32 0
@.str.2 = [5 x i8] c"'\\''\00"
@.str.3 = [7 x i8] c"%%%02x\00"
define void @output(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %8
%9 = load i8*, i8** %6
store i8* %9, i8** %7
br label %10
10: ; preds = %52, %3
%11 = load i8*, i8** %7
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %55
15: ; preds = %10
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = call i64 @isprint(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %50
20: ; preds = %15
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = call i64 @isspace(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %50, label %25
25: ; preds = %20
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 39
br i1 %29, label %50, label %30
30: ; preds = %25
%31 = load i8*, i8** %7
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 34
br i1 %34, label %50, label %35
35: ; preds = %30
%36 = load i8*, i8** %7
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 36
br i1 %39, label %50, label %40
40: ; preds = %35
%41 = load i8*, i8** %7
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 42
br i1 %44, label %50, label %45
45: ; preds = %40
%46 = load i8*, i8** %7
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 63
br i1 %49, label %50, label %51
50: ; preds = %45, %40, %35, %30, %25, %20, %15
store i32 1, i32* %8
br label %55
51: ; preds = %45
br label %52
52: ; preds = %51
%53 = load i8*, i8** %7
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %7
br label %10
55: ; preds = %50, %10
%56 = load i32, i32* %8
%57 = icmp ne i32 %56, 0
br i1 %57, label %64, label %58
58: ; preds = %55
%59 = load i32, i32* %4
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %5
%62 = load i8*, i8** %6
%63 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 zeroext %60, i8* %61, i8* %62)
br label %113
64: ; preds = %55
%65 = load i32, i32* %4
%66 = trunc i32 %65 to i8
%67 = load i8*, i8** %5
%68 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %66, i8* %67)
%69 = load i32, i32* @stdout
%70 = call i32 @fputc(i8 signext 39, i32 %69)
%71 = load i8*, i8** %6
store i8* %71, i8** %7
br label %72
72: ; preds = %105, %64
%73 = load i8*, i8** %7
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %108
77: ; preds = %72
%78 = load i8*, i8** %7
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
switch i32 %80, label %84 [
i32 39, label %81
]
81: ; preds = %77
%82 = load i32, i32* @stdout
%83 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %82)
br label %104
84: ; preds = %77
%85 = load i8*, i8** %7
%86 = load i8, i8* %85
%87 = call i64 @isprint(i8 signext %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %94, label %89
89: ; preds = %84
%90 = load i8*, i8** %7
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 32
br i1 %93, label %94, label %99
94: ; preds = %89, %84
%95 = load i8*, i8** %7
%96 = load i8, i8* %95
%97 = load i32, i32* @stdout
%98 = call i32 @fputc(i8 signext %96, i32 %97)
br label %103
99: ; preds = %89
%100 = load i8*, i8** %7
%101 = load i8, i8* %100
%102 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %101)
br label %103
103: ; preds = %99, %94
br label %104
104: ; preds = %103, %81
br label %105
105: ; preds = %104
%106 = load i8*, i8** %7
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %7
br label %72
108: ; preds = %72
%109 = load i32, i32* @stdout
%110 = call i32 @fputc(i8 signext 39, i32 %109)
%111 = load i32, i32* @stdout
%112 = call i32 @fputc(i8 signext 10, i32 %111)
br label %113
113: ; preds = %108, %58
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"NET_%d_%s=%s\0A\00"
@.str.1 = [11 x i8] c"NET_%d_%s=\00"
@stdout = global i32 0
@.str.2 = [5 x i8] c"'\\''\00"
@.str.3 = [7 x i8] c"%%%02x\00"
define void @output(i32 %0, i8* %1, i8* %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3, %17
%7 = phi i8 [ %19, %17 ], [ %4, %3 ]
%8 = phi i8* [ %18, %17 ], [ %2, %3 ]
%9 = tail call i64 @isprint(i8 signext %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %6
%12 = load i8, i8* %8
%13 = tail call i64 @isspace(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i8, i8* %8
switch i8 %16, label %17 [
i8 39, label %24
i8 34, label %24
i8 36, label %24
i8 42, label %24
i8 63, label %24
]
17: ; preds = %15
%18 = getelementptr inbounds i8, i8* %8, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %6
21: ; preds = %17, %3
%22 = trunc i32 %0 to i8
%23 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8 zeroext %22, i8* %1, i8* %2)
br label %54
24: ; preds = %15, %15, %15, %15, %15, %11, %6
%25 = trunc i32 %0 to i8
%26 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %25, i8* %1)
%27 = load i32, i32* @stdout
%28 = tail call i32 @fputc(i8 signext 39, i32 %27)
br label %29
29: ; preds = %47, %24
%30 = phi i8* [ %2, %24 ], [ %48, %47 ]
%31 = load i8, i8* %30
switch i8 %31, label %35 [
i8 0, label %49
i8 39, label %32
]
32: ; preds = %29
%33 = load i32, i32* @stdout
%34 = tail call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %47
35: ; preds = %29
%36 = tail call i64 @isprint(i8 signext %31)
%37 = icmp eq i64 %36, 0
%38 = load i8, i8* %30
br i1 %37, label %39, label %41
39: ; preds = %35
%40 = icmp eq i8 %38, 32
br i1 %40, label %41, label %45
41: ; preds = %35, %39
%42 = phi i8 [ 32, %39 ], [ %38, %35 ]
%43 = load i32, i32* @stdout
%44 = tail call i32 @fputc(i8 signext %42, i32 %43)
br label %47
45: ; preds = %39
%46 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %38)
br label %47
47: ; preds = %32, %45, %41
%48 = getelementptr inbounds i8, i8* %30, i64 1
br label %29
49: ; preds = %29
%50 = load i32, i32* @stdout
%51 = tail call i32 @fputc(i8 signext 39, i32 %50)
%52 = load i32, i32* @stdout
%53 = tail call i32 @fputc(i8 signext 10, i32 %52)
br label %54
54: ; preds = %49, %21
ret void
}