#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*/ fprintf(int /*<<< orphan*/ *, char *);
size_t strcspn(char const *, char *);
int /*<<< orphan*/ xfwrite(char const *, size_t, int, int /*<<< orphan*/ *);
void kconfig_print_comment(FILE *fp, const char *value, void *arg) {
  const char *p = value;
  size_t l;
  for (;;) {
    l = strcspn(p, "\n");
    fprintf(fp, "#");
    if (l) {
      fprintf(fp, " ");
      xfwrite(p, l, 1, fp);
      p += l;
    }
    fprintf(fp, "\n");
    if (*p++ == '\0')
      break;
  }
}


x86 assembly (clang, -O0):
<kconfig_print_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1030 <strcspn@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <fprintf@plt>
cmpq   $0x0,-0x28(%rbp)
je     11ad <kconfig_print_comment+0x7d>
mov    -0x8(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
call   1050 <xfwrite@plt>
mov    -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11dd <kconfig_print_comment+0xad>
jmp    11e2 <kconfig_print_comment+0xb2>
jmp    114c <kconfig_print_comment+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kconfig_print_comment>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xebb(%rip),%r15
jmp    1166 <kconfig_print_comment+0x36>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
je     11ab <kconfig_print_comment+0x7b>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcspn@plt>
mov    %rax,%r12
mov    $0x23,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
test   %r12,%r12
je     1150 <kconfig_print_comment+0x20>
mov    $0x20,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <xfwrite@plt>
add    %r12,%rbx
jmp    1150 <kconfig_print_comment+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [2 x i8] c" \00"
define void @kconfig_print_comment(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %5
store i8* %9, i8** %7
br label %10
10: ; preds = %36, %3
%11 = load i8*, i8** %7
%12 = call i64 @strcspn(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i64 %12, i64* %8
%13 = load i32*, i32** %4
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i64, i64* %8
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %10
%18 = load i32*, i32** %4
%19 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %7
%21 = load i64, i64* %8
%22 = load i32*, i32** %4
%23 = call i32 @xfwrite(i8* %20, i64 %21, i32 1, i32* %22)
%24 = load i64, i64* %8
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 %24
store i8* %26, i8** %7
br label %27
27: ; preds = %17, %10
%28 = load i32*, i32** %4
%29 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %7
%32 = load i8, i8* %30
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %27
br label %37
36: ; preds = %27
br label %10
37: ; preds = %35
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define void @kconfig_print_comment(i32* %0, i8* %1, i8* nocapture readnone %2) {
br label %4
4: ; preds = %13, %3
%5 = phi i8* [ %1, %3 ], [ %16, %13 ]
%6 = tail call i64 @strcspn(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @fputc(i32 35, i32* %0)
%8 = icmp eq i64 %6, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = tail call i32 @fputc(i32 32, i32* %0)
%11 = tail call i32 @xfwrite(i8* %5, i64 %6, i32 1, i32* %0)
%12 = getelementptr inbounds i8, i8* %5, i64 %6
br label %13
13: ; preds = %9, %4
%14 = phi i8* [ %12, %9 ], [ %5, %4 ]
%15 = tail call i32 @fputc(i32 10, i32* %0)
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %4
19: ; preds = %13
ret void
}