#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 */
void rfc2822_unfold(char *header) {
  size_t in = 0;
  size_t out = 0;
  while (header[in]) {
    if (header[in] == '\n')
      ++in;
    else
      header[out++] = header[in++];
  }
  header[out] = '\0';
}


x86 assembly (clang, -O0):
<rfc2822_unfold>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1181 <rfc2822_unfold+0x81>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1150 <rfc2822_unfold+0x50>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117c <rfc2822_unfold+0x7c>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x18(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    1118 <rfc2822_unfold+0x18>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfc2822_unfold>:
xor    %eax,%eax
mov    %rdi,%rcx
jmp    1114 <rfc2822_unfold+0x14>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
movzbl (%rcx),%edx
cmp    $0xa,%dl
je     1110 <rfc2822_unfold+0x10>
test   %dl,%dl
je     1129 <rfc2822_unfold+0x29>
mov    %dl,(%rdi,%rax,1)
add    $0x1,%rax
jmp    1110 <rfc2822_unfold+0x10>
movb   $0x0,(%rdi,%rax,1)
ret

LLVM IR (-O0):
define void @rfc2822_unfold(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %5
5: ; preds = %31, %1
%6 = load i8*, i8** %2
%7 = load i64, i64* %3
%8 = getelementptr inbounds i8, i8* %6, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %5
%12 = load i8*, i8** %2
%13 = load i64, i64* %3
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
br label %31
21: ; preds = %11
%22 = load i8*, i8** %2
%23 = load i64, i64* %3
%24 = add i64 %23, 1
store i64 %24, i64* %3
%25 = getelementptr inbounds i8, i8* %22, i64 %23
%26 = load i8, i8* %25
%27 = load i8*, i8** %2
%28 = load i64, i64* %4
%29 = add i64 %28, 1
store i64 %29, i64* %4
%30 = getelementptr inbounds i8, i8* %27, i64 %28
store i8 %26, i8* %30
br label %31
31: ; preds = %21, %18
br label %5
32: ; preds = %5
%33 = load i8*, i8** %2
%34 = load i64, i64* %4
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8 0, i8* %35
ret void
}

LLVM IR (-O2):
define void @rfc2822_unfold(i8* nocapture %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i64 [ 0, %1 ], [ %12, %10 ]
%4 = phi i64 [ 0, %1 ], [ %11, %10 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %3
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %13
i8 10, label %10
]
7: ; preds = %2
%8 = add i64 %4, 1
%9 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 %6, i8* %9
br label %10
10: ; preds = %2, %7
%11 = phi i64 [ %8, %7 ], [ %4, %2 ]
%12 = add i64 %3, 1
br label %2
13: ; preds = %2
%14 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 0, i8* %14
ret void
}