#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*/ *);
scalar_t__ isblank(char);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int check_line_continuation(FILE *ftmpl, char *node_name) {
  char buf[256];
  int line = 0;
  while (fgets(buf, 256, ftmpl) != NULL) {
    int len = strlen(buf);
    ++line;
    if (len < 2 || buf[len - 1] != '\n' || !isblank(buf[len - 2])) {
      continue;
    }
    len -= 3;
    while (len >= 0 && isblank(buf[len])) {
      --len;
    }
    if (len >= 0 && buf[len] == '\\') {
      printf("[%s]\n", node_name);
      printf("Warning: \"backslash + space\" detected at the end of line %d.\n"
             "         This will not work as line continuation.\n",
             line);
      continue;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_line_continuation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12ae <check_line_continuation+0x16e>
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x118(%rbp)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
cmpl   $0x2,-0x118(%rbp)
jl     11e8 <check_line_continuation+0xa8>
mov    -0x118(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    11e8 <check_line_continuation+0xa8>
mov    -0x118(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%edi
ff
call   1050 <isblank@plt>
cmp    $0x0,%rax
jne    11ed <check_line_continuation+0xad>
jmp    115d <check_line_continuation+0x1d>
mov    -0x118(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x118(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x118(%rbp)
mov    %al,-0x119(%rbp)
jl     1232 <check_line_continuation+0xf2>
movslq -0x118(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%edi
ff
call   1050 <isblank@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    1245 <check_line_continuation+0x105>
jmp    1259 <check_line_continuation+0x119>
mov    -0x118(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x118(%rbp)
jmp    11fc <check_line_continuation+0xbc>
cmpl   $0x0,-0x118(%rbp)
jl     12a9 <check_line_continuation+0x169>
movslq -0x118(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x5c,%eax
jne    12a9 <check_line_continuation+0x169>
mov    -0x10(%rbp),%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x114(%rbp),%esi
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115d <check_line_continuation+0x1d>
jmp    115d <check_line_continuation+0x1d>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_line_continuation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     122d <check_line_continuation+0xed>
mov    %rsp,%rbx
lea    0xe8c(%rip),%r13
xor    %ebp,%ebp
jmp    1199 <check_line_continuation+0x59>
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     122d <check_line_continuation+0xed>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0x1,%ebp
cmp    $0x2,%eax
jl     1180 <check_line_continuation+0x40>
mov    %eax,%r12d
lea    -0x1(%r12),%eax
cmpb   $0xa,(%rsp,%rax,1)
jne    1180 <check_line_continuation+0x40>
lea    -0x2(%r12),%eax
movsbl (%rsp,%rax,1),%edi
call   1050 <isblank@plt>
test   %rax,%rax
je     1180 <check_line_continuation+0x40>
cmp    $0x3,%r12d
jb     1180 <check_line_continuation+0x40>
add    $0xfffffffd,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rsp,%r12,1),%edi
call   1050 <isblank@plt>
test   %rax,%rax
je     11fe <check_line_continuation+0xbe>
lea    -0x1(%r12),%rax
test   %r12,%r12
mov    %rax,%r12
jg     11e0 <check_line_continuation+0xa0>
jmp    1180 <check_line_continuation+0x40>
mov    %r12d,%eax
cmpb   $0x5c,(%rsp,%rax,1)
jne    1180 <check_line_continuation+0x40>
lea    0xdee(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <check_line_continuation+0x40>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"[%s]\0A\00"
@.str.1 = [112 x i8] c"Warning: \22backslash + space\22 detected at the end of line %d.\0A This will not work as line continuation.\0A\00"
define i32 @check_line_continuation(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %6
br label %8
8: ; preds = %70, %65, %36, %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%10 = load i32*, i32** %3
%11 = call i32* @fgets(i8* %9, i32 256, i32* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %71
13: ; preds = %8
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 2
br i1 %19, label %36, label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br i1 %27, label %36, label %28
28: ; preds = %20
%29 = load i32, i32* %7
%30 = sub nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i64 @isblank(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %28, %20, %13
br label %8
37: ; preds = %28
%38 = load i32, i32* %7
%39 = sub nsw i32 %38, 3
store i32 %39, i32* %7
br label %40
40: ; preds = %52, %37
%41 = load i32, i32* %7
%42 = icmp sge i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i64 @isblank(i8 signext %47)
%49 = icmp ne i64 %48, 0
br label %50
50: ; preds = %43, %40
%51 = phi i1 [ false, %40 ], [ %49, %43 ]
br i1 %51, label %52, label %55
52: ; preds = %50
%53 = load i32, i32* %7
%54 = add nsw i32 %53, -1
store i32 %54, i32* %7
br label %40
55: ; preds = %50
%56 = load i32, i32* %7
%57 = icmp sge i32 %56, 0
br i1 %57, label %58, label %70
58: ; preds = %55
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 92
br i1 %64, label %65, label %70
65: ; preds = %58
%66 = load i8*, i8** %4
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %66)
%68 = load i32, i32* %6
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0), i32 %68)
br label %8
70: ; preds = %58, %55
br label %8
71: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"[%s]\0A\00"
@.str.1 = [112 x i8] c"Warning: \22backslash + space\22 detected at the end of line %d.\0A This will not work as line continuation.\0A\00"
define i32 @check_line_continuation(i32* nocapture %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32* @fgets(i8* %4, i32 256, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %50, label %7
7: ; preds = %2, %47
%8 = phi i32 [ %10, %47 ], [ 0, %2 ]
%9 = call i32 @strlen(i8* %4)
%10 = add nuw nsw i32 %8, 1
%11 = icmp slt i32 %9, 2
br i1 %11, label %47, label %12
12: ; preds = %7
%13 = add nsw i32 %9, -1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %47
18: ; preds = %12
%19 = add nsw i32 %9, -2
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i64 @isblank(i8 signext %22)
%24 = icmp ne i64 %23, 0
%25 = icmp ugt i32 %9, 2
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %27, label %47
27: ; preds = %18
%28 = add nsw i32 %9, -3
%29 = zext i32 %28 to i64
br label %30
30: ; preds = %27, %36
%31 = phi i64 [ %29, %27 ], [ %37, %36 ]
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i64 @isblank(i8 signext %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %30
%37 = add nsw i64 %31, -1
%38 = icmp sgt i64 %31, 0
br i1 %38, label %30, label %47
39: ; preds = %30
%40 = and i64 %31, 4294967295
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 92
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %47
47: ; preds = %36, %39, %7, %12, %18, %44
%48 = call i32* @fgets(i8* %4, i32 256, i32* %0)
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %7
50: ; preds = %47, %2
ret i32 0
}