#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 */

/* Variables and functions */
size_t strcspn(char const *, char *);
int check_cmd_for_too_long_lines(char const *command, int const max,
                                 int *const error_length,
                                 int *const error_max_length) {
  while (*command) {
    size_t const l = strcspn(command, "\n");
    if (l > max) {
      *error_length = l;
      *error_max_length = max;
      return 103;
    }
    command += l;
    if (*command)
      ++command;
  }
  return 101;
}


x86 assembly (clang, -O0):
<check_cmd_for_too_long_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a4 <check_cmd_for_too_long_lines+0x94>
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1030 <strcspn@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jbe    117a <check_cmd_for_too_long_lines+0x6a>
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x67,-0x4(%rbp)
jmp    11ab <check_cmd_for_too_long_lines+0x9b>
mov    -0x30(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119f <check_cmd_for_too_long_lines+0x8f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <check_cmd_for_too_long_lines+0x17>
movl   $0x65,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_cmd_for_too_long_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x65,%r13d
cmpb   $0x0,(%rdi)
je     1179 <check_cmd_for_too_long_lines+0x69>
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%rbp
mov    %rcx,(%rsp)
movslq %esi,%r14
lea    0xec3(%rip),%rbx
nopl   (%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcspn@plt>
cmp    %r14,%rax
ja     1169 <check_cmd_for_too_long_lines+0x59>
mov    %rax,%rcx
add    %rbp,%rcx
cmpb   $0x1,0x0(%rbp,%rax,1)
sbb    $0xffffffffffffffff,%rcx
cmpb   $0x0,(%rcx)
mov    %rcx,%rbp
jne    1140 <check_cmd_for_too_long_lines+0x30>
jmp    1179 <check_cmd_for_too_long_lines+0x69>
mov    %eax,(%r15)
mov    (%rsp),%rax
mov    %r12d,(%rax)
mov    $0x67,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i32 @check_cmd_for_too_long_lines(i8* nocapture %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = sext i32 %1 to i64
br label %9
9: ; preds = %7, %15
%10 = phi i8* [ %0, %7 ], [ %20, %15 ]
%11 = tail call i64 @strcspn(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp ugt i64 %11, %8
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = trunc i64 %11 to i32
store i32 %14, i32* %2
store i32 %1, i32* %3
br label %23
15: ; preds = %9
%16 = getelementptr inbounds i8, i8* %10, i64 %11
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
%19 = zext i1 %18 to i64
%20 = getelementptr i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %9
23: ; preds = %15, %4, %13
%24 = phi i32 [ 103, %13 ], [ 101, %4 ], [ 101, %15 ]
ret i32 %24
}