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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void copy_truncate_makefile(const char *backup) {
  char buf[8192];
  FILE *in;
  int i, j, ninbuf;
  char line[] = "# DO NOT EDIT BENEATH THIS LINE ... GENERATED AUTOMATICALLY";
  int len = strlen(line);
  if (!(in = fopen(backup, "r"))) {
    fprintf(stderr, "failed to open %s for reading\n", backup);
    perror(" ");
    exit(1);
  }
  ninbuf = 0;
  while ((i = getc(in)) != EOF) {
    if (i == '\n') {
      if (ninbuf && (strncmp(buf, line, len) == 0)) {
        ninbuf = 0;
        break;
      } else {
        for (j = 0; j < ninbuf; j++)
          putchar(buf[j]);
        putchar('\n');
        ninbuf = 0;
      }
    } else {
      if (ninbuf >= sizeof(buf)) {
        fprintf(stderr, "dependencies: makefile line too long\n");
        exit(1);
      }
      buf[ninbuf++] = i;
    }
  }
  if (ninbuf) {
    for (j = 0; j < ninbuf; j++)
      putchar(buf[j]);
    putchar('\n');
  }
  printf("%s\n", line);
  fclose(in);
}


x86 assembly (clang, -O0):
<copy_truncate_makefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2070,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x2060(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x3c,%edx
call   1090 <memcpy@plt>
lea    -0x2060(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x2064(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x2018(%rbp)
cmp    $0x0,%rax
jne    123b <copy_truncate_makefile+0x8b>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    0xe31(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x2024(%rbp)
mov    -0x2018(%rbp),%rdi
call   10d0 <getc@plt>
mov    %eax,-0x201c(%rbp)
mov    0x2d8a(%rip),%rcx
cmp    (%rcx),%eax
je     136a <copy_truncate_makefile+0x1ba>
cmpl   $0xa,-0x201c(%rbp)
jne    130f <copy_truncate_makefile+0x15f>
cmpl   $0x0,-0x2024(%rbp)
je     12b2 <copy_truncate_makefile+0x102>
lea    -0x2010(%rbp),%rdi
lea    -0x2060(%rbp),%rsi
mov    -0x2064(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12b2 <copy_truncate_makefile+0x102>
movl   $0x0,-0x2024(%rbp)
jmp    136a <copy_truncate_makefile+0x1ba>
movl   $0x0,-0x2020(%rbp)
mov    -0x2020(%rbp),%eax
cmp    -0x2024(%rbp),%eax
jge    12f6 <copy_truncate_makefile+0x146>
movslq -0x2020(%rbp),%rax
movsbl -0x2010(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x2020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2020(%rbp)
jmp    12bc <copy_truncate_makefile+0x10c>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x2024(%rbp)
jmp    1365 <copy_truncate_makefile+0x1b5>
movslq -0x2024(%rbp),%rax
cmp    $0x2000,%rax
jb     1343 <copy_truncate_makefile+0x193>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    0xd2d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x201c(%rbp),%eax
mov    %al,%cl
mov    -0x2024(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2024(%rbp)
cltq
mov    %cl,-0x2010(%rbp,%rax,1)
jmp    1245 <copy_truncate_makefile+0x95>
cmpl   $0x0,-0x2024(%rbp)
je     13c5 <copy_truncate_makefile+0x215>
movl   $0x0,-0x2020(%rbp)
mov    -0x2020(%rbp),%eax
cmp    -0x2024(%rbp),%eax
jge    13bb <copy_truncate_makefile+0x20b>
movslq -0x2020(%rbp),%rax
movsbl -0x2010(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x2020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2020(%rbp)
jmp    1381 <copy_truncate_makefile+0x1d1>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x2060(%rbp),%rsi
lea    0xcb2(%rip),%rdi
call   1070 <printf@plt>
mov    -0x2018(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x2070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_truncate_makefile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2048,%rsp
mov    %rdi,%r14
movups 0xe71(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xe59(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe3d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe21(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1060 <strlen@plt>
mov    %eax,%r12d
lea    0xe47(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1317 <copy_truncate_makefile+0x177>
mov    %rax,%r15
mov    %rax,%rdi
call   10c0 <getc@plt>
mov    0x2dd0(%rip),%r13
cmp    0x0(%r13),%eax
je     12cd <copy_truncate_makefile+0x12d>
xor    %ebp,%ebp
mov    %rsp,%rbx
jmp    124a <copy_truncate_makefile+0xaa>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
call   10c0 <getc@plt>
cmp    0x0(%r13),%eax
je     12a3 <copy_truncate_makefile+0x103>
cmp    $0xa,%eax
jne    1290 <copy_truncate_makefile+0xf0>
test   %ebp,%ebp
je     1230 <copy_truncate_makefile+0x90>
lea    0x40(%rsp),%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12cd <copy_truncate_makefile+0x12d>
mov    %ebp,%ebp
xor    %r14d,%r14d
nopl   (%rax)
movsbl 0x40(%rsp,%r14,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1270 <copy_truncate_makefile+0xd0>
jmp    1230 <copy_truncate_makefile+0x90>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x2000,%ebp
jae    12f6 <copy_truncate_makefile+0x156>
mov    %ebp,%ecx
add    $0x1,%ebp
mov    %al,0x40(%rsp,%rcx,1)
jmp    123c <copy_truncate_makefile+0x9c>
test   %ebp,%ebp
je     12cd <copy_truncate_makefile+0x12d>
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl 0x40(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12b0 <copy_truncate_makefile+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdb1(%rip),%rdi
mov    %rsp,%rsi
call   1070 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x2048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xd25(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@__const.copy_truncate_makefile.line = [60 x i8] c"# DO NOT EDIT BENEATH THIS LINE ... GENERATED AUTOMATICALLY\00"
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"failed to open %s for reading\0A\00"
@.str.2 = [2 x i8] c" \00"
@EOF = global i32 0
@.str.3 = [38 x i8] c"dependencies: makefile line too long\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define void @copy_truncate_makefile(i8* %0) {
%2 = alloca i8*
%3 = alloca [8192 x i8]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [60 x i8]
%9 = alloca i32
store i8* %0, i8** %2
%10 = bitcast [60 x i8]* %8 to i8*
%11 = getelementptr inbounds [60 x i8], [60 x i8]* %8, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %9
%13 = load i8*, i8** %2
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %4
%15 = icmp ne i32* %14, null
br i1 %15, label %22, label %16
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %2
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 @perror(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %1
store i32 0, i32* %7
br label %23
23: ; preds = %73, %22
%24 = load i32*, i32** %4
%25 = call i32 @getc(i32* %24)
store i32 %25, i32* %5
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %74
28: ; preds = %23
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %58
31: ; preds = %28
%32 = load i32, i32* %7
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%36 = getelementptr inbounds [60 x i8], [60 x i8]* %8, i64 0, i64 0
%37 = load i32, i32* %9
%38 = call i64 @strncmp(i8* %35, i8* %36, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 0, i32* %7
br label %74
41: ; preds = %34, %31
store i32 0, i32* %6
br label %42
42: ; preds = %52, %41
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %55
46: ; preds = %42
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @putchar(i8 signext %50)
br label %52
52: ; preds = %46
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %42
55: ; preds = %42
%56 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %7
br label %57
57: ; preds = %55
br label %73
58: ; preds = %28
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = icmp uge i64 %60, 8192
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %58
%67 = load i32, i32* %5
%68 = trunc i32 %67 to i8
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
%71 = sext i32 %69 to i64
%72 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %71
store i8 %68, i8* %72
br label %73
73: ; preds = %66, %57
br label %23
74: ; preds = %40, %23
%75 = load i32, i32* %7
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %93
77: ; preds = %74
store i32 0, i32* %6
br label %78
78: ; preds = %88, %77
%79 = load i32, i32* %6
%80 = load i32, i32* %7
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %91
82: ; preds = %78
%83 = load i32, i32* %6
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = call i32 @putchar(i8 signext %86)
br label %88
88: ; preds = %82
%89 = load i32, i32* %6
%90 = add nsw i32 %89, 1
store i32 %90, i32* %6
br label %78
91: ; preds = %78
%92 = call i32 @putchar(i8 signext 10)
br label %93
93: ; preds = %91, %74
%94 = getelementptr inbounds [60 x i8], [60 x i8]* %8, i64 0, i64 0
%95 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %94)
%96 = load i32*, i32** %4
%97 = call i32 @fclose(i32* %96)
ret void
}

LLVM IR (-O2):
@__const.copy_truncate_makefile.line = [60 x i8] c"# DO NOT EDIT BENEATH THIS LINE ... GENERATED AUTOMATICALLY\00"
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"failed to open %s for reading\0A\00"
@.str.2 = [2 x i8] c" \00"
@EOF = global i32 0
@.str.3 = [38 x i8] c"dependencies: makefile line too long\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define void @copy_truncate_makefile(i8* %0) {
%2 = alloca [8192 x i8]
%3 = alloca [60 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [60 x i8], [60 x i8]* %3, i64 0, i64 0
%6 = call i32 @strlen(i8* %5)
%7 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = call i32 @getc(i32* %7)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %67, label %18
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%16 = call i32 @perror(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %9, %49
%19 = phi i32 [ %51, %49 ], [ %10, %9 ]
%20 = phi i32 [ %50, %49 ], [ 0, %9 ]
%21 = icmp eq i32 %19, 10
br i1 %21, label %22, label %38
22: ; preds = %18
%23 = icmp eq i32 %20, 0
br i1 %23, label %36, label %24
24: ; preds = %22
%25 = call i64 @strncmp(i8* %4, i8* %5, i32 %6)
%26 = icmp eq i64 %25, 0
br i1 %26, label %67, label %27
27: ; preds = %24
%28 = zext i32 %20 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %34, %29 ]
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @putchar(i8 signext %32)
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, %28
br i1 %35, label %36, label %29
36: ; preds = %29, %22
%37 = call i32 @putchar(i8 signext 10)
br label %49
38: ; preds = %18
%39 = icmp ugt i32 %20, 8191
br i1 %39, label %40, label %44
40: ; preds = %38
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %38
%45 = zext i32 %20 to i64
%46 = trunc i32 %19 to i8
%47 = add nuw nsw i32 %20, 1
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 %45
store i8 %46, i8* %48
br label %49
49: ; preds = %44, %36
%50 = phi i32 [ 0, %36 ], [ %47, %44 ]
%51 = call i32 @getc(i32* %7)
%52 = load i32, i32* @EOF
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %18
54: ; preds = %49
%55 = icmp eq i32 %50, 0
br i1 %55, label %67, label %56
56: ; preds = %54
%57 = zext i32 %50 to i64
br label %58
58: ; preds = %56, %58
%59 = phi i64 [ 0, %56 ], [ %63, %58 ]
%60 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = call i32 @putchar(i8 signext %61)
%63 = add nuw nsw i64 %59, 1
%64 = icmp eq i64 %63, %57
br i1 %64, label %65, label %58
65: ; preds = %58
%66 = call i32 @putchar(i8 signext 10)
br label %67
67: ; preds = %24, %9, %65, %54
%68 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%69 = call i32 @fclose(i32* %7)
ret void
}