#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 */
char getc(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
void read_email_address(char *s, int n) {
  while (n--) {
    *s = getc(stdin);
    if (*s == '\n')
      break;
    s++;
  }
  *s = 0;
}


x86 assembly (clang, -O0):
<read_email_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     116f <read_email_address+0x5f>
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
call   1030 <getc@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    115e <read_email_address+0x4e>
jmp    116f <read_email_address+0x5f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111f <read_email_address+0xf>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_email_address>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
test   %esi,%esi
je     1149 <read_email_address+0x39>
mov    %esi,%ebp
mov    0x2ec4(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edi
call   1030 <getc@plt>
mov    %al,(%rbx)
cmp    $0xa,%al
je     1149 <read_email_address+0x39>
add    $0xffffffff,%ebp
add    $0x1,%rbx
test   %ebp,%ebp
jne    1130 <read_email_address+0x20>
movb   $0x0,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define void @read_email_address(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %18, %2
%6 = load i32, i32* %4
%7 = add nsw i32 %6, -1
store i32 %7, i32* %4
%8 = icmp ne i32 %6, 0
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = load i32, i32* @stdin
%11 = call signext i8 @getc(i32 %10)
%12 = load i8*, i8** %3
store i8 %11, i8* %12
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %18
17: ; preds = %9
br label %21
18: ; preds = %9
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
br label %5
21: ; preds = %17, %5
%22 = load i8*, i8** %3
store i8 0, i8* %22
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
define void @read_email_address(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %11
%5 = phi i32 [ %7, %11 ], [ %1, %2 ]
%6 = phi i8* [ %12, %11 ], [ %0, %2 ]
%7 = add nsw i32 %5, -1
%8 = load i32, i32* @stdin
%9 = tail call signext i8 @getc(i32 %8)
store i8 %9, i8* %6
%10 = icmp eq i8 %9, 10
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = getelementptr inbounds i8, i8* %6, i64 1
%13 = icmp eq i32 %7, 0
br i1 %13, label %14, label %4
14: ; preds = %11, %4, %2
%15 = phi i8* [ %0, %2 ], [ %6, %4 ], [ %12, %11 ]
store i8 0, i8* %15
ret void
}