#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*/ Error_write(int, char *, int, char *, char *);
int /*<<< orphan*/ StrUtil_stripnewline(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int strlen(char *);
int FileUtil_getStrippedLine(char *line, int maxLen, FILE *Fp) {
  int lenLine;
  line[0] = '\0';
  fgets(line, maxLen, Fp);
  lenLine = strlen(line);
  if (lenLine == maxLen - 1 && line[lenLine - 1] != '\n') {
    Error_write(22, "FileUtil_getStrippedLine", 2, "Didn't read a newline\n%s",
                line);
    return 0;
  }
  StrUtil_stripnewline(line);
  return 1;
}


x86 assembly (clang, -O0):
<FileUtil_getStrippedLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11ce <FileUtil_getStrippedLine+0x8e>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11ce <FileUtil_getStrippedLine+0x8e>
mov    -0x10(%rbp),%r8
mov    $0x16,%edi
lea    0xe4f(%rip),%rsi
mov    $0x2,%edx
lea    0xe5c(%rip),%rcx
call   1050 <Error_write@plt>
movl   $0x0,-0x4(%rbp)
jmp    11de <FileUtil_getStrippedLine+0x9e>
mov    -0x10(%rbp),%rdi
call   1030 <StrUtil_stripnewline@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileUtil_getStrippedLine>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movb   $0x0,(%rdi)
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jne    1168 <FileUtil_getStrippedLine+0x28>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1177 <FileUtil_getStrippedLine+0x37>
mov    %rbx,%rdi
call   1030 <StrUtil_stripnewline@plt>
mov    $0x1,%eax
jmp    1199 <FileUtil_getStrippedLine+0x59>
lea    0xe82(%rip),%rsi
lea    0xe94(%rip),%rcx
mov    $0x16,%edi
mov    $0x2,%edx
mov    %rbx,%r8
call   1050 <Error_write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"FileUtil_getStrippedLine\00"
@.str.1 = [25 x i8] c"Didn't read a newline\0A%s\00"
define i32 @FileUtil_getStrippedLine(i8* %0, i32 %1, i32* nocapture %2) {
store i8 0, i8* %0
%4 = tail call i32 @fgets(i8* %0, i32 %1, i32* %2)
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %1, -1
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = add nsw i32 %5, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 10
br i1 %13, label %16, label %14
14: ; preds = %8
%15 = tail call i32 @Error_write(i32 22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %18
16: ; preds = %8, %3
%17 = tail call i32 @StrUtil_stripnewline(i8* %0)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ 0, %14 ], [ 1, %16 ]
ret i32 %19
}