#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 */
struct misc_file_buffer {
  int dummy;
};

/* Variables and functions */
#define EOF 128
int misc_get_char(struct misc_file_buffer *, int);
int search_line_for(struct misc_file_buffer *file, int search) {
  int i;
  int current;
  for (i = 0;; i++) {
    current = misc_get_char(file, i);
    switch (current) {
    case EOF:
    case '\n':
      return 0;
    default:
      if (current == search)
        return 1;
    }
  }
}


x86 assembly (clang, -O0):
<search_line_for>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <misc_get_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0xa,%eax
je     115c <search_line_for+0x4c>
jmp    1149 <search_line_for+0x39>
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
jne    1168 <search_line_for+0x58>
jmp    115c <search_line_for+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    1198 <search_line_for+0x88>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1180 <search_line_for+0x70>
movl   $0x1,-0x4(%rbp)
jmp    1198 <search_line_for+0x88>
jmp    1185 <search_line_for+0x75>
jmp    118a <search_line_for+0x7a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <search_line_for+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_line_for>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <misc_get_char@plt>
cmp    $0xa,%eax
je     1154 <search_line_for+0x44>
cmp    $0x80,%eax
je     1154 <search_line_for+0x44>
add    $0x1,%ebp
cmp    %r15d,%eax
jne    1130 <search_line_for+0x20>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.misc_file_buffer = type { i32 }
define i32 @search_line_for(%struct.misc_file_buffer* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.misc_file_buffer*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.misc_file_buffer* %0, %struct.misc_file_buffer** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %21, %2
%9 = load %struct.misc_file_buffer*, %struct.misc_file_buffer** %4
%10 = load i32, i32* %6
%11 = call i32 @misc_get_char(%struct.misc_file_buffer* %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
switch i32 %12, label %14 [
i32 128, label %13
i32 10, label %13
]
13: ; preds = %8, %8
store i32 0, i32* %3
br label %24
14: ; preds = %8
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %3
br label %24
19: ; preds = %14
br label %20
20: ; preds = %19
br label %21
21: ; preds = %20
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %8
24: ; preds = %18, %13
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.misc_file_buffer = type { i32 }
define i32 @search_line_for(%struct.misc_file_buffer* %0, i32 %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i32 [ 0, %2 ], [ %8, %6 ]
%5 = tail call i32 @misc_get_char(%struct.misc_file_buffer* %0, i32 %4)
switch i32 %5, label %6 [
i32 128, label %9
i32 10, label %9
]
6: ; preds = %3
%7 = icmp eq i32 %5, %1
%8 = add nuw nsw i32 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %6, %3, %3
%10 = phi i32 [ 0, %3 ], [ 0, %3 ], [ 1, %6 ]
ret i32 %10
}