#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ strcmp(char *, char *);
void make_readme(FILE *in, FILE *out, char *title) {
  int p = 0;
  char line[10000];
  fprintf(out, "File name: %s\n", title);
  while (fgets(line, 10000, in) != NULL) {
    if (p == 0 && strcmp(line, "/**\n") == 0)
      p = 1;
    if (p == 1) {
      fprintf(out, "%s", line);
    }
    if (p == 1 && strcmp(line, " */\n") == 0)
      p = 0;
  }
  fprintf(out, "Comment end.\n\n");
}


x86 assembly (clang, -O0):
<make_readme>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x2730(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x2710,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     1207 <make_readme+0xd7>
cmpl   $0x0,-0x1c(%rbp)
jne    11b1 <make_readme+0x81>
lea    -0x2730(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b1 <make_readme+0x81>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11d4 <make_readme+0xa4>
mov    -0x10(%rbp),%rdi
lea    -0x2730(%rbp),%rdx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    1202 <make_readme+0xd2>
lea    -0x2730(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1202 <make_readme+0xd2>
movl   $0x0,-0x1c(%rbp)
jmp    1164 <make_readme+0x34>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_readme>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2718,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe92(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rsp,%rdi
mov    $0x2710,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11fc <make_readme+0xac>
lea    0xe79(%rip),%r15
mov    %rsp,%rbx
lea    0xe74(%rip),%r13
jmp    11e4 <make_readme+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
mov    $0x2710,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11fc <make_readme+0xac>
test   %ebp,%ebp
jne    11b0 <make_readme+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11cf <make_readme+0x7f>
jmp    11b0 <make_readme+0x60>
lea    0xe16(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
add    $0x2718,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"File name: %s\0A\00"
@.str.1 = [5 x i8] c"/**\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c" */\0A\00"
@.str.4 = [15 x i8] c"Comment end.\0A\0A\00"
define void @make_readme(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [10000 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%9 = load i32*, i32** %5
%10 = load i8*, i8** %6
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %40, %3
%13 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i32* @fgets(i8* %13, i32 10000, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %41
17: ; preds = %12
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %7
br label %25
25: ; preds = %24, %20, %17
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32*, i32** %5
%30 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %25
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 0, i32* %7
br label %40
40: ; preds = %39, %35, %32
br label %12
41: ; preds = %12
%42 = load i32*, i32** %5
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"File name: %s\0A\00"
@.str.1 = [5 x i8] c"/**\0A\00"
@.str.3 = [5 x i8] c" */\0A\00"
@.str.4 = [15 x i8] c"Comment end.\0A\0A\00"
define void @make_readme(i32* nocapture %0, i32* nocapture %1, i8* %2) {
%4 = alloca [10000 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i32* @fgets(i8* %5, i32 10000, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %24, label %9
9: ; preds = %3, %20
%10 = phi i32 [ %21, %20 ], [ 0, %3 ]
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9, %12
%16 = call i32 @fputs(i8* %5, i32* %1)
%17 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %15, %12
%21 = phi i32 [ %19, %15 ], [ 0, %12 ]
%22 = call i32* @fgets(i8* %5, i32 10000, i32* %0)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %9
24: ; preds = %20, %3
%25 = call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i64 14, i64 1, i32* %1)
ret void
}