main(argc, argv) int argc;
char *argv[];
{
  char c;
  if (argc == 2) {
    std_err(argv[1]);
    std_err("\n");
  }
  close(0);
  open("/dev/tty0", 0);
  do {
    read(0, &c, 1);
  } while (c != '\n');
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    118d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   1070 <std_err@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1070 <std_err@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1030 <close@plt>
lea    0xe65(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1050 <open@plt>
xor    %edi,%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <read@plt>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    11a6 <main+0x56>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1173 <main+0x23>
mov    0x8(%rsi),%rdi
xor    %eax,%eax
call   1070 <std_err@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1070 <std_err@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1030 <close@plt>
lea    0xe7f(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <open@plt>
lea    0xf(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <read@plt>
cmpb   $0xa,0xf(%rsp)
jne    11a0 <main+0x50>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [10 x i8] c"/dev/tty0\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @std_err to i32 (i8*, ...)*)(i8* %12)
%14 = call i32 (i8*, ...) bitcast (i32 (...)* @std_err to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %9, %2
%16 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 0)
%17 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %18
18: ; preds = %20, %15
%19 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 0, i8* %6, i32 1)
br label %20
20: ; preds = %18
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %18, label %24
24: ; preds = %20
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [10 x i8] c"/dev/tty0\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @std_err to i32 (i8*, ...)*)(i8* %7)
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @std_err to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %5, %2
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 0)
%12 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %13
13: ; preds = %13, %10
%14 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 0, i8* %3, i32 1)
%15 = load i8, i8* %3
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %13
17: ; preds = %13
unreachable
}