char *btic4b_img_sgets(char *t, char *s) {
  while (*s && (*s != '\n')) {
    *t++ = *s++;
  }
  *t++ = 0;
  if (*s == '\n')
    s++;
  return (s);
}


x86 assembly (clang, -O0):
<btic4b_img_sgets>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1131 <btic4b_img_sgets+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1141 <btic4b_img_sgets+0x41>
jmp    1168 <btic4b_img_sgets+0x68>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    110c <btic4b_img_sgets+0xc>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1196 <btic4b_img_sgets+0x96>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<btic4b_img_sgets>:
movzbl (%rsi),%eax
test   %al,%al
je     1117 <btic4b_img_sgets+0x17>
cmp    $0xa,%al
je     1117 <btic4b_img_sgets+0x17>
add    $0x1,%rsi
mov    %al,(%rdi)
add    $0x1,%rdi
jmp    1100 <btic4b_img_sgets>
movb   $0x0,(%rdi)
xor    %eax,%eax
cmpb   $0xa,(%rsi)
sete   %al
add    %rsi,%rax
ret

LLVM IR (-O0):
define i8* @btic4b_img_sgets(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %17, %2
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
%20 = load i8, i8* %18
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 %20, i8* %21
br label %5
23: ; preds = %15
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
store i8 0, i8* %24
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %33
33: ; preds = %30, %23
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
define i8* @btic4b_img_sgets(i8* nocapture writeonly %0, i8* %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i8* [ %0, %2 ], [ %9, %7 ]
%5 = phi i8* [ %1, %2 ], [ %8, %7 ]
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %10
i8 10, label %10
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %6, i8* %4
br label %3
10: ; preds = %3, %3
store i8 0, i8* %4
%11 = load i8, i8* %5
%12 = icmp eq i8 %11, 10
%13 = zext i1 %12 to i64
%14 = getelementptr i8, i8* %5, i64 %13
ret i8* %14
}