#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/ *);
int /*<<< orphan*/ isdigit(char const);
void write_sanitized(char const *s, FILE *f) {
  for (char const *c = s; *c != '\0'; ++c) {
    switch (*c) {
    case 1:
    case 2:
    case 28:
    case 29:
    case 30:
    case 31:
      break;
    case 3:
      if (c[1] == '#')
        c += 15;
      else {
        if (isdigit(c[1]))
          ++c;
        if (isdigit(c[1]))
          ++c;
        if (c[1] == ',')
          ++c;
        if (isdigit(c[1]))
          ++c;
        if (isdigit(c[1]))
          ++c;
      }
      break;
    default:
      fputc(*c, f);
    }
  }
}


x86 assembly (clang, -O0):
<write_sanitized>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1286 <write_sanitized+0x166>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     1188 <write_sanitized+0x68>
jmp    1163 <write_sanitized+0x43>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     118d <write_sanitized+0x6d>
jmp    1174 <write_sanitized+0x54>
mov    -0x1c(%rbp),%eax
add    $0xffffffe4,%eax
sub    $0x3,%eax
ja     125e <write_sanitized+0x13e>
jmp    1188 <write_sanitized+0x68>
jmp    1270 <write_sanitized+0x150>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x23,%eax
jne    11af <write_sanitized+0x8f>
mov    -0x18(%rbp),%rax
add    $0xf,%rax
mov    %rax,-0x18(%rbp)
jmp    1259 <write_sanitized+0x139>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11d1 <write_sanitized+0xb1>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11f3 <write_sanitized+0xd3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2c,%eax
jne    1210 <write_sanitized+0xf0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1232 <write_sanitized+0x112>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1254 <write_sanitized+0x134>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1259 <write_sanitized+0x139>
jmp    1270 <write_sanitized+0x150>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    1275 <write_sanitized+0x155>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <write_sanitized+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_sanitized>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     11cb <write_sanitized+0xab>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xf0000006,%ebp
jmp    115c <write_sanitized+0x3c>
mov    %r14,%rsi
call   1040 <fputc@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11cb <write_sanitized+0xab>
movsbl %al,%edi
cmp    $0x1f,%edi
ja     113b <write_sanitized+0x1b>
bt     %edi,%ebp
jb     1150 <write_sanitized+0x30>
cmp    $0x3,%edi
jne    113b <write_sanitized+0x1b>
movzbl 0x1(%rbx),%eax
cmp    $0x23,%al
jne    117c <write_sanitized+0x5c>
add    $0xf,%rbx
jmp    1150 <write_sanitized+0x30>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     118c <write_sanitized+0x6c>
add    $0x1,%rbx
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     119d <write_sanitized+0x7d>
add    $0x1,%rbx
cmpb   $0x2c,0x1(%rbx)
jne    11a7 <write_sanitized+0x87>
add    $0x1,%rbx
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11b8 <write_sanitized+0x98>
add    $0x1,%rbx
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1150 <write_sanitized+0x30>
add    $0x1,%rbx
jmp    1150 <write_sanitized+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @write_sanitized(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
br label %7
7: ; preds = %79, %2
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %82
12: ; preds = %7
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %73 [
i32 1, label %16
i32 2, label %16
i32 28, label %16
i32 29, label %16
i32 30, label %16
i32 31, label %16
i32 3, label %17
]
16: ; preds = %12, %12, %12, %12, %12, %12
br label %78
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 35
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 15
store i8* %25, i8** %5
br label %72
26: ; preds = %17
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = call i32 @isdigit(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
br label %35
35: ; preds = %32, %26
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = call i32 @isdigit(i8 signext %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %5
br label %44
44: ; preds = %41, %35
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 44
br i1 %49, label %50, label %53
50: ; preds = %44
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %5
br label %53
53: ; preds = %50, %44
%54 = load i8*, i8** %5
%55 = getelementptr inbounds i8, i8* %54, i64 1
%56 = load i8, i8* %55
%57 = call i32 @isdigit(i8 signext %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %53
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %5
br label %62
62: ; preds = %59, %53
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
%66 = call i32 @isdigit(i8 signext %65)
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %5
br label %71
71: ; preds = %68, %62
br label %72
72: ; preds = %71, %23
br label %78
73: ; preds = %12
%74 = load i8*, i8** %5
%75 = load i8, i8* %74
%76 = load i32*, i32** %4
%77 = call i32 @fputc(i8 signext %75, i32* %76)
br label %78
78: ; preds = %73, %72, %16
br label %79
79: ; preds = %78
%80 = load i8*, i8** %5
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %5
br label %7
82: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @write_sanitized(i8* nocapture %0, i32* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %41, %2
ret void
6: ; preds = %2, %41
%7 = phi i8 [ %44, %41 ], [ %3, %2 ]
%8 = phi i8* [ %43, %41 ], [ %0, %2 ]
%9 = sext i8 %7 to i32
switch i32 %9, label %39 [
i32 1, label %41
i32 2, label %41
i32 28, label %41
i32 29, label %41
i32 30, label %41
i32 31, label %41
i32 3, label %10
]
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 35
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %8, i64 15
br label %41
16: ; preds = %10
%17 = tail call i32 @isdigit(i8 signext %12)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* %8, i8* %11
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = tail call i32 @isdigit(i8 signext %21)
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i8* %19, i8* %20
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 44
%28 = select i1 %27, i8* %25, i8* %24
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = tail call i32 @isdigit(i8 signext %30)
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i8* %28, i8* %29
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = tail call i32 @isdigit(i8 signext %35)
%37 = icmp eq i32 %36, 0
%38 = select i1 %37, i8* %33, i8* %34
br label %41
39: ; preds = %6
%40 = tail call i32 @fputc(i8 signext %7, i32* %1)
br label %41
41: ; preds = %16, %39, %6, %6, %6, %6, %6, %6, %14
%42 = phi i8* [ %8, %39 ], [ %15, %14 ], [ %8, %6 ], [ %8, %6 ], [ %8, %6 ], [ %8, %6 ], [ %8, %6 ], [ %8, %6 ], [ %38, %16 ]
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %5, label %6
}