#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 */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void check_ctrl_d(char *input_buffer, int length) {
  static int i;
  for (i = 0; i < length; i++) {
    if (!input_buffer[i]) {
      if (0 & 1)
        printf("--sh: input contains ^d. Exiting.\n\n");
      exit(0);
    }
    if (input_buffer[i] == '\n') {
      if (0 & 1)
        printf("--sh: input does not contain ^d\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<check_ctrl_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,0x2f03(%rip)
mov    0x2efd(%rip),%eax
cmp    -0xc(%rbp),%eax
jge    118a <check_ctrl_d+0x7a>
mov    -0x8(%rbp),%rax
movslq 0x2ee9(%rip),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    1154 <check_ctrl_d+0x44>
xor    %edi,%edi
call   1030 <exit@plt>
mov    -0x8(%rbp),%rax
movslq 0x2ecd(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1171 <check_ctrl_d+0x61>
jmp    118a <check_ctrl_d+0x7a>
jmp    1176 <check_ctrl_d+0x66>
mov    0x2eb0(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea7(%rip)
jmp    1129 <check_ctrl_d+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_ctrl_d>:
push   %rax
test   %esi,%esi
jle    1136 <check_ctrl_d+0x26>
mov    %esi,%eax
xor    %ecx,%ecx
nopl   0x0(%rax)
movzbl (%rdi,%rcx,1),%edx
cmp    $0xa,%dl
je     1136 <check_ctrl_d+0x26>
test   %dl,%dl
je     1138 <check_ctrl_d+0x28>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1120 <check_ctrl_d+0x10>
pop    %rax
ret
xor    %edi,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
@check_ctrl_d.i = internal global i32 0
define void @check_ctrl_d(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* @check_ctrl_d.i
br label %5
5: ; preds = %28, %2
%6 = load i32, i32* @check_ctrl_d.i
%7 = load i32, i32* %4
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %31
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i32, i32* @check_ctrl_d.i
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %9
%19 = load i8*, i8** %3
%20 = load i32, i32* @check_ctrl_d.i
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %27
26: ; preds = %18
br label %31
27: ; preds = %18
br label %28
28: ; preds = %27
%29 = load i32, i32* @check_ctrl_d.i
%30 = add nsw i32 %29, 1
store i32 %30, i32* @check_ctrl_d.i
br label %5
31: ; preds = %26, %5
ret void
}

LLVM IR (-O2):
define void @check_ctrl_d(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %12
%7 = phi i64 [ 0, %4 ], [ %13, %12 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %12 [
i8 0, label %10
i8 10, label %15
]
10: ; preds = %6
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %6
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %15, label %6
15: ; preds = %12, %6, %2
ret void
}