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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void output_function_csv_record(unsigned long int host, int port, time_t time,
                                char *data, int len) {
  printf("\"%lu.%lu.%lu.%lu\",%d,%d,", ((host & 0xFF000000) >> 24),
         ((host & 0x00FF0000) >> 16), ((host & 0x0000FF00) >> 8),
         ((host & 0x000000FF) >> 0), port, time);
  printf("\"");
  int i;
  for (i = 0; i < len; ++i) {
    switch (data[i]) {
    case '\n':
      printf("\\n");
      break;
    case '\r':
      printf("\\r");
      break;
    case '"':
      printf("\\\"");
      break;
    case '\\':
      printf("\\");
      break;
    default:
      printf("%c", data[i]);
    }
  }
  printf("\"\n");
}


x86 assembly (clang, -O0):
<output_function_csv_record>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movabs $0xff000000,%rsi
and    -0x8(%rbp),%rsi
shr    $0x18,%rsi
mov    -0x8(%rbp),%rdx
and    $0xff0000,%rdx
shr    $0x10,%rdx
mov    -0x8(%rbp),%rcx
and    $0xff00,%rcx
shr    $0x8,%rcx
mov    -0x8(%rbp),%r8
and    $0xff,%r8
shr    $0x0,%r8
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%eax
lea    0xe89(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    126b <output_function_csv_record+0x15b>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
sub    $0xa,%eax
je     11f2 <output_function_csv_record+0xe2>
jmp    11bf <output_function_csv_record+0xaf>
mov    -0x24(%rbp),%eax
sub    $0xd,%eax
je     1205 <output_function_csv_record+0xf5>
jmp    11d0 <output_function_csv_record+0xc0>
mov    -0x24(%rbp),%eax
sub    $0x22,%eax
je     1218 <output_function_csv_record+0x108>
jmp    11e1 <output_function_csv_record+0xd1>
mov    -0x24(%rbp),%eax
sub    $0x5c,%eax
je     122b <output_function_csv_record+0x11b>
jmp    123e <output_function_csv_record+0x12e>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <output_function_csv_record+0x148>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <output_function_csv_record+0x148>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <output_function_csv_record+0x148>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <output_function_csv_record+0x148>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <output_function_csv_record+0x14d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <output_function_csv_record+0x86>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_function_csv_record>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %rcx,%r13
mov    %esi,%r9d
mov    %rdi,%rax
movzbl %ah,%ecx
movzbl %al,%r8d
mov    %eax,%esi
shr    $0x18,%esi
shr    $0x10,%edi
movzbl %dil,%eax
mov    %edx,(%rsp)
lea    0xe9c(%rip),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x22,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    11f5 <output_function_csv_record+0xc5>
mov    %ebp,%ebp
lea    0xe94(%rip),%r14
lea    0xe90(%rip),%r15
lea    0xe8c(%rip),%r12
xor    %ebx,%ebx
jmp    11b3 <output_function_csv_record+0x83>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11f5 <output_function_csv_record+0xc5>
movsbl 0x0(%r13,%rbx,1),%edi
cmp    $0x21,%edi
jg     11d0 <output_function_csv_record+0xa0>
cmp    $0xa,%edi
je     11a0 <output_function_csv_record+0x70>
cmp    $0xd,%edi
jne    11df <output_function_csv_record+0xaf>
mov    %r15,%rdi
jmp    11a3 <output_function_csv_record+0x73>
nopl   (%rax)
cmp    $0x22,%edi
je     11f0 <output_function_csv_record+0xc0>
cmp    $0x5c,%edi
jne    11df <output_function_csv_record+0xaf>
mov    $0x5c,%edi
call   1030 <putchar@plt>
jmp    11aa <output_function_csv_record+0x7a>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
jmp    11a3 <output_function_csv_record+0x73>
lea    0xe24(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"\22%lu.%lu.%lu.%lu\22,%d,%d,\00"
@.str.1 = [2 x i8] c"\22\00"
@.str.2 = [3 x i8] c"\\n\00"
@.str.3 = [3 x i8] c"\\r\00"
@.str.4 = [3 x i8] c"\\\22\00"
@.str.5 = [2 x i8] c"\\\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [3 x i8] c"\22\0A\00"
define void @output_function_csv_record(i64 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i64 %0, i64* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i64, i64* %6
%13 = and i64 %12, 4278190080
%14 = lshr i64 %13, 24
%15 = load i64, i64* %6
%16 = and i64 %15, 16711680
%17 = lshr i64 %16, 16
%18 = load i64, i64* %6
%19 = and i64 %18, 65280
%20 = lshr i64 %19, 8
%21 = load i64, i64* %6
%22 = and i64 %21, 255
%23 = lshr i64 %22, 0
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %17, i64 %20, i64 %23, i32 %24, i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %11
br label %28
28: ; preds = %56, %5
%29 = load i32, i32* %11
%30 = load i32, i32* %10
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %59
32: ; preds = %28
%33 = load i8*, i8** %9
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
switch i32 %38, label %47 [
i32 10, label %39
i32 13, label %41
i32 34, label %43
i32 92, label %45
]
39: ; preds = %32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %55
41: ; preds = %32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %55
43: ; preds = %32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %55
45: ; preds = %32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %55
47: ; preds = %32
%48 = load i8*, i8** %9
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %47, %45, %43, %41, %39
br label %56
56: ; preds = %55
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 1
store i32 %58, i32* %11
br label %28
59: ; preds = %28
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"\22%lu.%lu.%lu.%lu\22,%d,%d,\00"
@.str.2 = [3 x i8] c"\\n\00"
@.str.3 = [3 x i8] c"\\r\00"
@.str.4 = [3 x i8] c"\\\22\00"
@str = [2 x i8] c"\22\00"
define void @output_function_csv_record(i64 %0, i32 %1, i32 %2, i8* nocapture %3, i32 %4) {
%6 = lshr i64 %0, 24
%7 = and i64 %6, 255
%8 = lshr i64 %0, 16
%9 = and i64 %8, 255
%10 = lshr i64 %0, 8
%11 = and i64 %10, 255
%12 = and i64 %0, 255
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %7, i64 %9, i64 %11, i64 %12, i32 %1, i32 %2)
%14 = tail call i32 @putchar(i32 34)
%15 = icmp sgt i32 %4, 0
br i1 %15, label %16, label %36
16: ; preds = %5
%17 = zext i32 %4 to i64
br label %18
18: ; preds = %16, %33
%19 = phi i64 [ 0, %16 ], [ %34, %33 ]
%20 = getelementptr inbounds i8, i8* %3, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %31 [
i32 10, label %23
i32 13, label %25
i32 34, label %27
i32 92, label %29
]
23: ; preds = %18
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %33
25: ; preds = %18
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %33
27: ; preds = %18
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %33
29: ; preds = %18
%30 = tail call i32 @putchar(i32 92)
br label %33
31: ; preds = %18
%32 = tail call i32 @putchar(i32 %22)
br label %33
33: ; preds = %23, %25, %27, %29, %31
%34 = add nuw nsw i64 %19, 1
%35 = icmp eq i64 %34, %17
br i1 %35, label %36, label %18
36: ; preds = %33, %5
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}